Skip to contentSkip to conversation

RDMA/i40iw: Fix 32-bit overflow in i40iw_check_mem_contiguous()

PATCH New Ivan Stepchenko 1 participant 1 message Aug 20, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/i40iw: Fix 32-bit overflow in i40iw_check_mem_contiguous()

pg_size and pg_idx are u32, so pg_size * pg_idx is computed in 32-bit and wraps once the total offset reaches 4 GiB (e.g. 2 MiB pages at pg_idx == 2048). The wrapped offset is then widened to u64, producing a false negative: contiguous PBL entries are incorrectly reported as non-contiguous.

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

Fixes b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs")
---
 drivers/infiniband/hw/irdma/verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/irdma/verbs.c +1 -1
index da5a41b275d8..33831cd3ce1f 100644
@@ -2366,7 +2366,7 @@ static bool irdma_check_mem_contiguous(u64 *arr, u32 npages, u32 pg_size)
 	u32 pg_idx;
 
 	for (pg_idx = 0; pg_idx < npages; pg_idx++) {
-		if ((*arr + (pg_size * pg_idx)) != arr[pg_idx])
+		if ((*arr + ((u64)pg_size * pg_idx)) != arr[pg_idx])
 			return false;
 	}
 
Signature · 1 line
2.39.5