mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] RDMA/srp: bound the receive IU the target asks for
@ 2026-10-25 11:41 Yehyeong Lee
  2026-10-25 11:41 ` [PATCH 1/2] RDMA/srp: refuse a target that cannot receive an SRP_RSP Yehyeong Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Yehyeong Lee @ 2026-10-25 11:41 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Leon Romanovsky, Jason Gunthorpe, linux-rdma, linux-kernel,
	stable, yhlee

The target decides how large the initiator's receive buffers are, and the
initiator never checks the answer.

srp_cm_rep_handler() takes max_ti_iu_len out of the SRP_LOGIN_RSP and
srp_alloc_iu_bufs() sizes every receive IU with it. Across the whole file
that value is only ever assigned, handed to kzalloc() and passed to two
dma_sync calls. It is never compared against anything. Meanwhile the
initiator parses a 36 byte header out of those buffers, and
srp_process_rsp() does so without looking at how many bytes arrived, unlike
srp_process_cred_req() and srp_process_aer_req() which both refuse a short
message.

The two patches close different halves of that, so they are separate.

The first refuses a login that cannot work. A report below 36 gives
undersized buffers, and a report of zero is worse, because kzalloc()
answers it with ZERO_SIZE_PTR and on a virtually mapped transport
ib_dma_map_single() returns that pointer without looking at the length,
while ib_dma_mapping_error() calls it a success. The buffer then reaches
the receive path and the read of the opcode in srp_recv_done() is already
out of bounds.

The second refuses a truncated response, which is also what makes the
initiator stop parsing whatever an earlier response left in the reused IU.

Both have been exercised against an out of tree KUnit test on x86_64 with
KASAN, one boot per case. On the unpatched arm a target reporting 33 gets
33 byte IUs and srp_process_rsp() reads four bytes at offset 32:

  BUG: KASAN: slab-out-of-bounds in srp_process_rsp+0x757/0xbe0
  Read of size 4 at addr ffff88800243f120 by task kunit_try_catch/42
   srp_process_rsp+0x757/0xbe0
  Allocated by task 42:
   srp_alloc_iu.constprop.0+0x69/0x5c0
   srp_cm_rep_handler+0xc2e/0x1bb0
  The buggy address belongs to the object at ffff88800243f100
   which belongs to the cache kmalloc-64 of size 64
  The buggy address is located 32 bytes inside of
   allocated 33-byte region [ffff88800243f100, ffff88800243f121)

A report of zero logs in on the unpatched arm with the receive IUs pointing
at ZERO_SIZE_PTR and four receive work requests posted against them, and is
refused with -ECONNRESET afterwards. A target reporting 64 logs in and
completes a full response identically either way. The test is not part of
these patches.

This is an out of bounds read, and on a virtually mapped transport a
read of a wild address. Neither patch is about a write or a use after
free.

Yehyeong Lee (2):
  RDMA/srp: refuse a target that cannot receive an SRP_RSP
  RDMA/srp: drop a truncated SRP_RSP

 drivers/infiniband/ulp/srp/ib_srp.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)


base-commit: 330517c63aa9b48227b6ab45f01003effac77ae4
-- 
2.43.0


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

end of thread, other threads:[~2026-10-26  5:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-25 11:41 [PATCH 0/2] RDMA/srp: bound the receive IU the target asks for Yehyeong Lee
2026-10-25 11:41 ` [PATCH 1/2] RDMA/srp: refuse a target that cannot receive an SRP_RSP Yehyeong Lee
2026-10-25 14:18   ` Bart Van Assche
2026-10-25 11:41 ` [PATCH 2/2] RDMA/srp: drop a truncated SRP_RSP Yehyeong Lee
2026-10-25 14:20   ` Bart Van Assche
2026-10-26  5:20 ` [PATCH v2 0/2] RDMA/srp: bound the receive IU the target asks for Yehyeong Lee
2026-10-26  5:20   ` [PATCH v2 1/2] RDMA/srp: refuse a target that cannot receive an SRP_RSP Yehyeong Lee
2026-10-26  5:20   ` [PATCH v2 2/2] RDMA/srp: do not DMA-sync a receive IU past its mapped length Yehyeong Lee

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

all inboxes | Powered by JetHome®