* [PATCH rdma-rc] RDMA/siw: Reject an MPA reply too short for the IRD/ORD block
@ 2026-11-28 14:08 Andrew Stellman
2026-11-28 14:26 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stellman @ 2026-11-28 14:08 UTC (permalink / raw)
To: Bernard Metzler
Cc: Jason Gunthorpe, Leon Romanovsky, linux-rdma, linux-kernel
From: Andrew Stellman <astellman@stellman-greene.com>
When a siw initiator uses enhanced connection setup (MPA v2),
siw_proc_mpareply() reads the IRD/ORD block from the reply's private
data without checking that the responder sent one. The responder
chooses the PD_Length of its reply.
With a PD_Length of 0 there is no private data buffer and siw
dereferences NULL:
Unable to handle kernel paging request at virtual address dfff800000000000
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
Call trace:
siw_cm_work_handler+0xfa8/0x1b5c (P)
process_one_work+0x5cc/0xc90
worker_thread+0x3ac/0xaa0
kthread+0x36c/0x420
ret_from_fork+0x10/0x20
---[ end trace 0000000000000000 ]---
With a PD_Length of 1 to 3, siw_cm_upcall() subtracts the 4 byte block
from the u8 private data length, and iw_cm copies 253 to 255 bytes from
a much smaller buffer. With PD_Length 2 (a 6-byte buffer):
BUG: KASAN: slab-out-of-bounds in kmemdup_noprof+0x48/0x60
Read of size 254 at addr ffff0000da924cc4 by task kworker/u32:3/179
Call trace:
kmemdup_noprof+0x48/0x60
cm_event_handler+0x318/0x50c
siw_cm_upcall+0x290/0x420
siw_cm_work_handler+0xb84/0x1b5c
process_one_work+0x5cc/0xc90
worker_thread+0x3ac/0xaa0
kthread+0x36c/0x420
ret_from_fork+0x10/0x20
Fail the connection when an enhanced reply is shorter than the IRD/ORD
block, and only hide the block from the consumer when it is there. The
initiator now gets RDMA_CM_EVENT_REJECTED with -ECONNRESET for these
replies.
The issue was found by Claude Opus 5.5 running Quality Playbook, an
LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix and this changelog were drafted with Claude Opus 5.5 and
reviewed by me.
Fixes: 6c52fdc244b5 ("rdma/siw: connection management")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
Tested on arm64 QEMU with KASAN, built from rdma for-next 94e81a1f3ffa
sources applied to an older checkout (hence the version string). The
PD_Length 0 oops came after over-read reports in the same boot (hence
the B taint). Each reply's 20-byte MPA header was sent in five writes
and its private data one byte at a time. With this patch, PD_Length 0
to 3 and a reject with PD_Length 2 all gave RDMA_CM_EVENT_REJECTED with
-ECONNRESET and no KASAN report, and a valid enhanced reply still
established.
A reproducer is available on request.
drivers/infiniband/sw/siw/siw_cm.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c
index ed49818793dde..0a0d91398e790 100644
--- a/drivers/infiniband/sw/siw/siw_cm.c
+++ b/drivers/infiniband/sw/siw/siw_cm.c
@@ -392,7 +392,8 @@ static int siw_cm_upcall(struct siw_cep *cep, enum iw_cm_event_type reason,
event.private_data = cep->mpa.pdata;
/* Hide MPA V2 IRD/ORD control */
- if (cep->enhanced_rdma_conn_est) {
+ if (cep->enhanced_rdma_conn_est &&
+ pd_len >= sizeof(struct mpa_v2_data)) {
event.private_data_len -=
sizeof(struct mpa_v2_data);
event.private_data +=
@@ -849,6 +850,14 @@ static int siw_proc_mpareply(struct siw_cep *cep)
-ECONNRESET);
return -EINVAL;
}
+ if (be16_to_cpu(rep->params.pd_len) <
+ sizeof(struct mpa_v2_data)) {
+ siw_dbg_cep(cep, "mpa reply error: pd_len %u\n",
+ be16_to_cpu(rep->params.pd_len));
+ siw_cm_upcall(cep, IW_CM_EVENT_CONNECT_REPLY,
+ -ECONNRESET);
+ return -EINVAL;
+ }
v2 = (struct mpa_v2_data *)cep->mpa.pdata;
rep_ird = ntohs(v2->ird) & MPA_IRD_ORD_MASK;
rep_ord = ntohs(v2->ord) & MPA_IRD_ORD_MASK;
base-commit: 94e81a1f3ffabb388f7d0a9674bb1d3acc067e00
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH rdma-rc] RDMA/siw: Reject an MPA reply too short for the IRD/ORD block
2026-11-28 14:08 [PATCH rdma-rc] RDMA/siw: Reject an MPA reply too short for the IRD/ORD block Andrew Stellman
@ 2026-11-28 14:26 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-28 14:26 UTC (permalink / raw)
To: Andrew Stellman; +Cc: linux-rdma
> From: Andrew Stellman <astellman@stellman-greene.com>
>
> When a siw initiator uses enhanced connection setup (MPA v2),
> siw_proc_mpareply() reads the IRD/ORD block from the reply's private
> data without checking that the responder sent one. The responder
> chooses the PD_Length of its reply.
>
> With a PD_Length of 0 there is no private data buffer and siw
> dereferences NULL:
>
> Unable to handle kernel paging request at virtual address dfff800000000000
> KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
> Call trace:
> siw_cm_work_handler+0xfa8/0x1b5c (P)
> process_one_work+0x5cc/0xc90
> [ ... ]
> The fix and this changelog were drafted with Claude Opus 5.5 and
> reviewed by me.
>
> Fixes: 6c52fdc244b5 ("rdma/siw: connection management")
> Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128140838.58976-1-bugs@stellman-greene.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-28 14:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 14:08 [PATCH rdma-rc] RDMA/siw: Reject an MPA reply too short for the IRD/ORD block Andrew Stellman
2026-11-28 14:26 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox