[v1] common/cnxk: fix integer overflow
Checks
Commit Message
The expression flow_age->aging_poll_freq * NPC_AGE_WAIT_TIMEOUT_US is
evaluated using 32 bit arithmetic. An integer overflow may occur when
the value is too large to fit in 32 bits. This patch resolves this by
casting flow_age->aging_poll_freq to 64 bit.
Coverity issue: 428156
Fixes: a4878294318e ("common/cnxk: fix flow aging on application exit")
Cc: stable@dpdk.org
Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
---
drivers/common/cnxk/roc_npc_aging.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Jul 18, 2024 at 12:13 PM Ankur Dwivedi <adwivedi@marvell.com> wrote:
>
> The expression flow_age->aging_poll_freq * NPC_AGE_WAIT_TIMEOUT_US is
> evaluated using 32 bit arithmetic. An integer overflow may occur when
> the value is too large to fit in 32 bits. This patch resolves this by
> casting flow_age->aging_poll_freq to 64 bit.
>
> Coverity issue: 428156
> Fixes: a4878294318e ("common/cnxk: fix flow aging on application exit")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Applied to dpdk-next-net-mrvl/for-main. Thanks
> ---
> drivers/common/cnxk/roc_npc_aging.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/common/cnxk/roc_npc_aging.c b/drivers/common/cnxk/roc_npc_aging.c
> index 1e85033e2a..258c15e341 100644
> --- a/drivers/common/cnxk/roc_npc_aging.c
> +++ b/drivers/common/cnxk/roc_npc_aging.c
> @@ -145,7 +145,7 @@ npc_age_wait_until(struct roc_npc_flow_age *flow_age)
> plt_delay_us(sleep);
> timeout += sleep;
> } while (!flow_age->aged_flows_get_thread_exit &&
> - (timeout < (flow_age->aging_poll_freq * NPC_AGE_WAIT_TIMEOUT_US)));
> + (timeout < ((uint64_t)flow_age->aging_poll_freq * NPC_AGE_WAIT_TIMEOUT_US)));
> }
>
> uint32_t
> --
> 2.25.1
>
@@ -145,7 +145,7 @@ npc_age_wait_until(struct roc_npc_flow_age *flow_age)
plt_delay_us(sleep);
timeout += sleep;
} while (!flow_age->aged_flows_get_thread_exit &&
- (timeout < (flow_age->aging_poll_freq * NPC_AGE_WAIT_TIMEOUT_US)));
+ (timeout < ((uint64_t)flow_age->aging_poll_freq * NPC_AGE_WAIT_TIMEOUT_US)));
}
uint32_t