Skip to content

Commit 5201953

Browse files
CIQ Kernel Automationroxanan1996
authored andcommitted
RDMA/umad: Reject negative data_len in ib_umad_write
jira VULN-178538 cve CVE-2026-23243 commit-author YunJe Shin <yjshin0438@gmail.com> commit 5551b02 upstream-diff | cast second param `hdr_size(file) + hdr_len` in `check_sub_overflow` call to size_t to match the type of the first param `count` to fix build issue. ib_umad_write computes data_len from user-controlled count and the MAD header sizes. With a mismatched user MAD header size and RMPP header length, data_len can become negative and reach ib_create_send_mad(). This can make the padding calculation exceed the segment size and trigger an out-of-bounds memset in alloc_send_rmpp_list(). Add an explicit check to reject negative data_len before creating the send buffer. KASAN splat: [ 211.363464] BUG: KASAN: slab-out-of-bounds in ib_create_send_mad+0xa01/0x11b0 [ 211.364077] Write of size 220 at addr ffff88800c3fa1f8 by task spray_thread/102 [ 211.365867] ib_create_send_mad+0xa01/0x11b0 [ 211.365887] ib_umad_write+0x853/0x1c80 Fixes: 2be8e3e ("IB/umad: Add P_Key index support") Signed-off-by: YunJe Shin <ioerts@kookmin.ac.kr> Link: https://patch.msgid.link/20260203100628.1215408-1-ioerts@kookmin.ac.kr Signed-off-by: Leon Romanovsky <leon@kernel.org> (cherry picked from commit 5551b02) Signed-off-by: CIQ Kernel Automation <ciq_kernel_automation@ciq.com>
1 parent 4a90f6c commit 5201953

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/infiniband/core/user_mad.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
500500
struct ib_ah *ah;
501501
struct ib_rmpp_mad *rmpp_mad;
502502
__be64 *tid;
503-
int ret, data_len, hdr_len, copy_offset, rmpp_active;
503+
int ret, hdr_len, copy_offset, rmpp_active;
504+
size_t data_len;
504505
u8 base_version;
505506

506507
if (count < hdr_size(file) + IB_MGMT_RMPP_HDR)
@@ -574,7 +575,10 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
574575
}
575576

576577
base_version = ((struct ib_mad_hdr *)&packet->mad.data)->base_version;
577-
data_len = count - hdr_size(file) - hdr_len;
578+
if (check_sub_overflow(count, (size_t)(hdr_size(file) + hdr_len), &data_len)) {
579+
ret = -EINVAL;
580+
goto err_ah;
581+
}
578582
packet->msg = ib_create_send_mad(agent,
579583
be32_to_cpu(packet->mad.hdr.qpn),
580584
packet->mad.hdr.pkey_index, rmpp_active,

0 commit comments

Comments
 (0)