> 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: [email protected]
>
> Signed-off-by: Alexey Simakov <[email protected]>
> Signed-off-by: Mark Bulatov <[email protected]>
> ---
> 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;
> }
NAK.
The overflow bug is present, also in rte_align32pow2().
But the fix is wrong; it does not return a power-of-two value.
There is no solution to fix this overflow.
The only possible fix is to specify in the function documentation that the
parameter must not exceed 1 << 63 (0x8000000000000000).
-Morten