[PATCH] bitops: fix integer overflow in align64pow2

Jack Bond-Preston jack.bond-preston at foss.arm.com
Fri Nov 13 17:32:50 CET 2026


On 13/11/2026 14:13, Bulatov Mark wrote:
> If the function rte_combine64ms1b() returns the maximum possible uint64_t
> value, it will result in an overflow.
> 
> To avoid this, add a check.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 7253e3d2a5 ("bitops: move bit count functions")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Alexey Simakov <bigalex934 at gmail.com>
> Signed-off-by: Mark Bulatov <ms.bulatov7 at gmail.com>
> ---
>   lib/eal/include/rte_bitops.h | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h
> index 45255b68aa..d2ed0c3c61 100644
> --- a/lib/eal/include/rte_bitops.h
> +++ b/lib/eal/include/rte_bitops.h
> @@ -1307,6 +1307,9 @@ rte_align64pow2(uint64_t v)
>   	v--;
>   	v = rte_combine64ms1b(v);
>   
> +	if (v == UINT64_MAX)
> +		v--;
> +
>   	return v + 1;
>   }
>   

Reviewed-by: Jack Bond-Preston <jack.bond-preston at foss.arm.com>



More information about the dev mailing list