mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
RDMA/hns: Fix arithmetic overflow in calc_hem_config()
If bt_num is 3 or 2, then the expressions like
l0_idx * chunk_ba_num + l1_idx are computed in 32-bit
arithmetic before being assigned to a u64 index field,
which can lead to overflow.
Cast the first operand to u64 to ensure the arithmetic
is performed in 64-bit.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 2f49de21f3 ("RDMA/hns: Optimize mhop get flow for multi-hop addressing")
Signed-off-by: Alexander Chesnokov <Alexander.Chesnokov@kaspersky.com>
Link: https://patch.msgid.link/20260413091527.39990-1-Alexander.Chesnokov@kaspersky.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
194762e6e4
commit
a38e4410af
|
|
@ -314,14 +314,14 @@ static int calc_hem_config(struct hns_roce_dev *hr_dev,
|
|||
bt_num = hns_roce_get_bt_num(table->type, mhop->hop_num);
|
||||
switch (bt_num) {
|
||||
case 3:
|
||||
index->l1 = l0_idx * chunk_ba_num + l1_idx;
|
||||
index->l1 = (u64)l0_idx * chunk_ba_num + l1_idx;
|
||||
index->l0 = l0_idx;
|
||||
index->buf = l0_idx * chunk_ba_num * chunk_ba_num +
|
||||
l1_idx * chunk_ba_num + l2_idx;
|
||||
index->buf = (u64)l0_idx * chunk_ba_num * chunk_ba_num +
|
||||
(u64)l1_idx * chunk_ba_num + l2_idx;
|
||||
break;
|
||||
case 2:
|
||||
index->l0 = l0_idx;
|
||||
index->buf = l0_idx * chunk_ba_num + l1_idx;
|
||||
index->buf = (u64)l0_idx * chunk_ba_num + l1_idx;
|
||||
break;
|
||||
case 1:
|
||||
index->buf = l0_idx;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user