From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Yiran Qiu <eritque-arcus@ikuyo.dev>,
zyjzyj2000@gmail.com, jgg@ziepe.ca, leon@kernel.org,
"yanjun.zhu@linux.dev" <yanjun.zhu@linux.dev>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] RDMA/rxe: match a duplicate request to a resource of its own type
Date: Sat, 21 Nov 2026 13:09:10 -0800 [thread overview]
Message-ID: <9ec73d93-2d91-4d87-857f-4480084bb7a1@linux.dev> (raw)
In-Reply-To: <20261120055951.302239-1-eritque-arcus@ikuyo.dev>
在 2026/11/19 21:59, Yiran Qiu 写道:
> 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.
Thanks a lot. If you can share the reproducer and the test logs with me,
I can reproduce this problem in my local host.
Except that, I am fine with this commit.
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Zhu Yanjun
>
> 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;
--
Best Regards,
Yanjun.Zhu
next prev parent reply other threads:[~2026-11-21 21:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 5:59 [PATCH] RDMA/rxe: match a duplicate request to a resource of its own type Yiran Qiu
2026-11-20 6:13 ` sashiko-bot
2026-11-21 21:09 ` Zhu Yanjun [this message]
2026-11-25 12:25 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9ec73d93-2d91-4d87-857f-4480084bb7a1@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=eritque-arcus@ikuyo.dev \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=zyjzyj2000@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.