[lvc-project] [PATCH v3] RDMA/hns: Compute HEM index in 64-bit in hns_roce_v2_set_hem()
Alexander.Chesnokov at kaspersky.com
Alexander.Chesnokov at kaspersky.com
Thu Jul 9 08:03:27 MSK 2026
From: Alexander Chesnokov <Alexander.Chesnokov at kaspersky.com>
In hns_roce_v2_set_hem() the HEM address indices are computed from
i, j and k (the base-chunk_ba_num decomposition of the 32-bit
table_idx) in 32-bit arithmetic and then assigned to u64 fields.
The recombined value always equals table_idx and cannot exceed
U32_MAX, so this is not a reachable overflow and has no user-visible
impact. Declare i, j and k as u64 so the calculation is done in
64-bit and the pattern no longer trips static analyzers.
No functional change intended.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Suggested-by: David Laight <david.laight.linux at gmail.com>
Signed-off-by: Alexander Chesnokov <Alexander.Chesnokov at kaspersky.com>
---
Changes in v3:
- Drop the Fixes: tag and Cc: stable and reword the subject/commit
message: there is no reachable overflow, so this is a robustness
cleanup rather than a bug fix (David Laight).
- Resend as a standalone message, not threaded under the previous
version (Leon Romanovsky).
Changes in v2:
- Declare i, j and k as u64 instead of casting the operands (David Laight).
Previous discussion:
https://lore.kernel.org/linux-rdma/20260707140938.3106919-1-Alexander.Chesnokov@kaspersky.com/
https://lore.kernel.org/linux-rdma/20260708092146.3325855-1-Alexander.Chesnokov@kaspersky.com/
---
drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
index 1c180a6b1c07..3469a9a68d3b 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
@@ -4238,7 +4238,7 @@ static int hns_roce_v2_set_hem(struct hns_roce_dev *hr_dev,
struct hns_roce_hem_mhop mhop;
struct hns_roce_hem *hem;
unsigned long mhop_obj = obj;
- int i, j, k;
+ u64 i, j, k;
int ret = 0;
u64 hem_idx = 0;
u64 l1_idx = 0;
--
2.43.0
More information about the lvc-project
mailing list