* [dpdk-stable] [PATCH] examples/vhost_scsi: fix buffer not terminated
@ 2017-09-22 13:09 Michal Jastrzebski
2017-10-02 13:53 ` [dpdk-stable] [dpdk-dev] " Jastrzebski, MichalX K
2018-05-14 19:08 ` Thomas Monjalon
0 siblings, 2 replies; 8+ messages in thread
From: Michal Jastrzebski @ 2017-09-22 13:09 UTC (permalink / raw)
To: yliu, maxime.coquelin
Cc: dev, deepak.k.jain, Jacek Piasecki, changpeng.liu, stable
From: Jacek Piasecki <jacekx.piasecki@intel.com>
Fix size of buffer in strcpy. There was possible to get
not terminated string after copy operation.
Coverity issue: 158629
Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")
Cc: changpeng.liu@intel.com
Cc: stable@dpdk.org
Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
---
examples/vhost_scsi/vhost_scsi.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/examples/vhost_scsi/vhost_scsi.c b/examples/vhost_scsi/vhost_scsi.c
index b4f1f8d..b1a8c93 100644
--- a/examples/vhost_scsi/vhost_scsi.c
+++ b/examples/vhost_scsi/vhost_scsi.c
@@ -186,8 +186,9 @@ static uint64_t gpa_to_vva(int vid, uint64_t gpa)
if (!bdev)
return NULL;
- strncpy(bdev->name, bdev_name, sizeof(bdev->name));
- strncpy(bdev->product_name, bdev_serial, sizeof(bdev->product_name));
+ strncpy(bdev->name, bdev_name, sizeof(bdev->name) - 1);
+ strncpy(bdev->product_name, bdev_serial,
+ sizeof(bdev->product_name) - 1);
bdev->blocklen = blk_size;
bdev->blockcnt = blk_cnt;
bdev->write_cache = wce_enable;
--
1.9.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
2017-09-22 13:09 [dpdk-stable] [PATCH] examples/vhost_scsi: fix buffer not terminated Michal Jastrzebski
@ 2017-10-02 13:53 ` Jastrzebski, MichalX K
2017-10-11 13:45 ` Jastrzebski, MichalX K
2018-05-14 19:08 ` Thomas Monjalon
1 sibling, 1 reply; 8+ messages in thread
From: Jastrzebski, MichalX K @ 2017-10-02 13:53 UTC (permalink / raw)
To: Jastrzebski, MichalX K, yliu, maxime.coquelin
Cc: dev, Jain, Deepak K, Piasecki, JacekX, Liu, Changpeng, stable
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Michal Jastrzebski
> Sent: Friday, September 22, 2017 3:10 PM
> To: yliu@fridaylinux.org; maxime.coquelin@redhat.com
> Cc: dev@dpdk.org; Jain, Deepak K <deepak.k.jain@intel.com>; Piasecki,
> JacekX <jacekx.piasecki@intel.com>; Liu, Changpeng
> <changpeng.liu@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
>
> From: Jacek Piasecki <jacekx.piasecki@intel.com>
>
> Fix size of buffer in strcpy. There was possible to get
> not terminated string after copy operation.
>
> Coverity issue: 158629
> Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")
> Cc: changpeng.liu@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> ---
> examples/vhost_scsi/vhost_scsi.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/examples/vhost_scsi/vhost_scsi.c
> b/examples/vhost_scsi/vhost_scsi.c
> index b4f1f8d..b1a8c93 100644
> --- a/examples/vhost_scsi/vhost_scsi.c
> +++ b/examples/vhost_scsi/vhost_scsi.c
> @@ -186,8 +186,9 @@ static uint64_t gpa_to_vva(int vid, uint64_t gpa)
> if (!bdev)
> return NULL;
>
> - strncpy(bdev->name, bdev_name, sizeof(bdev->name));
> - strncpy(bdev->product_name, bdev_serial, sizeof(bdev-
> >product_name));
> + strncpy(bdev->name, bdev_name, sizeof(bdev->name) - 1);
> + strncpy(bdev->product_name, bdev_serial,
> + sizeof(bdev->product_name) - 1);
> bdev->blocklen = blk_size;
> bdev->blockcnt = blk_cnt;
> bdev->write_cache = wce_enable;
> --
> 1.9.1
Hi Yu / Maxime,
I would like to ask for a feedback regarding proposed fix.
If everything is ok with it, please send acked-by.
Best regards
Michal.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
2017-10-02 13:53 ` [dpdk-stable] [dpdk-dev] " Jastrzebski, MichalX K
@ 2017-10-11 13:45 ` Jastrzebski, MichalX K
0 siblings, 0 replies; 8+ messages in thread
From: Jastrzebski, MichalX K @ 2017-10-11 13:45 UTC (permalink / raw)
To: yliu, maxime.coquelin
Cc: dev, Jain, Deepak K, Piasecki, JacekX, Liu, Changpeng, stable
> -----Original Message-----
> From: Jastrzebski, MichalX K
> Sent: Monday, October 2, 2017 3:53 PM
> To: Jastrzebski, MichalX K <michalx.k.jastrzebski@intel.com>;
> yliu@fridaylinux.org; maxime.coquelin@redhat.com
> Cc: dev@dpdk.org; Jain, Deepak K <deepak.k.jain@intel.com>; Piasecki,
> JacekX <jacekx.piasecki@intel.com>; Liu, Changpeng
> <changpeng.liu@intel.com>; stable@dpdk.org
> Subject: RE: [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not
> terminated
>
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Michal
> Jastrzebski
> > Sent: Friday, September 22, 2017 3:10 PM
> > To: yliu@fridaylinux.org; maxime.coquelin@redhat.com
> > Cc: dev@dpdk.org; Jain, Deepak K <deepak.k.jain@intel.com>; Piasecki,
> > JacekX <jacekx.piasecki@intel.com>; Liu, Changpeng
> > <changpeng.liu@intel.com>; stable@dpdk.org
> > Subject: [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not
> terminated
> >
> > From: Jacek Piasecki <jacekx.piasecki@intel.com>
> >
> > Fix size of buffer in strcpy. There was possible to get
> > not terminated string after copy operation.
> >
> > Coverity issue: 158629
> > Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample
> app")
> > Cc: changpeng.liu@intel.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> > ---
> > examples/vhost_scsi/vhost_scsi.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/examples/vhost_scsi/vhost_scsi.c
> > b/examples/vhost_scsi/vhost_scsi.c
> > index b4f1f8d..b1a8c93 100644
> > --- a/examples/vhost_scsi/vhost_scsi.c
> > +++ b/examples/vhost_scsi/vhost_scsi.c
> > @@ -186,8 +186,9 @@ static uint64_t gpa_to_vva(int vid, uint64_t gpa)
> > if (!bdev)
> > return NULL;
> >
> > - strncpy(bdev->name, bdev_name, sizeof(bdev->name));
> > - strncpy(bdev->product_name, bdev_serial, sizeof(bdev-
> > >product_name));
> > + strncpy(bdev->name, bdev_name, sizeof(bdev->name) - 1);
> > + strncpy(bdev->product_name, bdev_serial,
> > + sizeof(bdev->product_name) - 1);
> > bdev->blocklen = blk_size;
> > bdev->blockcnt = blk_cnt;
> > bdev->write_cache = wce_enable;
> > --
> > 1.9.1
>
> Hi Yu / Maxime,
> I would like to ask for a feedback regarding proposed fix.
> If everything is ok with it, please send acked-by.
>
> Best regards
> Michal.
Acked-by: Michal Jastrzebski <michalx.k.jastrzebski@intel.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
2017-09-22 13:09 [dpdk-stable] [PATCH] examples/vhost_scsi: fix buffer not terminated Michal Jastrzebski
2017-10-02 13:53 ` [dpdk-stable] [dpdk-dev] " Jastrzebski, MichalX K
@ 2018-05-14 19:08 ` Thomas Monjalon
2018-05-15 5:59 ` Pattan, Reshma
1 sibling, 1 reply; 8+ messages in thread
From: Thomas Monjalon @ 2018-05-14 19:08 UTC (permalink / raw)
To: Michal Jastrzebski, Jacek Piasecki, reshma.pattan
Cc: dev, yliu, maxime.coquelin, deepak.k.jain, changpeng.liu, stable,
bruce.richardson
22/09/2017 15:09, Michal Jastrzebski:
> From: Jacek Piasecki <jacekx.piasecki@intel.com>
>
> Fix size of buffer in strcpy. There was possible to get
> not terminated string after copy operation.
>
> Coverity issue: 158629
> Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")
> Cc: changpeng.liu@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> ---
> - strncpy(bdev->name, bdev_name, sizeof(bdev->name));
> - strncpy(bdev->product_name, bdev_serial, sizeof(bdev->product_name));
> + strncpy(bdev->name, bdev_name, sizeof(bdev->name) - 1);
> + strncpy(bdev->product_name, bdev_serial,
> + sizeof(bdev->product_name) - 1);
Can it be fixed with strlcpy?
I wonder why recent patch from Reshma is not touching these lines:
http://dpdk.org/commit/21ce8e44b8d
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
2018-05-14 19:08 ` Thomas Monjalon
@ 2018-05-15 5:59 ` Pattan, Reshma
0 siblings, 0 replies; 8+ messages in thread
From: Pattan, Reshma @ 2018-05-15 5:59 UTC (permalink / raw)
To: Thomas Monjalon, Michal Jastrzebski, Jacek Piasecki
Cc: dev, yliu, maxime.coquelin, Jain, Deepak K, Liu, Changpeng,
stable, Richardson, Bruce
Hi Thomas,
> Can it be fixed with strlcpy?
>
> I wonder why recent patch from Reshma is not touching these lines:
> http://dpdk.org/commit/21ce8e44b8d
>
Yes, I remembered now, I fixed only gcc 8.0.1 compilation issues of this file, in which the lines of code this patch
is fixing is not listed. I totally forgot to replace these lines with strlcpy later on.
Thanks,
Reshma
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
2017-10-02 13:50 ` [dpdk-stable] [dpdk-dev] " Jastrzebski, MichalX K
@ 2017-10-02 15:07 ` Maxime Coquelin
0 siblings, 0 replies; 8+ messages in thread
From: Maxime Coquelin @ 2017-10-02 15:07 UTC (permalink / raw)
To: Jastrzebski, MichalX K, yliu
Cc: dev, Jain, Deepak K, Piasecki, JacekX, Liu, Changpeng, stable
On 10/02/2017 03:50 PM, Jastrzebski, MichalX K wrote:
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Michal Jastrzebski
>> Sent: Friday, September 22, 2017 3:08 PM
>> To: yliu@fridaylinux.org; maxime.coquelin@redhat.com
>> Cc: dev@dpdk.org; Jain, Deepak K <deepak.k.jain@intel.com>; Piasecki,
>> JacekX <jacekx.piasecki@intel.com>; Liu, Changpeng
>> <changpeng.liu@intel.com>; stable@dpdk.org
>> Subject: [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
>>
>> From: Jacek Piasecki <jacekx.piasecki@intel.com>
>>
>> Fix size of buffer in strcpy. There was possible to get
>> not terminated string after copy operation.
>>
>> Coverity issue: 158631
>> Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")
>> Cc: changpeng.liu@intel.com
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
>> ---
>> examples/vhost_scsi/scsi.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/examples/vhost_scsi/scsi.c b/examples/vhost_scsi/scsi.c
>> index 54d3104..de9639a 100644
>> --- a/examples/vhost_scsi/scsi.c
>> +++ b/examples/vhost_scsi/scsi.c
>> @@ -307,7 +307,8 @@
>> strncpy((char *)inqdata->t10_vendor_id, "INTEL", 8);
>>
>> /* PRODUCT IDENTIFICATION */
>> - strncpy((char *)inqdata->product_id, bdev->product_name,
>> 16);
>> + strncpy((char *)inqdata->product_id, bdev->product_name,
>> + ARRAY_SIZE(inqdata->product_id) - 1);
Does it assume that product_id is memzero'ed before?
IIUC strncpy manpage, it wouldn't protect against non-null terminated
strings if it is not the case:
"
A simple implementation of strncpy() might be:
char *
strncpy(char *dest, const char *src, size_t n)
{
size_t i;
for (i = 0; i < n && src[i] != '\0'; i++)
dest[i] = src[i];
for ( ; i < n; i++)
dest[i] = '\0';
return dest;
}
"
Cheers,
Maxime
>>
>> /* PRODUCT REVISION LEVEL */
>> strncpy((char *)inqdata->product_rev, "0001", 4);
>> --
>> 1.9.1
>
> Hi Yu / Maxime,
> I would like to ask for a feedback regarding proposed fix.
> If everything is ok with it, please send acked-by.
>
> Best regards
> Michal.
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
2017-09-22 13:07 [dpdk-stable] " Michal Jastrzebski
@ 2017-10-02 13:50 ` Jastrzebski, MichalX K
2017-10-02 15:07 ` Maxime Coquelin
0 siblings, 1 reply; 8+ messages in thread
From: Jastrzebski, MichalX K @ 2017-10-02 13:50 UTC (permalink / raw)
To: Jastrzebski, MichalX K, yliu, maxime.coquelin
Cc: dev, Jain, Deepak K, Piasecki, JacekX, Liu, Changpeng, stable
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Michal Jastrzebski
> Sent: Friday, September 22, 2017 3:08 PM
> To: yliu@fridaylinux.org; maxime.coquelin@redhat.com
> Cc: dev@dpdk.org; Jain, Deepak K <deepak.k.jain@intel.com>; Piasecki,
> JacekX <jacekx.piasecki@intel.com>; Liu, Changpeng
> <changpeng.liu@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
>
> From: Jacek Piasecki <jacekx.piasecki@intel.com>
>
> Fix size of buffer in strcpy. There was possible to get
> not terminated string after copy operation.
>
> Coverity issue: 158631
> Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")
> Cc: changpeng.liu@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> ---
> examples/vhost_scsi/scsi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/examples/vhost_scsi/scsi.c b/examples/vhost_scsi/scsi.c
> index 54d3104..de9639a 100644
> --- a/examples/vhost_scsi/scsi.c
> +++ b/examples/vhost_scsi/scsi.c
> @@ -307,7 +307,8 @@
> strncpy((char *)inqdata->t10_vendor_id, "INTEL", 8);
>
> /* PRODUCT IDENTIFICATION */
> - strncpy((char *)inqdata->product_id, bdev->product_name,
> 16);
> + strncpy((char *)inqdata->product_id, bdev->product_name,
> + ARRAY_SIZE(inqdata->product_id) - 1);
>
> /* PRODUCT REVISION LEVEL */
> strncpy((char *)inqdata->product_rev, "0001", 4);
> --
> 1.9.1
Hi Yu / Maxime,
I would like to ask for a feedback regarding proposed fix.
If everything is ok with it, please send acked-by.
Best regards
Michal.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dpdk-stable] [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
2017-09-22 13:08 [dpdk-stable] " Michal Jastrzebski
@ 2017-09-22 13:23 ` Jastrzebski, MichalX K
0 siblings, 0 replies; 8+ messages in thread
From: Jastrzebski, MichalX K @ 2017-09-22 13:23 UTC (permalink / raw)
To: Jastrzebski, MichalX K, yliu, maxime.coquelin
Cc: dev, Jain, Deepak K, Piasecki, JacekX, Liu, Changpeng, stable
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Michal Jastrzebski
> Sent: Friday, September 22, 2017 3:08 PM
> To: yliu@fridaylinux.org; maxime.coquelin@redhat.com
> Cc: dev@dpdk.org; Jain, Deepak K <deepak.k.jain@intel.com>; Piasecki,
> JacekX <jacekx.piasecki@intel.com>; Liu, Changpeng
> <changpeng.liu@intel.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] examples/vhost_scsi: fix buffer not terminated
>
> From: Jacek Piasecki <jacekx.piasecki@intel.com>
>
> Fix size of buffer in strcpy. There was possible to get
> not terminated string after copy operation.
>
> Coverity issue: 158631
> Fixes: db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")
> Cc: changpeng.liu@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Jacek Piasecki <jacekx.piasecki@intel.com>
> ---
> examples/vhost_scsi/scsi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/examples/vhost_scsi/scsi.c b/examples/vhost_scsi/scsi.c
> index 54d3104..de9639a 100644
> --- a/examples/vhost_scsi/scsi.c
> +++ b/examples/vhost_scsi/scsi.c
> @@ -307,7 +307,8 @@
> strncpy((char *)inqdata->t10_vendor_id, "INTEL", 8);
>
> /* PRODUCT IDENTIFICATION */
> - strncpy((char *)inqdata->product_id, bdev->product_name,
> 16);
> + strncpy((char *)inqdata->product_id, bdev->product_name,
> + ARRAY_SIZE(inqdata->product_id) - 1);
>
> /* PRODUCT REVISION LEVEL */
> strncpy((char *)inqdata->product_rev, "0001", 4);
> --
> 1.9.1
I am sorry, please ignore this mail - sent two times.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-05-15 5:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-22 13:09 [dpdk-stable] [PATCH] examples/vhost_scsi: fix buffer not terminated Michal Jastrzebski
2017-10-02 13:53 ` [dpdk-stable] [dpdk-dev] " Jastrzebski, MichalX K
2017-10-11 13:45 ` Jastrzebski, MichalX K
2018-05-14 19:08 ` Thomas Monjalon
2018-05-15 5:59 ` Pattan, Reshma
-- strict thread matches above, loose matches on Subject: below --
2017-09-22 13:08 [dpdk-stable] " Michal Jastrzebski
2017-09-22 13:23 ` [dpdk-stable] [dpdk-dev] " Jastrzebski, MichalX K
2017-09-22 13:07 [dpdk-stable] " Michal Jastrzebski
2017-10-02 13:50 ` [dpdk-stable] [dpdk-dev] " Jastrzebski, MichalX K
2017-10-02 15:07 ` Maxime Coquelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).