* [dpdk-dev] [PATCH v2 0/1] Fix coverity issues reported in DPDK-26381 @ 2021-04-08 8:51 Wei Huang 2021-04-08 8:51 ` [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning Wei Huang 0 siblings, 1 reply; 13+ messages in thread From: Wei Huang @ 2021-04-08 8:51 UTC (permalink / raw) To: dev, rosen.xu, qi.z.zhang; +Cc: stable, tianfei.zhang, ferruh.yigit, Wei Huang Below coverity issues are fixed in this patch set. 367480, 367482 Main changes from v1: - change two patches to one patch because they have the same root cause Wei Huang (1): raw/ifpga/base: check size before assigning drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- drivers/raw/ifpga/base/opae_intel_max10.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) -- 2.29.2 ^ permalink raw reply [flat|nested] 13+ messages in thread
* [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-08 8:51 [dpdk-dev] [PATCH v2 0/1] Fix coverity issues reported in DPDK-26381 Wei Huang @ 2021-04-08 8:51 ` Wei Huang 2021-04-08 9:38 ` Ferruh Yigit 2021-04-19 8:12 ` Zhang, Qi Z 0 siblings, 2 replies; 13+ messages in thread From: Wei Huang @ 2021-04-08 8:51 UTC (permalink / raw) To: dev, rosen.xu, qi.z.zhang; +Cc: stable, tianfei.zhang, ferruh.yigit, Wei Huang In max10_staging_area_init(), variable "size" from fdt_get_reg() may be invalid, it should be checked before assigning to member variable "staging_area_size" of structure "intel_max10_device". Coverity issue: 367480, 367482 Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device driver") Signed-off-by: Wei Huang <wei.huang@intel.com> --- v2: check size before assigning to staging_area_size --- drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- drivers/raw/ifpga/base/opae_intel_max10.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c b/drivers/raw/ifpga/base/opae_intel_max10.c index 443e248fb3..c223fafa03 100644 --- a/drivers/raw/ifpga/base/opae_intel_max10.c +++ b/drivers/raw/ifpga/base/opae_intel_max10.c @@ -593,7 +593,7 @@ static int max10_staging_area_init(struct intel_max10_device *dev) continue; ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); - if (!ret) { + if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { dev->staging_area_base = start; dev->staging_area_size = size; } diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h b/drivers/raw/ifpga/base/opae_intel_max10.h index 670683f017..e7142d6f0d 100644 --- a/drivers/raw/ifpga/base/opae_intel_max10.h +++ b/drivers/raw/ifpga/base/opae_intel_max10.h @@ -182,6 +182,7 @@ struct opae_retimer_status { #define SBUS_VERSION GENMASK(31, 16) #define DFT_MAX_SIZE 0x7e0000 +#define MAX_STAGING_AREA_SIZE 0x3800000 int max10_reg_read(struct intel_max10_device *dev, unsigned int reg, unsigned int *val); -- 2.29.2 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-08 8:51 ` [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning Wei Huang @ 2021-04-08 9:38 ` Ferruh Yigit 2021-04-09 14:56 ` Aaron Conole 2021-04-19 8:12 ` Zhang, Qi Z 1 sibling, 1 reply; 13+ messages in thread From: Ferruh Yigit @ 2021-04-08 9:38 UTC (permalink / raw) To: Aaron Conole, David Marchand Cc: stable, tianfei.zhang, Wei Huang, qi.z.zhang, rosen.xu, dev, John McNamara On 4/8/2021 9:51 AM, Wei Huang wrote: > In max10_staging_area_init(), variable "size" from fdt_get_reg() may > be invalid, it should be checked before assigning to member variable > "staging_area_size" of structure "intel_max10_device". > > Coverity issue: 367480, 367482 > Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device driver") > > Signed-off-by: Wei Huang <wei.huang@intel.com> > --- > v2: check size before assigning to staging_area_size > --- > drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- > drivers/raw/ifpga/base/opae_intel_max10.h | 1 + > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c b/drivers/raw/ifpga/base/opae_intel_max10.c > index 443e248fb3..c223fafa03 100644 > --- a/drivers/raw/ifpga/base/opae_intel_max10.c > +++ b/drivers/raw/ifpga/base/opae_intel_max10.c > @@ -593,7 +593,7 @@ static int max10_staging_area_init(struct intel_max10_device *dev) > continue; > > ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); > - if (!ret) { > + if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { > dev->staging_area_base = start; > dev->staging_area_size = size; > } > diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h b/drivers/raw/ifpga/base/opae_intel_max10.h > index 670683f017..e7142d6f0d 100644 > --- a/drivers/raw/ifpga/base/opae_intel_max10.h > +++ b/drivers/raw/ifpga/base/opae_intel_max10.h > @@ -182,6 +182,7 @@ struct opae_retimer_status { > #define SBUS_VERSION GENMASK(31, 16) > > #define DFT_MAX_SIZE 0x7e0000 > +#define MAX_STAGING_AREA_SIZE 0x3800000 > > int max10_reg_read(struct intel_max10_device *dev, > unsigned int reg, unsigned int *val); > Hi Aaron, David, The data flow is complex for this coverity issues [1], at least I can't confirm that change fixes the issue. Are you aware of any way to confirm this coverity issue before merging it? [1] https://scan4.coverity.com/reports.htm#v26325/p10075/fileInstanceId=100181086&defectInstanceId=14238477&mergedDefectId=367480 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-08 9:38 ` Ferruh Yigit @ 2021-04-09 14:56 ` Aaron Conole 2021-04-14 2:46 ` Zhang, Tianfei 0 siblings, 1 reply; 13+ messages in thread From: Aaron Conole @ 2021-04-09 14:56 UTC (permalink / raw) To: Ferruh Yigit Cc: David Marchand, stable, tianfei.zhang, Wei Huang, qi.z.zhang, rosen.xu, dev, John McNamara Ferruh Yigit <ferruh.yigit@intel.com> writes: > On 4/8/2021 9:51 AM, Wei Huang wrote: >> In max10_staging_area_init(), variable "size" from fdt_get_reg() may >> be invalid, it should be checked before assigning to member variable >> "staging_area_size" of structure "intel_max10_device". >> >> Coverity issue: 367480, 367482 >> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device driver") >> >> Signed-off-by: Wei Huang <wei.huang@intel.com> >> --- >> v2: check size before assigning to staging_area_size >> --- >> drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- >> drivers/raw/ifpga/base/opae_intel_max10.h | 1 + >> 2 files changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c b/drivers/raw/ifpga/base/opae_intel_max10.c >> index 443e248fb3..c223fafa03 100644 >> --- a/drivers/raw/ifpga/base/opae_intel_max10.c >> +++ b/drivers/raw/ifpga/base/opae_intel_max10.c >> @@ -593,7 +593,7 @@ static int max10_staging_area_init(struct intel_max10_device *dev) >> continue; >> ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); >> - if (!ret) { >> + if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { >> dev->staging_area_base = start; >> dev->staging_area_size = size; >> } >> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h b/drivers/raw/ifpga/base/opae_intel_max10.h >> index 670683f017..e7142d6f0d 100644 >> --- a/drivers/raw/ifpga/base/opae_intel_max10.h >> +++ b/drivers/raw/ifpga/base/opae_intel_max10.h >> @@ -182,6 +182,7 @@ struct opae_retimer_status { >> #define SBUS_VERSION GENMASK(31, 16) >> #define DFT_MAX_SIZE 0x7e0000 >> +#define MAX_STAGING_AREA_SIZE 0x3800000 >> int max10_reg_read(struct intel_max10_device *dev, >> unsigned int reg, unsigned int *val); >> > > Hi Aaron, David, > > The data flow is complex for this coverity issues [1], at least I > can't confirm that change fixes the issue. > > Are you aware of any way to confirm this coverity issue before merging it? Not generically. :-/ We need someone that understands the data flow and the coverity splat to know that the fix is correct. Coverity even ratelimits how many outstanding submissions we can post, iirc, so we don't get to push patch sets (unless we pay? I don't recall if there's an option for that). > [1] > https://scan4.coverity.com/reports.htm#v26325/p10075/fileInstanceId=100181086&defectInstanceId=14238477&mergedDefectId=367480 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-09 14:56 ` Aaron Conole @ 2021-04-14 2:46 ` Zhang, Tianfei 2021-04-14 7:42 ` Ferruh Yigit 2021-05-17 8:50 ` Ferruh Yigit 0 siblings, 2 replies; 13+ messages in thread From: Zhang, Tianfei @ 2021-04-14 2:46 UTC (permalink / raw) To: Aaron Conole, Yigit, Ferruh Cc: David Marchand, stable, Huang, Wei, Zhang, Qi Z, Xu, Rosen, dev, Mcnamara, John > -----Original Message----- > From: Aaron Conole <aconole@redhat.com> > Sent: 2021年4月9日 22:56 > To: Yigit, Ferruh <ferruh.yigit@intel.com> > Cc: David Marchand <david.marchand@redhat.com>; stable@dpdk.org; > Zhang, Tianfei <tianfei.zhang@intel.com>; Huang, Wei > <wei.huang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Xu, Rosen > <rosen.xu@intel.com>; dev@dpdk.org; Mcnamara, John > <john.mcnamara@intel.com> > Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before assigning > > Ferruh Yigit <ferruh.yigit@intel.com> writes: > > > On 4/8/2021 9:51 AM, Wei Huang wrote: > >> In max10_staging_area_init(), variable "size" from fdt_get_reg() may > >> be invalid, it should be checked before assigning to member variable > >> "staging_area_size" of structure "intel_max10_device". > >> > >> Coverity issue: 367480, 367482 > >> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device > >> driver") > >> > >> Signed-off-by: Wei Huang <wei.huang@intel.com> > >> --- > >> v2: check size before assigning to staging_area_size > >> --- > >> drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- > >> drivers/raw/ifpga/base/opae_intel_max10.h | 1 + > >> 2 files changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c > >> b/drivers/raw/ifpga/base/opae_intel_max10.c > >> index 443e248fb3..c223fafa03 100644 > >> --- a/drivers/raw/ifpga/base/opae_intel_max10.c > >> +++ b/drivers/raw/ifpga/base/opae_intel_max10.c > >> @@ -593,7 +593,7 @@ static int max10_staging_area_init(struct > intel_max10_device *dev) > >> continue; > >> ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); > >> - if (!ret) { > >> + if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { > >> dev->staging_area_base = start; > >> dev->staging_area_size = size; > >> } > >> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h > >> b/drivers/raw/ifpga/base/opae_intel_max10.h > >> index 670683f017..e7142d6f0d 100644 > >> --- a/drivers/raw/ifpga/base/opae_intel_max10.h > >> +++ b/drivers/raw/ifpga/base/opae_intel_max10.h > >> @@ -182,6 +182,7 @@ struct opae_retimer_status { > >> #define SBUS_VERSION GENMASK(31, 16) > >> #define DFT_MAX_SIZE 0x7e0000 > >> +#define MAX_STAGING_AREA_SIZE 0x3800000 > >> int max10_reg_read(struct intel_max10_device *dev, > >> unsigned int reg, unsigned int *val); > >> > > > > Hi Aaron, David, > > > > The data flow is complex for this coverity issues [1], at least I > > can't confirm that change fixes the issue. > > > > Are you aware of any way to confirm this coverity issue before merging it? > > Not generically. :-/ > > We need someone that understands the data flow and the coverity splat to > know that the fix is correct. Coverity even ratelimits how many outstanding > submissions we can post, iirc, so we don't get to push patch sets (unless we > pay? I don't recall if there's an option for that). This fix is looks good for me. The fdt_get_reg() function just read out the content of some items from DTS file, We call the libfdt library API to do this. The Coverity just assume some attacker broken the DTS file or invoke the function with arbitrary values, it is not safety, So this patch add some checking after the function return. > > > [1] > > https://scan4.coverity.com/reports.htm#v26325/p10075/fileInstanceId=10 > > 0181086&defectInstanceId=14238477&mergedDefectId=367480 ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-14 2:46 ` Zhang, Tianfei @ 2021-04-14 7:42 ` Ferruh Yigit 2021-04-16 2:49 ` Huang, Wei 2021-05-17 8:50 ` Ferruh Yigit 1 sibling, 1 reply; 13+ messages in thread From: Ferruh Yigit @ 2021-04-14 7:42 UTC (permalink / raw) To: Zhang, Tianfei, Aaron Conole Cc: David Marchand, stable, Huang, Wei, Zhang, Qi Z, Xu, Rosen, dev, Mcnamara, John On 4/14/2021 3:46 AM, Zhang, Tianfei wrote: > > >> -----Original Message----- >> From: Aaron Conole <aconole@redhat.com> >> Sent: 2021年4月9日 22:56 >> To: Yigit, Ferruh <ferruh.yigit@intel.com> >> Cc: David Marchand <david.marchand@redhat.com>; stable@dpdk.org; >> Zhang, Tianfei <tianfei.zhang@intel.com>; Huang, Wei >> <wei.huang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Xu, Rosen >> <rosen.xu@intel.com>; dev@dpdk.org; Mcnamara, John >> <john.mcnamara@intel.com> >> Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before assigning >> >> Ferruh Yigit <ferruh.yigit@intel.com> writes: >> >>> On 4/8/2021 9:51 AM, Wei Huang wrote: >>>> In max10_staging_area_init(), variable "size" from fdt_get_reg() may >>>> be invalid, it should be checked before assigning to member variable >>>> "staging_area_size" of structure "intel_max10_device". >>>> >>>> Coverity issue: 367480, 367482 >>>> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device >>>> driver") >>>> >>>> Signed-off-by: Wei Huang <wei.huang@intel.com> >>>> --- >>>> v2: check size before assigning to staging_area_size >>>> --- >>>> drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- >>>> drivers/raw/ifpga/base/opae_intel_max10.h | 1 + >>>> 2 files changed, 2 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c >>>> b/drivers/raw/ifpga/base/opae_intel_max10.c >>>> index 443e248fb3..c223fafa03 100644 >>>> --- a/drivers/raw/ifpga/base/opae_intel_max10.c >>>> +++ b/drivers/raw/ifpga/base/opae_intel_max10.c >>>> @@ -593,7 +593,7 @@ static int max10_staging_area_init(struct >> intel_max10_device *dev) >>>> continue; >>>> ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); >>>> -if (!ret) { >>>> +if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { >>>> dev->staging_area_base = start; >>>> dev->staging_area_size = size; >>>> } >>>> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h >>>> b/drivers/raw/ifpga/base/opae_intel_max10.h >>>> index 670683f017..e7142d6f0d 100644 >>>> --- a/drivers/raw/ifpga/base/opae_intel_max10.h >>>> +++ b/drivers/raw/ifpga/base/opae_intel_max10.h >>>> @@ -182,6 +182,7 @@ struct opae_retimer_status { >>>> #define SBUS_VERSIONGENMASK(31, 16) >>>> #define DFT_MAX_SIZE0x7e0000 >>>> +#define MAX_STAGING_AREA_SIZE0x3800000 >>>> int max10_reg_read(struct intel_max10_device *dev, >>>> unsigned int reg, unsigned int *val); >>>> >>> >>> Hi Aaron, David, >>> >>> The data flow is complex for this coverity issues [1], at least I >>> can't confirm that change fixes the issue. >>> >>> Are you aware of any way to confirm this coverity issue before merging it? >> >> Not generically. :-/ >> >> We need someone that understands the data flow and the coverity splat to >> know that the fix is correct. Coverity even ratelimits how many outstanding >> submissions we can post, iirc, so we don't get to push patch sets (unless we >> pay? I don't recall if there's an option for that). > > This fix is looks good for me. The fdt_get_reg() function just read out the content of some items from DTS file, > We call the libfdt library API to do this. > The Coverity just assume some attacker broken the DTS file or invoke the function with arbitrary values, it is not safety, > So this patch add some checking after the function return. > Hi Tianfei, From the CI capacity perspective, it would be better to have a way to verify Coverity fixes before merging them. For most of the Coverity fixes we can tell that patch is fixing issue by review, but for the non trivial cases like this, a way to verify patch, even it is manual etc.., would be nice, otherwise it turns out to try and see Coverity fixes. And as far as I remember we had in the past that a Coverity fix result two more new Coverity issues :) >> >>> [1] >>> https://scan4.coverity.com/reports.htm#v26325/p10075/fileInstanceId=10 >>> 0181086&defectInstanceId=14238477&mergedDefectId=367480 > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-14 7:42 ` Ferruh Yigit @ 2021-04-16 2:49 ` Huang, Wei 0 siblings, 0 replies; 13+ messages in thread From: Huang, Wei @ 2021-04-16 2:49 UTC (permalink / raw) To: Yigit, Ferruh, Zhang, Tianfei, Aaron Conole Cc: David Marchand, stable, Zhang, Qi Z, Xu, Rosen, dev, Mcnamara, John Hi Ferruh, We have no way to run Coverity scan manually, if you or someone else know how to do it, please let us know. Thanks, Wei -----Original Message----- From: Ferruh Yigit <ferruh.yigit@intel.com> Sent: Wednesday, April 14, 2021 15:42 To: Zhang, Tianfei <tianfei.zhang@intel.com>; Aaron Conole <aconole@redhat.com> Cc: David Marchand <david.marchand@redhat.com>; stable@dpdk.org; Huang, Wei <wei.huang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Xu, Rosen <rosen.xu@intel.com>; dev@dpdk.org; Mcnamara, John <john.mcnamara@intel.com> Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before assigning On 4/14/2021 3:46 AM, Zhang, Tianfei wrote: > > >> -----Original Message----- >> From: Aaron Conole <aconole@redhat.com> >> Sent: 2021年4月9日 22:56 >> To: Yigit, Ferruh <ferruh.yigit@intel.com> >> Cc: David Marchand <david.marchand@redhat.com>; stable@dpdk.org; >> Zhang, Tianfei <tianfei.zhang@intel.com>; Huang, Wei >> <wei.huang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Xu, Rosen >> <rosen.xu@intel.com>; dev@dpdk.org; Mcnamara, John >> <john.mcnamara@intel.com> >> Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before >> assigning >> >> Ferruh Yigit <ferruh.yigit@intel.com> writes: >> >>> On 4/8/2021 9:51 AM, Wei Huang wrote: >>>> In max10_staging_area_init(), variable "size" from fdt_get_reg() >>>> may be invalid, it should be checked before assigning to member >>>> variable "staging_area_size" of structure "intel_max10_device". >>>> >>>> Coverity issue: 367480, 367482 >>>> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device >>>> driver") >>>> >>>> Signed-off-by: Wei Huang <wei.huang@intel.com> >>>> --- >>>> v2: check size before assigning to staging_area_size >>>> --- >>>> drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- >>>> drivers/raw/ifpga/base/opae_intel_max10.h | 1 + >>>> 2 files changed, 2 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c >>>> b/drivers/raw/ifpga/base/opae_intel_max10.c >>>> index 443e248fb3..c223fafa03 100644 >>>> --- a/drivers/raw/ifpga/base/opae_intel_max10.c >>>> +++ b/drivers/raw/ifpga/base/opae_intel_max10.c >>>> @@ -593,7 +593,7 @@ static int max10_staging_area_init(struct >> intel_max10_device *dev) >>>> continue; >>>> ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); -if >>>> (!ret) { >>>> +if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { >>>> dev->staging_area_base = start; >>>> dev->staging_area_size = size; >>>> } >>>> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h >>>> b/drivers/raw/ifpga/base/opae_intel_max10.h >>>> index 670683f017..e7142d6f0d 100644 >>>> --- a/drivers/raw/ifpga/base/opae_intel_max10.h >>>> +++ b/drivers/raw/ifpga/base/opae_intel_max10.h >>>> @@ -182,6 +182,7 @@ struct opae_retimer_status { >>>> #define SBUS_VERSIONGENMASK(31, 16) >>>> #define DFT_MAX_SIZE0x7e0000 >>>> +#define MAX_STAGING_AREA_SIZE0x3800000 >>>> int max10_reg_read(struct intel_max10_device *dev, >>>> unsigned int reg, unsigned int *val); >>>> >>> >>> Hi Aaron, David, >>> >>> The data flow is complex for this coverity issues [1], at least I >>> can't confirm that change fixes the issue. >>> >>> Are you aware of any way to confirm this coverity issue before merging it? >> >> Not generically. :-/ >> >> We need someone that understands the data flow and the coverity splat >> to know that the fix is correct. Coverity even ratelimits how many >> outstanding submissions we can post, iirc, so we don't get to push >> patch sets (unless we pay? I don't recall if there's an option for that). > > This fix is looks good for me. The fdt_get_reg() function just read > out the content of some items from DTS file, We call the libfdt library API to do this. > The Coverity just assume some attacker broken the DTS file or invoke > the function with arbitrary values, it is not safety, So this patch add some checking after the function return. > Hi Tianfei, From the CI capacity perspective, it would be better to have a way to verify Coverity fixes before merging them. For most of the Coverity fixes we can tell that patch is fixing issue by review, but for the non trivial cases like this, a way to verify patch, even it is manual etc.., would be nice, otherwise it turns out to try and see Coverity fixes. And as far as I remember we had in the past that a Coverity fix result two more new Coverity issues :) >> >>> [1] >>> https://scan4.coverity.com/reports.htm#v26325/p10075/fileInstanceId= >>> 10 >>> 0181086&defectInstanceId=14238477&mergedDefectId=367480 > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-14 2:46 ` Zhang, Tianfei 2021-04-14 7:42 ` Ferruh Yigit @ 2021-05-17 8:50 ` Ferruh Yigit 1 sibling, 0 replies; 13+ messages in thread From: Ferruh Yigit @ 2021-05-17 8:50 UTC (permalink / raw) To: Zhang, Tianfei, Huang, Wei, Xu, Rosen Cc: David Marchand, stable, Zhang, Qi Z, dev, Mcnamara, John, Aaron Conole On 4/14/2021 3:46 AM, Zhang, Tianfei wrote: > > >> -----Original Message----- >> From: Aaron Conole <aconole@redhat.com> >> Sent: 2021年4月9日 22:56 >> To: Yigit, Ferruh <ferruh.yigit@intel.com> >> Cc: David Marchand <david.marchand@redhat.com>; stable@dpdk.org; >> Zhang, Tianfei <tianfei.zhang@intel.com>; Huang, Wei >> <wei.huang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Xu, Rosen >> <rosen.xu@intel.com>; dev@dpdk.org; Mcnamara, John >> <john.mcnamara@intel.com> >> Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before assigning >> >> Ferruh Yigit <ferruh.yigit@intel.com> writes: >> >>> On 4/8/2021 9:51 AM, Wei Huang wrote: >>>> In max10_staging_area_init(), variable "size" from fdt_get_reg() may >>>> be invalid, it should be checked before assigning to member variable >>>> "staging_area_size" of structure "intel_max10_device". >>>> >>>> Coverity issue: 367480, 367482 >>>> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device >>>> driver") >>>> >>>> Signed-off-by: Wei Huang <wei.huang@intel.com> >>>> --- >>>> v2: check size before assigning to staging_area_size >>>> --- >>>> drivers/raw/ifpga/base/opae_intel_max10.c | 2 +- >>>> drivers/raw/ifpga/base/opae_intel_max10.h | 1 + >>>> 2 files changed, 2 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.c >>>> b/drivers/raw/ifpga/base/opae_intel_max10.c >>>> index 443e248fb3..c223fafa03 100644 >>>> --- a/drivers/raw/ifpga/base/opae_intel_max10.c >>>> +++ b/drivers/raw/ifpga/base/opae_intel_max10.c >>>> @@ -593,7 +593,7 @@ static int max10_staging_area_init(struct >> intel_max10_device *dev) >>>> continue; >>>> ret = fdt_get_reg(fdt_root, offset, 0, &start, &size); >>>> -if (!ret) { >>>> +if (!ret && (size <= MAX_STAGING_AREA_SIZE)) { >>>> dev->staging_area_base = start; >>>> dev->staging_area_size = size; >>>> } >>>> diff --git a/drivers/raw/ifpga/base/opae_intel_max10.h >>>> b/drivers/raw/ifpga/base/opae_intel_max10.h >>>> index 670683f017..e7142d6f0d 100644 >>>> --- a/drivers/raw/ifpga/base/opae_intel_max10.h >>>> +++ b/drivers/raw/ifpga/base/opae_intel_max10.h >>>> @@ -182,6 +182,7 @@ struct opae_retimer_status { >>>> #define SBUS_VERSIONGENMASK(31, 16) >>>> #define DFT_MAX_SIZE0x7e0000 >>>> +#define MAX_STAGING_AREA_SIZE0x3800000 >>>> int max10_reg_read(struct intel_max10_device *dev, >>>> unsigned int reg, unsigned int *val); >>>> >>> >>> Hi Aaron, David, >>> >>> The data flow is complex for this coverity issues [1], at least I >>> can't confirm that change fixes the issue. >>> >>> Are you aware of any way to confirm this coverity issue before merging it? >> >> Not generically. :-/ >> >> We need someone that understands the data flow and the coverity splat to >> know that the fix is correct. Coverity even ratelimits how many outstanding >> submissions we can post, iirc, so we don't get to push patch sets (unless we >> pay? I don't recall if there's an option for that). > > This fix is looks good for me. The fdt_get_reg() function just read out the content of some items from DTS file, > We call the libfdt library API to do this. > The Coverity just assume some attacker broken the DTS file or invoke the function with arbitrary values, it is not safety, > So this patch add some checking after the function return. > Hi Tianfei, Wei, Rosen, The defect is reported in Coverity, as concerned, can you please look at it? >> >>> [1] >>> https://scan4.coverity.com/reports.htm#v26325/p10075/fileInstanceId=10 >>> 0181086&defectInstanceId=14238477&mergedDefectId=367480 > ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-08 8:51 ` [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning Wei Huang 2021-04-08 9:38 ` Ferruh Yigit @ 2021-04-19 8:12 ` Zhang, Qi Z 2021-04-19 22:35 ` Ferruh Yigit 1 sibling, 1 reply; 13+ messages in thread From: Zhang, Qi Z @ 2021-04-19 8:12 UTC (permalink / raw) To: Huang, Wei, dev, Xu, Rosen; +Cc: stable, Zhang, Tianfei, Yigit, Ferruh > -----Original Message----- > From: Huang, Wei <wei.huang@intel.com> > Sent: Thursday, April 8, 2021 4:52 PM > To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z > <qi.z.zhang@intel.com> > Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Yigit, Ferruh > <ferruh.yigit@intel.com>; Huang, Wei <wei.huang@intel.com> > Subject: [PATCH v2 1/1] raw/ifpga/base: check size before assigning > > In max10_staging_area_init(), variable "size" from fdt_get_reg() may be invalid, > it should be checked before assigning to member variable "staging_area_size" > of structure "intel_max10_device". > > Coverity issue: 367480, 367482 > Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device driver") > > Signed-off-by: Wei Huang <wei.huang@intel.com> > --- Applied to dpdk-next-net-intel. Thanks Qi ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-19 8:12 ` Zhang, Qi Z @ 2021-04-19 22:35 ` Ferruh Yigit 2021-04-20 0:13 ` Zhang, Tianfei 0 siblings, 1 reply; 13+ messages in thread From: Ferruh Yigit @ 2021-04-19 22:35 UTC (permalink / raw) To: Zhang, Qi Z, Huang, Wei, dev, Xu, Rosen; +Cc: stable, Zhang, Tianfei On 4/19/2021 9:12 AM, Zhang, Qi Z wrote: > > >> -----Original Message----- >> From: Huang, Wei <wei.huang@intel.com> >> Sent: Thursday, April 8, 2021 4:52 PM >> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z >> <qi.z.zhang@intel.com> >> Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Yigit, Ferruh >> <ferruh.yigit@intel.com>; Huang, Wei <wei.huang@intel.com> >> Subject: [PATCH v2 1/1] raw/ifpga/base: check size before assigning >> >> In max10_staging_area_init(), variable "size" from fdt_get_reg() may be invalid, >> it should be checked before assigning to member variable "staging_area_size" >> of structure "intel_max10_device". >> >> Coverity issue: 367480, 367482 >> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device driver") >> >> Signed-off-by: Wei Huang <wei.huang@intel.com> >> --- > > Applied to dpdk-next-net-intel. > This patch is missing the maintainer ack. Rosen, Tianfei, can you please review the patch? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-19 22:35 ` Ferruh Yigit @ 2021-04-20 0:13 ` Zhang, Tianfei 2021-04-20 1:00 ` Ferruh Yigit 0 siblings, 1 reply; 13+ messages in thread From: Zhang, Tianfei @ 2021-04-20 0:13 UTC (permalink / raw) To: Yigit, Ferruh, Zhang, Qi Z, Huang, Wei, dev, Xu, Rosen; +Cc: stable > -----Original Message----- > From: Yigit, Ferruh <ferruh.yigit@intel.com> > Sent: 2021年4月20日 6:36 > To: Zhang, Qi Z <qi.z.zhang@intel.com>; Huang, Wei <wei.huang@intel.com>; > dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com> > Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com> > Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before assigning > > On 4/19/2021 9:12 AM, Zhang, Qi Z wrote: > > > > > >> -----Original Message----- > >> From: Huang, Wei <wei.huang@intel.com> > >> Sent: Thursday, April 8, 2021 4:52 PM > >> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z > >> <qi.z.zhang@intel.com> > >> Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Yigit, > >> Ferruh <ferruh.yigit@intel.com>; Huang, Wei <wei.huang@intel.com> > >> Subject: [PATCH v2 1/1] raw/ifpga/base: check size before assigning > >> > >> In max10_staging_area_init(), variable "size" from fdt_get_reg() may > >> be invalid, it should be checked before assigning to member variable > "staging_area_size" > >> of structure "intel_max10_device". > >> > >> Coverity issue: 367480, 367482 > >> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device > >> driver") > >> > >> Signed-off-by: Wei Huang <wei.huang@intel.com> > >> --- > > > > Applied to dpdk-next-net-intel. > > > > This patch is missing the maintainer ack. > > Rosen, Tianfei, can you please review the patch? It looks good for me. Acked-by: Tianfei zhang <Tianfei.zhang@intel.com> ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-20 0:13 ` Zhang, Tianfei @ 2021-04-20 1:00 ` Ferruh Yigit 2021-04-20 1:59 ` Xu, Rosen 0 siblings, 1 reply; 13+ messages in thread From: Ferruh Yigit @ 2021-04-20 1:00 UTC (permalink / raw) To: Zhang, Tianfei, Zhang, Qi Z, Huang, Wei, dev, Xu, Rosen; +Cc: stable On 4/20/2021 1:13 AM, Zhang, Tianfei wrote: > > >> -----Original Message----- >> From: Yigit, Ferruh <ferruh.yigit@intel.com> >> Sent: 2021年4月20日 6:36 >> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Huang, Wei <wei.huang@intel.com>; >> dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com> >> Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com> >> Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before assigning >> >> On 4/19/2021 9:12 AM, Zhang, Qi Z wrote: >>> >>> >>>> -----Original Message----- >>>> From: Huang, Wei <wei.huang@intel.com> >>>> Sent: Thursday, April 8, 2021 4:52 PM >>>> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z >>>> <qi.z.zhang@intel.com> >>>> Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Yigit, >>>> Ferruh <ferruh.yigit@intel.com>; Huang, Wei <wei.huang@intel.com> >>>> Subject: [PATCH v2 1/1] raw/ifpga/base: check size before assigning >>>> >>>> In max10_staging_area_init(), variable "size" from fdt_get_reg() may >>>> be invalid, it should be checked before assigning to member variable >> "staging_area_size" >>>> of structure "intel_max10_device". >>>> >>>> Coverity issue: 367480, 367482 >>>> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device >>>> driver") >>>> >>>> Signed-off-by: Wei Huang <wei.huang@intel.com> >>>> --- >>> >>> Applied to dpdk-next-net-intel. >>> >> >> This patch is missing the maintainer ack. >> >> Rosen, Tianfei, can you please review the patch? > > It looks good for me. > > Acked-by: Tianfei zhang <Tianfei.zhang@intel.com> > Thanks, added in next-net. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning 2021-04-20 1:00 ` Ferruh Yigit @ 2021-04-20 1:59 ` Xu, Rosen 0 siblings, 0 replies; 13+ messages in thread From: Xu, Rosen @ 2021-04-20 1:59 UTC (permalink / raw) To: Yigit, Ferruh, Zhang, Tianfei, Zhang, Qi Z, Huang, Wei, dev; +Cc: stable Thanks all. -----Original Message----- From: Yigit, Ferruh <ferruh.yigit@intel.com> Sent: Tuesday, April 20, 2021 9:01 AM To: Zhang, Tianfei <tianfei.zhang@intel.com>; Zhang, Qi Z <qi.z.zhang@intel.com>; Huang, Wei <wei.huang@intel.com>; dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com> Cc: stable@dpdk.org Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before assigning On 4/20/2021 1:13 AM, Zhang, Tianfei wrote: > > >> -----Original Message----- >> From: Yigit, Ferruh <ferruh.yigit@intel.com> >> Sent: 2021年4月20日 6:36 >> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Huang, Wei >> <wei.huang@intel.com>; dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com> >> Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com> >> Subject: Re: [PATCH v2 1/1] raw/ifpga/base: check size before >> assigning >> >> On 4/19/2021 9:12 AM, Zhang, Qi Z wrote: >>> >>> >>>> -----Original Message----- >>>> From: Huang, Wei <wei.huang@intel.com> >>>> Sent: Thursday, April 8, 2021 4:52 PM >>>> To: dev@dpdk.org; Xu, Rosen <rosen.xu@intel.com>; Zhang, Qi Z >>>> <qi.z.zhang@intel.com> >>>> Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; >>>> Yigit, Ferruh <ferruh.yigit@intel.com>; Huang, Wei >>>> <wei.huang@intel.com> >>>> Subject: [PATCH v2 1/1] raw/ifpga/base: check size before assigning >>>> >>>> In max10_staging_area_init(), variable "size" from fdt_get_reg() >>>> may be invalid, it should be checked before assigning to member >>>> variable >> "staging_area_size" >>>> of structure "intel_max10_device". >>>> >>>> Coverity issue: 367480, 367482 >>>> Fixes: 96ebfcf8125c ("raw/ifpga/base: add SPI and MAX10 device >>>> driver") >>>> >>>> Signed-off-by: Wei Huang <wei.huang@intel.com> >>>> --- >>> >>> Applied to dpdk-next-net-intel. >>> >> >> This patch is missing the maintainer ack. >> >> Rosen, Tianfei, can you please review the patch? > > It looks good for me. > > Acked-by: Tianfei zhang <Tianfei.zhang@intel.com> > Thanks, added in next-net. ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-05-17 8:50 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-08 8:51 [dpdk-dev] [PATCH v2 0/1] Fix coverity issues reported in DPDK-26381 Wei Huang 2021-04-08 8:51 ` [dpdk-dev] [PATCH v2 1/1] raw/ifpga/base: check size before assigning Wei Huang 2021-04-08 9:38 ` Ferruh Yigit 2021-04-09 14:56 ` Aaron Conole 2021-04-14 2:46 ` Zhang, Tianfei 2021-04-14 7:42 ` Ferruh Yigit 2021-04-16 2:49 ` Huang, Wei 2021-05-17 8:50 ` Ferruh Yigit 2021-04-19 8:12 ` Zhang, Qi Z 2021-04-19 22:35 ` Ferruh Yigit 2021-04-20 0:13 ` Zhang, Tianfei 2021-04-20 1:00 ` Ferruh Yigit 2021-04-20 1:59 ` Xu, Rosen
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).