[PATCH rdma-rc] RDMA/siw: Reject a zero length WRITE segment that announces more segments
From: Andrew Stellman
Date: Thu Nov 19 2026 - 19:09:25 EST
siw_proc_write() returns early for a zero length tagged segment, before
it looks up the sink STag. If that first segment has the L bit clear,
the next segment is handled as a continuation of the same message and
siw reads mem->stag through rx_mem, which was never set. A remote peer
on an established siw connection can trigger this, and it panics the
host:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000004: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
RIP: 0010:siw_proc_write+0x175/0x9c0
Call Trace:
<IRQ>
siw_tcp_rx_data+0x20e/0x2040
__tcp_read_sock+0x1ab/0x810
siw_qp_llp_data_ready+0x185/0x2e0
tcp_data_queue+0x1f2d/0x4b70
tcp_rcv_established+0x8a8/0x3990
tcp_v4_do_rcv+0x45b/0x970
tcp_v4_rcv+0x223d/0x3b90
Kernel panic - not syncing: Fatal exception in interrupt
A zero length DDP message consists of exactly one segment (RFC 5041,
section 5.2), so terminate the connection with a tagged buffer error
when a zero length first segment announces more segments.
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 the same tool and reviewed
by me.
Fixes: 8b6a361b8c48 ("rdma/siw: receive path")
Signed-off-by: Andrew Stellman <astellman@xxxxxxxxxxxxxxxxxxx>
---
Tested in QEMU with KASAN on v7.4-rc3. The patch applies unchanged to
rdma for-rc. With this patch siw sends a TERMINATE and closes the
connection, a normal two segment WRITE is still placed, and rping over
siw works.
A reproducer is available on request.
drivers/infiniband/sw/siw/siw_qp_rx.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c
index e5b641c8d694..9b7e52906764 100644
--- a/drivers/infiniband/sw/siw/siw_qp_rx.c
+++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
@@ -550,8 +550,16 @@ int siw_proc_write(struct siw_qp *qp)
int bytes, rv;
if (srx->state == SIW_GET_DATA_START) {
- if (!srx->fpdu_part_rem) /* zero length WRITE */
+ if (!srx->fpdu_part_rem) { /* zero length WRITE */
+ /* A zero length DDP message is a single segment. */
+ if (unlikely(frx->first_ddp_seg && frx->more_ddp_segs)) {
+ siw_init_terminate(qp, TERM_ERROR_LAYER_DDP,
+ DDP_ETYPE_TAGGED_BUF,
+ DDP_ECODE_T_INVALID_STAG, 0);
+ return -EINVAL;
+ }
return 0;
+ }
rv = siw_write_check_ntoh(srx, frx);
if (unlikely(rv)) {
base-commit: e7732ec135b501e87ab060d992b3b5f2ec4396c9
--
2.43.0