[PATCH 24.11] cryptodev: fix undefined shift in hash capability check

Daniil Iskhakov dish at amicon.ru
Mon Apr 27 18:25:28 CEST 2026


rte_cryptodev_asym_xform_capability_check_hash() builds a bitmask with
`1 << hash` to test capability->hash_algos.

Since `1` is a 32-bit integer, shifting it by 32 bits is undefined
behavior. This is also inconsistent with capability->hash_algos, which
is a 64-bit mask.

Use RTE_BIT64(hash) to build the mask with the proper width.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 6f8ef8b68edb ("cryptodev: add hash algorithms in asymmetric capability")

Signed-off-by: Daniil Agalakov <ade at amicon.ru>
Signed-off-by: Daniil Iskhakov <dish at amicon.ru>
---
Cc: gmuthukrishn at marvell.com
Cc: sdl.dpdk at linuxtesting.org
Cc: rrv at amicon.ru
---
 lib/cryptodev/rte_cryptodev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 4fa32c2d08..fad590f073 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -620,7 +620,7 @@ rte_cryptodev_asym_xform_capability_check_hash(
 {
 	bool ret = false;
 
-	if (capability->hash_algos & (1 << hash))
+	if (capability->hash_algos & RTE_BIT64(hash))
 		ret = true;
 
 	rte_cryptodev_trace_asym_xform_capability_check_hash(
-- 
2.43.0



More information about the stable mailing list