[lvc-project] [PATCH] RDMA/i40iw: Fix 32-bit overflow in i40iw_check_mem_contiguous()

Ivan Stepchenko sid at itb.spb.ru
Wed Aug 20 14:28:28 MSK 2025


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")
Signed-off-by: Ivan Stepchenko <sid at itb.spb.ru>
---
 drivers/infiniband/hw/irdma/verbs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c
index da5a41b275d8..33831cd3ce1f 100644
--- a/drivers/infiniband/hw/irdma/verbs.c
+++ b/drivers/infiniband/hw/irdma/verbs.c
@@ -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;
 	}
 
-- 
2.39.5




More information about the lvc-project mailing list