RDMA/siw: avoid exposing kernel addresses in Read requests
Subsystems (3)
PATCH 1/1 RDMA/siw: avoid exposing kernel addresses in Read requests
siw_qp_prepare_tx() copies the local sink SGE address into the Tagged Offset of an outgoing RDMA Read Request. For kernel consumers using virtual DMA, this is a kernel virtual address. An unauthenticated peer can trigger this disclosure through an RPC-over-RDMA Read chunk before the server processes the RPC credentials.
Use a zero-based sink Tagged Offset for Reads on kernel QPs and expect the same initial offset when receiving the response. The outstanding Read queue already retains the local SGE, and siw_proc_rresp() uses that SGE for the local access check and data placement. Keep that address unchanged and advance the wire offset as response segments arrive.
RFC 5040 Sections 4.4 and 5.2.2 allow a zero initial Tagged Offset and require the peer to return Read responses in request order. No peer-side change is needed. Preserve the existing offsets for userspace QPs and leave RDMA Write and Read Response transmission unchanged.
The patch applies cleanly to nfsd-testing at
commit 36fd4049e3c2bb901118e11be63bf7a7922bea8c ("NFSD: Remove the dead session slot retirement code"). The affected SIW files match the RDMA for-rc patch base, e7732ec135b501e87ab060d992b3b5f2ec4396c9. Both x86-64 kernels used in the runtime tests below built with GCC 12.2, W=1, CONFIG_WERROR=y, CONFIG_RDMA_SIW=y, and RPC-over-RDMA enabled.
In a two-VM Soft-iWARP test, a raw MPA peer running as uid/gid 65534 with no capabilities and NoNewPrivs set triggered eight NFSv4 NULL calls with a four-byte Read chunk. Before this change, all eight Read Requests exposed the same kernel virtual address as SinkTO. After this change, all eight carried a zero SinkTO. In both runs, every Read completed and received its matching RPC reply. No WARN, Oops, or panic occurred.
The patched kernel also completed four outstanding Reads, a segmented Read Response, and MPA CRC, exercising SIW_OP_READ_LOCAL_INV. A userspace QP control retained its original nonzero address on the wire. Repeating the kernel-QP tests with Generic KASAN and lockdep produced no diagnostic.
The vulnerability research and validation were conducted by members of the Tobabz team as part of the Best of the Best 15th program.
--- drivers/infiniband/sw/siw/siw.h | 5 +++++ drivers/infiniband/sw/siw/siw_qp_rx.c | 3 ++- drivers/infiniband/sw/siw/siw_qp_tx.c | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-)
drivers/infiniband/sw/siw/siw.h +5 -0
@@ -478,6 +478,11 @@ struct siw_qp {#define rx_type (wqe) ((wqe)->rqe.opcode)#define tx_flags (wqe) ((wqe)->sqe.flags) +static inline u64 siw_read_wire_offset (const struct siw_qp *qp,u64 laddr) +{ +return rdma_is_kernel_res (&qp->base_qp.res) ?0 : laddr; +} +struct iwarp_msg_info {int hdr_len;struct iwarp_ctrl ctrl;
drivers/infiniband/sw/siw/siw_qp_rx.c +2 -1
@@ -174,7 +174,8 @@ static int siw_rresp_check_ntoh(struct siw_rx_stream *srx,if (frx->first_ddp_seg) { srx->ddp_stag = wqe->sqe.sge[0 ].lkey; - srx->ddp_to = wqe->sqe.sge[0 ].laddr; + srx->ddp_to =siw_read_wire_offset (rx_qp (srx), + wqe->sqe.sge[0 ].laddr); frx->pbl_idx =0 ; }/* Below checks extend beyond the semantics of DDP, and
drivers/infiniband/sw/siw/siw_qp_tx.c +4 -2
@@ -118,6 +118,7 @@ static int siw_qp_prepare_tx(struct siw_iwarp_tx *c_tx) {struct siw_wqe *wqe = &c_tx->wqe_active;char *crc =NULL ; +u64 sink_to;int data =0 ;switch (tx_type (wqe)) {
@@ -133,8 +134,9 @@ static int siw_qp_prepare_tx(struct siw_iwarp_tx *c_tx)htonl (++c_tx->ddp_msn[RDMAP_UNTAGGED_QN_RDMA_READ ]); c_tx->pkt.rreq.ddp_mo =0 ; c_tx->pkt.rreq.sink_stag =htonl (wqe->sqe.sge[0 ].lkey); - c_tx->pkt.rreq.sink_to = -cpu_to_be64 (wqe->sqe.sge[0 ].laddr); + sink_to =siw_read_wire_offset (tx_qp (c_tx), + wqe->sqe.sge[0 ].laddr); + c_tx->pkt.rreq.sink_to =cpu_to_be64 (sink_to); c_tx->pkt.rreq.source_stag =htonl (wqe->sqe.rkey); c_tx->pkt.rreq.source_to =cpu_to_be64 (wqe->sqe.raddr); c_tx->pkt.rreq.read_size =htonl (wqe->sqe.sge[0 ].length);
base-commit: e7732ec135b501e87ab060d992b3b5f2ec4396c9
Signature · 1 line
2.50.1 (Apple Git-155)
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 18 lines
siw_qp_prepare_tx()copies the local sink SGE address into the Tagged Offset of an outgoing RDMA Read Request. For kernel consumers using virtual DMA, this is a kernel virtual address. An unauthenticated peer can trigger this disclosure through an RPC-over-RDMA Read chunk before the server processes the RPC credentials.Use a zero-based sink Tagged Offset for Reads on kernel QPs and expect the same initial offset when receiving the response. The outstanding Read queue already retains the local SGE, and
siw_proc_rresp()uses that SGE for the local access check and data placement. Keep that address unchanged and advance the wire offset as response segments arrive.RFC 5040 Sections 4.4 and 5.2.2 allow a zero initial Tagged Offset and require the peer to return Read responses in request order. No peer-side change is needed. Preserve the existing offsets for userspace QPs and [ ... ]
the Tobabz team as part of the Best of the Best 15th program.
Quoted 3 lines
Fixes b9be6f18cf9e ("rdma/siw: transmit path")Signed-off-by Jiwoong Wi <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1