[PATCH v2] net/i40e: fix unintentional integer overflow

Ferruh Yigit ferruh.yigit at intel.com
Thu Feb 24 12:42:19 CET 2022


On 2/24/2022 6:21 AM, Yang, SteveX wrote:
> 
> 
>> -----Original Message-----
>> From: Stephen Hemminger <stephen at networkplumber.org>
>> Sent: Thursday, February 24, 2022 12:11 PM
>> To: Yang, SteveX <stevex.yang at intel.com>
>> Cc: dev at dpdk.org; Yigit, Ferruh <ferruh.yigit at intel.com>; Xing, Beilei
>> <beilei.xing at intel.com>; stable at 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 at 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 at dpdk.org
>>>
>>> ---
>>> v2: update commit message.
>>>
>>> Signed-off-by: Steve Yang <stevex.yang at 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.


More information about the stable mailing list