Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH rdma-rc] RDMA/siw: Reject a zero length WRITE segment that announces more segments
@ 2026-11-20  0:08 Andrew Stellman
  2026-11-20  0:15 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stellman @ 2026-11-20  0:08 UTC (permalink / raw)
  To: Bernard Metzler
  Cc: Jason Gunthorpe, Leon Romanovsky, linux-rdma, linux-kernel

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@stellman-greene.com>
---

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH rdma-rc] RDMA/siw: Reject a zero length WRITE segment that announces more segments
  2026-11-20  0:08 [PATCH rdma-rc] RDMA/siw: Reject a zero length WRITE segment that announces more segments Andrew Stellman
@ 2026-11-20  0:15 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-20  0:15 UTC (permalink / raw)
  To: Andrew Stellman; +Cc: linux-rdma

> 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
> [ ... ]
> 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@stellman-greene.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120000829.64597-1-astellman@stellman-greene.com?part=1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-20  0:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  0:08 [PATCH rdma-rc] RDMA/siw: Reject a zero length WRITE segment that announces more segments Andrew Stellman
2026-11-20  0:15 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox