From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.141 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796222949; b=GtlGLTumbbWCKTchejPJWVccRnB6IZmqgbIU9DtH8JrUczxmomNchA42Xj9FFCgLPtWx FQCH0iPeB6l8H0YcUWHLdmaL7wBNjdsM5MxjAt9Wu+JEHMMEZAOQrKkpdpzPplXF6Tvkq M/3zWoGwZavv713WF7Pi6X68/Ct/W+o3cbRJ8Y7uW7w0ZquXVZ0rWhZtE0/fO9Sd2GlrV je3zisKZlPjo7K75iqbzxD3Cz1tBM2BAvcQxO7htk6jxMJhN0rADaRWfP/FtdT26CeHAi NwnSHXJcPdgmPDn0Ph+IGuh5rWO68DB/bSvhfQxCsZeEjWvJgTeH/VkYyyY9FpZ3J1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796222949; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=P0oN/5nAafqKzKwzYdB3NdXPjkMUb1uHCn/+re2zB/g=; b=ymOr1W6pyO20KwRFrnvo5fiwBwdzHo0+Cg+0Bnos2viIb/9BKYke78VfywCnLMeFM6T9 JmV1sVvwXKGSygb681qXNAg+dm2ATc/xlKob2Xf/4XG2ZefKgwJsjQxZ1mZ1scwKnvWLe P7fz1mSdPOecAdzBEtO/62ImJgL1wM7wmyskG/ONDbsNJ5E04zC8bI9P6+OrnxFhYljul orNtoXqzCB1gQCABC1wFGaf6OoIyzVg+/pSFyK+9j0pQO7KdhsOsU15pXXDq/iAmOznVd HCLCrr68p3bhqB02yAf2Ca3+Q/bssulqfiUWJJ/IMqk8PL9XvSwH+6ikANgO0KfI7cA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=A7AamvOI; arc=none smtp.remote-ip=91.218.175.141 Received: from mta0.migadu.com (out-141.mta0.migadu.com [91.218.175.141]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94266606A325 for ; Wed, 2 Dec 2026 14:49:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 94266606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=A7AamvOI X-Envelope-To: linux-rdma@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=ISRahBZ2PTrvHm0eJdqUJXGaqq+MqbxVmL8kTdWQKNY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796222946; v=1; x=1796827746; b=A7AamvOIJcyw7XRW/i4ylJDFC40QKYjbNcf4HLfzgAv+XYWwRX4Tnw/0zgbA6cpi3wsq5RMf zbKSAEzgN1EpdJZNFRHc3MLSaA8ZJIM1/GEE02r1d9mFHTpb9kXY6ASwDgxw5zcbuWUOL9akhX3 RR/d68HtcIbnAo2zUS29rBtM= X-Envelope-To: linux-rdma@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 34266921ae7ec88c; Wed, 02 Dec 2026 14:49:06 +0000 X-Mizu-Trace-ID: 34266921ae7ec88c X-Migadu-Flow: FLOW_OUT Message-ID: Date: Wed, 2 Dec 2026 15:49:01 +0100 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] RDMA/siw: avoid exposing kernel addresses in Read requests To: Jiwoong Wi , Jason Gunthorpe , Leon Romanovsky Cc: linux-rdma@vger.kernel.org, bobtobabz@gmail.com, stable@vger.kernel.org References: <20261130061347.50309-1-dwdnlzj@gmail.com> From: Bernard Metzler In-Reply-To: <20261130061347.50309-1-dwdnlzj@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 > --- > 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