* [PATCH] RDMA/rxe: match a duplicate request to a resource of its own type
@ 2026-11-20 5:59 Yiran Qiu
0 siblings, 0 replies; only message in thread
From: Yiran Qiu @ 2026-11-20 5:59 UTC (permalink / raw)
To: zyjzyj2000, jgg, leon; +Cc: linux-rdma, linux-kernel, Yiran Qiu, stable
find_resource() matches a retransmitted request to a responder resource
by PSN alone, and rxe_prepare_res() never sets the PSN range of a FLUSH
resource, so it keeps the PSNs of the request that last used the slot.
duplicate_request() then gives a retransmitted READ the FLUSH resource
and reads res->read through the union, so read.rkey and read.length come
from the FLUSH's RETH va, chosen by the requester. read_reply() replays
the READ through rxe_recheck_mr(), which only checks that the rkey names
a valid MR.
A FLUSH with no persistence type needs no QP access bit. A connected RC
peer holding one rkey of the QP's PD can thus read any valid MR on the
device, including MRs of other PDs without remote access and the DMA MR
that each kernel PD gets on rxe, which reads kernel memory at the
address the peer gives.
Record the PSNs of a FLUSH resource, and match a duplicate only to a
resource of its own type.
Found with afb-afl, an LLM-driven kernel audit/repro pipeline; the fix
and this changelog were also drafted with LLM assistance. Reproduced on
an unmodified KASAN build of mainline, with raw RoCEv2 packets to an rxe
RC QP: four zero-length READs, a FLUSH, then a READ with the first PSN.
The replayed READ returned 64 bytes of an MR that another process had
registered in another PD with local access only and, against the kernel
DMA MR of rxe0 (key byte found in at most 256 tries), 64 bytes of
linux_banner. With this patch the replayed READ is dropped in both
cases. Retransmitted READ, FETCH_ADD and ATOMIC WRITE requests are
replayed as before, a READ with a foreign rkey is NAKed, and a
retransmitted FLUSH is now acknowledged instead of dropped. The
rdma-core v65.0 tests pass on rxe with and without this patch.
Fixes: ea1bb00ee9a5 ("RDMA/rxe: Implement flush execution in responder side")
Cc: stable@vger.kernel.org
Signed-off-by: Yiran Qiu <eritque-arcus@ikuyo.dev>
---
Tested on mainline 4405c18c95d2 (v7.4-rc3+) in QEMU. Applies to
rdma.git for-rc and for-next.
A reproducer and the test logs are available on request.
drivers/infiniband/sw/rxe/rxe_resp.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
index 1b7f31737225..db662736404c 100644
--- a/drivers/infiniband/sw/rxe/rxe_resp.c
+++ b/drivers/infiniband/sw/rxe/rxe_resp.c
@@ -688,6 +688,9 @@ static struct resp_res *rxe_prepare_res(struct rxe_qp *qp,
res->flush.length = qp->resp.length;
res->flush.type = feth_plt(pkt);
res->flush.level = feth_sel(pkt);
+ res->first_psn = pkt->psn;
+ res->last_psn = pkt->psn;
+ res->cur_psn = pkt->psn;
}
return res;
@@ -1327,14 +1330,14 @@ static enum resp_states cleanup(struct rxe_qp *qp,
return RESPST_DONE;
}
-static struct resp_res *find_resource(struct rxe_qp *qp, u32 psn)
+static struct resp_res *find_resource(struct rxe_qp *qp, u32 psn, int type)
{
int i;
for (i = 0; i < qp->attr.max_dest_rd_atomic; i++) {
struct resp_res *res = &qp->resp.resources[i];
- if (res->type == 0)
+ if (res->type != type)
continue;
if (psn_compare(psn, res->first_psn) >= 0 &&
@@ -1361,7 +1364,7 @@ static enum resp_states duplicate_request(struct rxe_qp *qp,
struct resp_res *res;
/* Find the operation in our list of responder resources. */
- res = find_resource(qp, pkt->psn);
+ res = find_resource(qp, pkt->psn, RXE_FLUSH_MASK);
if (res) {
res->replay = 1;
res->cur_psn = pkt->psn;
@@ -1376,7 +1379,7 @@ static enum resp_states duplicate_request(struct rxe_qp *qp,
} else if (pkt->mask & RXE_READ_MASK) {
struct resp_res *res;
- res = find_resource(qp, pkt->psn);
+ res = find_resource(qp, pkt->psn, RXE_READ_MASK);
if (!res) {
/* Resource not found. Class D error. Drop the
* request.
@@ -1423,7 +1426,8 @@ static enum resp_states duplicate_request(struct rxe_qp *qp,
struct resp_res *res;
/* Find the operation in our list of responder resources. */
- res = find_resource(qp, pkt->psn);
+ res = find_resource(qp, pkt->psn, pkt->mask & RXE_ATOMIC_MASK ?
+ RXE_ATOMIC_MASK : RXE_ATOMIC_WRITE_MASK);
if (res) {
res->replay = 1;
res->cur_psn = pkt->psn;
--
2.56.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-20 6:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 5:59 [PATCH] RDMA/rxe: match a duplicate request to a resource of its own type Yiran Qiu
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®