From: Shuai Liu <847807867@qq.com>
To: linux-rdma@vger.kernel.org
Cc: yanjun.zhu@linux.dev, zyjzyj2000@gmail.com, jgg@ziepe.ca,
leon@kernel.org, rpearsonhpe@gmail.com,
syzbot+fef38133c495aeb48297@syzkaller.appspotmail.com,
syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org
Subject: [PATCH rdma-next v1] RDMA/rxe: Don't trust the user space SQ producer index
Date: Fri, 20 Nov 2026 19:42:15 +0800 [thread overview]
Message-ID: <tencent_5B9FB1BCC8EF36C5E2128B7D4D54B867480A@qq.com> (raw)
In-Reply-To: <6adb54ac.d1cee5ca.8df35.0007.GAE@google.com>
The send queue producer index of a user space QP is stored in the
queue buffer which is shared with and written by user space. The
requester reads it without any validation in req_retry() and
__req_next_wqe().
The requester stops processing WQEs when its local WQE index equals
the producer index. If user space writes an out of range producer
index into the queue buffer, that comparison can never become true.
Once the QP is put into the error state, rxe_requester() then keeps
flushing the same (already errored) WQE forever: the flush loop
advances the WQE index but req_retry() resets it back to the
consumer index, and each pass calls rxe_qp_error() which reschedules
the send task, so the loop never converges. The send task holds a
reference to the QP for as long as this lasts, so ib_destroy_qp()
waits for the QP reference to drop until it times out after 50
seconds and the WARN_ON(!ret) fires in __rxe_cleanup():
WARNING: drivers/infiniband/sw/rxe/rxe_pool.c:212 at __rxe_cleanup
Call Trace:
__rxe_cleanup
rxe_destroy_qp
...
rxe0: qp#17 rxe_destroy_qp: cleanup failed, err = -110
Fix this by validating the producer index: if it is out of range,
treat the send queue as empty. Verified with the syzbot reproducer
in QEMU: without this patch every destroy_qp hangs for 50 seconds
and hits the WARNING above; with this patch the reproducer runs
cleanly.
Reported-by: syzbot+fef38133c495aeb48297@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=fef38133c495aeb48297
Fixes: 5bcf5a59c41e1 ("RDMA/rxe: Protext kernel index from user space")
Signed-off-by: Shuai Liu <847807867@qq.com>
---
drivers/infiniband/sw/rxe/rxe_req.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
index 4f353abd76f55..2f7396f40801b 100644
--- a/drivers/infiniband/sw/rxe/rxe_req.c
+++ b/drivers/infiniband/sw/rxe/rxe_req.c
@@ -48,6 +48,12 @@ static void req_retry(struct rxe_qp *qp)
cons = queue_get_consumer(q, QUEUE_TYPE_FROM_CLIENT);
prod = queue_get_producer(q, QUEUE_TYPE_FROM_CLIENT);
+ /* The producer index is written by user space and cannot
+ * be trusted; treat an out of range index as an empty queue.
+ */
+ if (unlikely(prod & ~q->index_mask))
+ prod = cons;
+
qp->req.wqe_index = cons;
qp->req.psn = qp->comp.psn;
qp->req.opcode = -1;
@@ -168,7 +174,7 @@ static struct rxe_send_wqe *__req_next_wqe(struct rxe_qp *qp)
unsigned int prod;
prod = queue_get_producer(q, QUEUE_TYPE_FROM_CLIENT);
- if (index == prod)
+ if (unlikely(prod & ~q->index_mask) || index == prod)
return NULL;
else
return queue_addr_from_index(q, index);
--
2.43.0
next prev parent reply other threads:[~2026-11-20 11:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 12:35 [syzbot] [rdma?] WARNING in __rxe_cleanup syzbot
2026-10-24 3:31 ` Zhu Yanjun
2026-11-19 21:03 ` syzbot
2026-11-20 11:42 ` Shuai Liu [this message]
2026-11-21 3:42 ` [PATCH] RDMA/rxe: Mask the SQ producer index read from user space Shuai Liu
2026-11-21 3:46 ` [PATCH rdma-next v2] " Shuai Liu
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=tencent_5B9FB1BCC8EF36C5E2128B7D4D54B867480A@qq.com \
--to=847807867@qq.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=rpearsonhpe@gmail.com \
--cc=syzbot+fef38133c495aeb48297@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=yanjun.zhu@linux.dev \
--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 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®