* [PATCH] RDMA/siw: avoid exposing kernel addresses in Read requests
@ 2026-11-30 6:13 Jiwoong Wi
2026-12-02 8:16 ` Leon Romanovsky
2026-12-02 14:49 ` Bernard Metzler
0 siblings, 2 replies; 3+ messages in thread
From: Jiwoong Wi @ 2026-11-30 6:13 UTC (permalink / raw)
To: Bernard Metzler, Jason Gunthorpe, Leon Romanovsky
Cc: linux-rdma, bobtobabz, stable
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.
Fixes: b9be6f18cf9e ("rdma/siw: transmit path")
Cc: stable@vger.kernel.org
Signed-off-by: Jiwoong Wi <dwdnlzj@gmail.com>
---
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(-)
diff --git a/drivers/infiniband/sw/siw/siw.h b/drivers/infiniband/sw/siw/siw.h
index 4ec9c2ac75e7b..692d0017807d7 100644
--- a/drivers/infiniband/sw/siw/siw.h
+++ b/drivers/infiniband/sw/siw/siw.h
@@ -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;
diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c
index e5b641c8d694a..608bb442d42b6 100644
--- a/drivers/infiniband/sw/siw/siw_qp_rx.c
+++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
@@ -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
diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c
index 2675bc0b20195..7d1cf94f8382c 100644
--- a/drivers/infiniband/sw/siw/siw_qp_tx.c
+++ b/drivers/infiniband/sw/siw/siw_qp_tx.c
@@ -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
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] RDMA/siw: avoid exposing kernel addresses in Read requests
2026-11-30 6:13 [PATCH] RDMA/siw: avoid exposing kernel addresses in Read requests Jiwoong Wi
@ 2026-12-02 8:16 ` Leon Romanovsky
2026-12-02 14:49 ` Bernard Metzler
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2026-12-02 8:16 UTC (permalink / raw)
To: Jiwoong Wi
Cc: Bernard Metzler, Jason Gunthorpe, linux-rdma, bobtobabz, stable
On Mon, Nov 30, 2026 at 03:13:47PM +0900, Jiwoong Wi wrote:
> 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.
SIW is used for testing, there is no such "unauthenticated peer" there.
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] RDMA/siw: avoid exposing kernel addresses in Read requests
2026-11-30 6:13 [PATCH] RDMA/siw: avoid exposing kernel addresses in Read requests Jiwoong Wi
2026-12-02 8:16 ` Leon Romanovsky
@ 2026-12-02 14:49 ` Bernard Metzler
1 sibling, 0 replies; 3+ messages in thread
From: Bernard Metzler @ 2026-12-02 14:49 UTC (permalink / raw)
To: Jiwoong Wi, Jason Gunthorpe, Leon Romanovsky
Cc: linux-rdma, bobtobabz, stable
On 30.11.2026 07:13, Jiwoong Wi wrote:
> 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.
>
I cannot yet follow that line of reasoning. Can you make that
readable? Who is doing what and what is the potential thread?
What is the "unauthenticated peer" in that respect?
The siw READ initiator context keeps the target offset of the
RREQUEST message to be sent and enforces that it gets the very same
target offset back in the RRESPONSE (in siw_rresp_check_ntoh()).
How can that be circumvented?
Thanks.
> 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.
>
> Fixes: b9be6f18cf9e ("rdma/siw: transmit path")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiwoong Wi <dwdnlzj@gmail.com>
> ---
> 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(-)
>
> diff --git a/drivers/infiniband/sw/siw/siw.h b/drivers/infiniband/sw/siw/siw.h
> index 4ec9c2ac75e7b..692d0017807d7 100644
> --- a/drivers/infiniband/sw/siw/siw.h
> +++ b/drivers/infiniband/sw/siw/siw.h
> @@ -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;
> diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c
> index e5b641c8d694a..608bb442d42b6 100644
> --- a/drivers/infiniband/sw/siw/siw_qp_rx.c
> +++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
> @@ -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
> diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c
> index 2675bc0b20195..7d1cf94f8382c 100644
> --- a/drivers/infiniband/sw/siw/siw_qp_tx.c
> +++ b/drivers/infiniband/sw/siw/siw_qp_tx.c
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-02 14:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 6:13 [PATCH] RDMA/siw: avoid exposing kernel addresses in Read requests Jiwoong Wi
2026-12-02 8:16 ` Leon Romanovsky
2026-12-02 14:49 ` Bernard Metzler
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.