* [PATCH v1] net/i40e: fix coverity issue @ 2022-02-23 6:41 Steve Yang 2022-02-23 10:28 ` Ferruh Yigit 2022-02-24 1:17 ` [PATCH v2] net/i40e: fix unintentional integer overflow Steve Yang 0 siblings, 2 replies; 9+ messages in thread From: Steve Yang @ 2022-02-23 6:41 UTC (permalink / raw) To: dev; +Cc: beilei.xing, Steve Yang Cast 1 to type uint64_t to avoid overflow. CID 375812 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression 1 << 2 * i + 1 with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64_t (64 bits, unsigned). Coverity issue: 375812 Fixes: 5fec01c35c49 ("net/i40e: support Linux VF to configure IRQ link list") Signed-off-by: Steve Yang <stevex.yang@intel.com> --- drivers/net/i40e/i40e_pf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index 2435a8a070..39e0c021a4 100644 --- a/drivers/net/i40e/i40e_pf.c +++ b/drivers/net/i40e/i40e_pf.c @@ -604,7 +604,7 @@ i40e_pf_config_irq_link_list(struct i40e_pf_vf *vf, tempmap = vvm->txq_map; for (i = 0; i < sizeof(vvm->txq_map) * BITS_PER_CHAR; i++) { if (tempmap & 0x1) - linklistmap |= (1 << (2 * i + 1)); + linklistmap |= ((uint64_t)1 << (2 * i + 1)); tempmap >>= 1; } -- 2.27.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1] net/i40e: fix coverity issue 2022-02-23 6:41 [PATCH v1] net/i40e: fix coverity issue Steve Yang @ 2022-02-23 10:28 ` Ferruh Yigit 2022-02-24 1:17 ` [PATCH v2] net/i40e: fix unintentional integer overflow Steve Yang 1 sibling, 0 replies; 9+ messages in thread From: Ferruh Yigit @ 2022-02-23 10:28 UTC (permalink / raw) To: Steve Yang, dev; +Cc: beilei.xing On 2/23/2022 6:41 AM, Steve Yang wrote: > Cast 1 to type uint64_t to avoid overflow. > > CID 375812 (#1 of 1): > Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) > overflow_before_widen: Potentially overflowing expression 1 << 2 * i + 1 > with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and > then used in a context that expects an expression of type uint64_t > (64 bits, unsigned). > > Coverity issue: 375812 > Fixes: 5fec01c35c49 ("net/i40e: support Linux VF to configure IRQ link list") > > Signed-off-by: Steve Yang <stevex.yang@intel.com> Hi Steve, Can you please describe what is actually done in the patch title? Fixing a static tool warning is not descriptive enough. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] net/i40e: fix unintentional integer overflow 2022-02-23 6:41 [PATCH v1] net/i40e: fix coverity issue Steve Yang 2022-02-23 10:28 ` Ferruh Yigit @ 2022-02-24 1:17 ` Steve Yang 2022-02-24 3:25 ` Zhang, Qi Z ` (2 more replies) 1 sibling, 3 replies; 9+ messages in thread From: Steve Yang @ 2022-02-24 1:17 UTC (permalink / raw) To: dev; +Cc: ferruh.yigit, beilei.xing, Steve Yang, stable Cast 1 to type uint64_t to avoid overflow. CID 375812 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression 1 << 2 * i + 1 with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64_t (64 bits, unsigned). Coverity issue: 375812 Fixes: 5fec01c35c49 ("net/i40e: support Linux VF to configure IRQ link list") Cc: stable@dpdk.org --- v2: update commit message. Signed-off-by: Steve Yang <stevex.yang@intel.com> --- drivers/net/i40e/i40e_pf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index 2435a8a070..39e0c021a4 100644 --- a/drivers/net/i40e/i40e_pf.c +++ b/drivers/net/i40e/i40e_pf.c @@ -604,7 +604,7 @@ i40e_pf_config_irq_link_list(struct i40e_pf_vf *vf, tempmap = vvm->txq_map; for (i = 0; i < sizeof(vvm->txq_map) * BITS_PER_CHAR; i++) { if (tempmap & 0x1) - linklistmap |= (1 << (2 * i + 1)); + linklistmap |= ((uint64_t)1 << (2 * i + 1)); tempmap >>= 1; } -- 2.27.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v2] net/i40e: fix unintentional integer overflow 2022-02-24 1:17 ` [PATCH v2] net/i40e: fix unintentional integer overflow Steve Yang @ 2022-02-24 3:25 ` Zhang, Qi Z 2022-02-24 4:10 ` Stephen Hemminger 2022-02-25 2:39 ` [PATCH v3] " Steve Yang 2 siblings, 0 replies; 9+ messages in thread From: Zhang, Qi Z @ 2022-02-24 3:25 UTC (permalink / raw) To: Yang, SteveX, dev; +Cc: Yigit, Ferruh, Xing, Beilei, Yang, SteveX, stable > -----Original Message----- > From: Steve Yang <stevex.yang@intel.com> > Sent: Thursday, February 24, 2022 9:17 AM > To: dev@dpdk.org > Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; Xing, Beilei <beilei.xing@intel.com>; > Yang, SteveX <stevex.yang@intel.com>; stable@dpdk.org > Subject: [PATCH v2] net/i40e: fix unintentional integer overflow > > Cast 1 to type uint64_t to avoid overflow. > > CID 375812 (#1 of 1): > Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) > overflow_before_widen: Potentially overflowing expression 1 << 2 * i + 1 with > type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a > context that expects an expression of type uint64_t > (64 bits, unsigned). > > Coverity issue: 375812 > Fixes: 5fec01c35c49 ("net/i40e: support Linux VF to configure IRQ link list") > Cc: stable@dpdk.org > > --- > v2: update commit message. > > Signed-off-by: Steve Yang <stevex.yang@intel.com> Acked-by: Qi Zhang <qi.z.zhang@intel.com> Applied to dpdk-next-net-intel. Thanks Qi ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] net/i40e: fix unintentional integer overflow 2022-02-24 1:17 ` [PATCH v2] net/i40e: fix unintentional integer overflow Steve Yang 2022-02-24 3:25 ` Zhang, Qi Z @ 2022-02-24 4:10 ` Stephen Hemminger 2022-02-24 6:21 ` Yang, SteveX 2022-02-25 2:39 ` [PATCH v3] " Steve Yang 2 siblings, 1 reply; 9+ messages in thread From: Stephen Hemminger @ 2022-02-24 4:10 UTC (permalink / raw) To: Steve Yang; +Cc: dev, ferruh.yigit, beilei.xing, stable On Thu, 24 Feb 2022 01:17:22 +0000 Steve Yang <stevex.yang@intel.com> wrote: > Cast 1 to type uint64_t to avoid overflow. > > CID 375812 (#1 of 1): > Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) > overflow_before_widen: Potentially overflowing expression 1 << 2 * i + 1 > with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and > then used in a context that expects an expression of type uint64_t > (64 bits, unsigned). > > Coverity issue: 375812 > Fixes: 5fec01c35c49 ("net/i40e: support Linux VF to configure IRQ link list") > Cc: stable@dpdk.org > > --- > v2: update commit message. > > Signed-off-by: Steve Yang <stevex.yang@intel.com> > --- > drivers/net/i40e/i40e_pf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c > index 2435a8a070..39e0c021a4 100644 > --- a/drivers/net/i40e/i40e_pf.c > +++ b/drivers/net/i40e/i40e_pf.c > @@ -604,7 +604,7 @@ i40e_pf_config_irq_link_list(struct i40e_pf_vf *vf, > tempmap = vvm->txq_map; > for (i = 0; i < sizeof(vvm->txq_map) * BITS_PER_CHAR; i++) { > if (tempmap & 0x1) > - linklistmap |= (1 << (2 * i + 1)); > + linklistmap |= ((uint64_t)1 << (2 * i + 1)); Could be RTE_BIT64(2 * i + 1) instead? ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v2] net/i40e: fix unintentional integer overflow 2022-02-24 4:10 ` Stephen Hemminger @ 2022-02-24 6:21 ` Yang, SteveX 2022-02-24 11:42 ` Ferruh Yigit 0 siblings, 1 reply; 9+ messages in thread From: Yang, SteveX @ 2022-02-24 6:21 UTC (permalink / raw) To: Stephen Hemminger; +Cc: dev, Yigit, Ferruh, Xing, Beilei, stable > -----Original Message----- > From: Stephen Hemminger <stephen@networkplumber.org> > Sent: Thursday, February 24, 2022 12:11 PM > To: Yang, SteveX <stevex.yang@intel.com> > Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>; Xing, Beilei > <beilei.xing@intel.com>; stable@dpdk.org > Subject: Re: [PATCH v2] net/i40e: fix unintentional integer overflow > > On Thu, 24 Feb 2022 01:17:22 +0000 > Steve Yang <stevex.yang@intel.com> wrote: > > > Cast 1 to type uint64_t to avoid overflow. > > > > CID 375812 (#1 of 1): > > Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) > > overflow_before_widen: Potentially overflowing expression 1 << 2 * i + > > 1 with type int (32 bits, signed) is evaluated using 32-bit > > arithmetic, and then used in a context that expects an expression of > > type uint64_t > > (64 bits, unsigned). > > > > Coverity issue: 375812 > > Fixes: 5fec01c35c49 ("net/i40e: support Linux VF to configure IRQ link > > list") > > Cc: stable@dpdk.org > > > > --- > > v2: update commit message. > > > > Signed-off-by: Steve Yang <stevex.yang@intel.com> > > --- > > drivers/net/i40e/i40e_pf.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c > > index 2435a8a070..39e0c021a4 100644 > > --- a/drivers/net/i40e/i40e_pf.c > > +++ b/drivers/net/i40e/i40e_pf.c > > @@ -604,7 +604,7 @@ i40e_pf_config_irq_link_list(struct i40e_pf_vf *vf, > > tempmap = vvm->txq_map; > > for (i = 0; i < sizeof(vvm->txq_map) * BITS_PER_CHAR; i++) { > > if (tempmap & 0x1) > > - linklistmap |= (1 << (2 * i + 1)); > > + linklistmap |= ((uint64_t)1 << (2 * i + 1)); > > Could be RTE_BIT64(2 * i + 1) instead? Thanks Stephen, excellent suggestion. Current code exist lots of similar nonstandard bit expression, I think it maybe better to start a new patch series to change them. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] net/i40e: fix unintentional integer overflow 2022-02-24 6:21 ` Yang, SteveX @ 2022-02-24 11:42 ` Ferruh Yigit 0 siblings, 0 replies; 9+ messages in thread From: Ferruh Yigit @ 2022-02-24 11:42 UTC (permalink / raw) To: Yang, SteveX, Stephen Hemminger; +Cc: dev, Xing, Beilei, stable On 2/24/2022 6:21 AM, Yang, SteveX wrote: > > >> -----Original Message----- >> From: Stephen Hemminger <stephen@networkplumber.org> >> Sent: Thursday, February 24, 2022 12:11 PM >> To: Yang, SteveX <stevex.yang@intel.com> >> Cc: dev@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>; Xing, Beilei >> <beilei.xing@intel.com>; stable@dpdk.org >> Subject: Re: [PATCH v2] net/i40e: fix unintentional integer overflow >> >> On Thu, 24 Feb 2022 01:17:22 +0000 >> Steve Yang <stevex.yang@intel.com> wrote: >> >>> Cast 1 to type uint64_t to avoid overflow. >>> >>> CID 375812 (#1 of 1): >>> Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) >>> overflow_before_widen: Potentially overflowing expression 1 << 2 * i + >>> 1 with type int (32 bits, signed) is evaluated using 32-bit >>> arithmetic, and then used in a context that expects an expression of >>> type uint64_t >>> (64 bits, unsigned). >>> >>> Coverity issue: 375812 >>> Fixes: 5fec01c35c49 ("net/i40e: support Linux VF to configure IRQ link >>> list") >>> Cc: stable@dpdk.org >>> >>> --- >>> v2: update commit message. >>> >>> Signed-off-by: Steve Yang <stevex.yang@intel.com> >>> --- >>> drivers/net/i40e/i40e_pf.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c >>> index 2435a8a070..39e0c021a4 100644 >>> --- a/drivers/net/i40e/i40e_pf.c >>> +++ b/drivers/net/i40e/i40e_pf.c >>> @@ -604,7 +604,7 @@ i40e_pf_config_irq_link_list(struct i40e_pf_vf *vf, >>> tempmap = vvm->txq_map; >>> for (i = 0; i < sizeof(vvm->txq_map) * BITS_PER_CHAR; i++) { >>> if (tempmap & 0x1) >>> - linklistmap |= (1 << (2 * i + 1)); >>> + linklistmap |= ((uint64_t)1 << (2 * i + 1)); >> >> Could be RTE_BIT64(2 * i + 1) instead? > > Thanks Stephen, excellent suggestion. > Current code exist lots of similar nonstandard bit expression, > I think it maybe better to start a new patch series to change them. Hi Steve, Why not fix this instance in this patch, it is a simple change? Later a clenaup patch can be optional on its own time, but better to get this fix in this release. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] net/i40e: fix unintentional integer overflow 2022-02-24 1:17 ` [PATCH v2] net/i40e: fix unintentional integer overflow Steve Yang 2022-02-24 3:25 ` Zhang, Qi Z 2022-02-24 4:10 ` Stephen Hemminger @ 2022-02-25 2:39 ` Steve Yang 2022-02-25 14:48 ` Ferruh Yigit 2 siblings, 1 reply; 9+ messages in thread From: Steve Yang @ 2022-02-25 2:39 UTC (permalink / raw) To: dev; +Cc: beilei.xing, stephen, ferruh.yigit, Steve Yang, stable Cast 1 to type uint64_t to avoid overflow. CID 375812 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression 1 << 2 * i + 1 with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64_t (64 bits, unsigned). Coverity issue: 375812 Fixes: 5fec01c35c49 ("net/i40e: support Linux VF to configure IRQ link list") Cc: stable@dpdk.org --- v2: update commit message; v3: use RTE_BIT64() to set bit; Signed-off-by: Steve Yang <stevex.yang@intel.com> --- drivers/net/i40e/i40e_pf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index 2435a8a070..15d9ff868f 100644 --- a/drivers/net/i40e/i40e_pf.c +++ b/drivers/net/i40e/i40e_pf.c @@ -597,14 +597,14 @@ i40e_pf_config_irq_link_list(struct i40e_pf_vf *vf, tempmap = vvm->rxq_map; for (i = 0; i < sizeof(vvm->rxq_map) * BITS_PER_CHAR; i++) { if (tempmap & 0x1) - linklistmap |= (1 << (2 * i)); + linklistmap |= RTE_BIT64(2 * i); tempmap >>= 1; } tempmap = vvm->txq_map; for (i = 0; i < sizeof(vvm->txq_map) * BITS_PER_CHAR; i++) { if (tempmap & 0x1) - linklistmap |= (1 << (2 * i + 1)); + linklistmap |= RTE_BIT64(2 * i + 1); tempmap >>= 1; } -- 2.27.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] net/i40e: fix unintentional integer overflow 2022-02-25 2:39 ` [PATCH v3] " Steve Yang @ 2022-02-25 14:48 ` Ferruh Yigit 0 siblings, 0 replies; 9+ messages in thread From: Ferruh Yigit @ 2022-02-25 14:48 UTC (permalink / raw) To: Steve Yang, dev; +Cc: beilei.xing, stephen, stable On 2/25/2022 2:39 AM, Steve Yang wrote: > Cast 1 to type uint64_t to avoid overflow. > > CID 375812 (#1 of 1): > Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) > overflow_before_widen: Potentially overflowing expression 1 << 2 * i + 1 > with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and > then used in a context that expects an expression of type uint64_t > (64 bits, unsigned). > > Coverity issue: 375812 > Fixes: 5fec01c35c49 ("net/i40e: support Linux VF to configure IRQ link list") > Cc: stable@dpdk.org > > --- > v2: update commit message; > v3: use RTE_BIT64() to set bit; > > Signed-off-by: Steve Yang <stevex.yang@intel.com> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com> Applied to dpdk-next-net/main, thanks. ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-02-25 14:48 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-02-23 6:41 [PATCH v1] net/i40e: fix coverity issue Steve Yang 2022-02-23 10:28 ` Ferruh Yigit 2022-02-24 1:17 ` [PATCH v2] net/i40e: fix unintentional integer overflow Steve Yang 2022-02-24 3:25 ` Zhang, Qi Z 2022-02-24 4:10 ` Stephen Hemminger 2022-02-24 6:21 ` Yang, SteveX 2022-02-24 11:42 ` Ferruh Yigit 2022-02-25 2:39 ` [PATCH v3] " Steve Yang 2022-02-25 14:48 ` Ferruh Yigit
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).