milos-linux/drivers/infiniband/ulp
Michael Bommarito 13e91fd076 RDMA/srp: bound SRP_RSP sense copy by the received length
srp_process_rsp() copies sense data from rsp->data + resp_data_len,
where resp_data_len is the full 32-bit value supplied by the SRP target
and is never checked against the number of bytes actually received
(wc->byte_len). The copy length is bounded to SCSI_SENSE_BUFFERSIZE, so
at most 96 bytes are copied, but the source offset is not bounded.

A malicious or compromised SRP target on the InfiniBand/RoCE fabric that
the initiator has logged into can return an SRP_RSP with
SRP_RSP_FLAG_SNSVALID set and a large resp_data_len. The receive buffer
is allocated at the target-chosen max_ti_iu_len, so the source of the
sense copy lands past the bytes actually received; with resp_data_len
near 0xFFFFFFFF it is gigabytes past the buffer and the read faults.

Copy the sense data only if it has not been truncated, that is, only if
the response header, the response data, and the sense region fit within
the bytes actually received; otherwise drop the sense and log. The
in-tree iSER and NVMe-RDMA receive paths already bound their parse by
wc->byte_len; this brings ib_srp into line with them.

Fixes: aef9ec39c4 ("IB: Add SCSI RDMA Protocol (SRP) initiator")
Link: https://patch.msgid.link/r/20260602220457.2542840-1-michael.bommarito@gmail.com
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
2026-06-08 13:43:23 -03:00
..
ipoib IB/IPoIB: ndo_set_rx_mode_async conversion 2026-05-15 17:16:33 -07:00
iser Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses 2026-02-22 08:26:33 -08:00
isert IB/isert: Reject login PDUs shorter than ISER_HEADERS_LEN 2026-06-08 13:43:23 -03:00
rtrs RDMA/rtrs: Fix use-after-free in path file creation cleanup 2026-05-19 19:32:48 -03:00
srp RDMA/srp: bound SRP_RSP sense copy by the received length 2026-06-08 13:43:23 -03:00
srpt scsi: target: Use driver completion preference by default 2026-02-28 21:04:02 -05:00
Makefile RDMA/hfi1: Remove opa_vnic 2026-03-10 07:51:30 -04:00