[PATCH rdma-next v1] RDMA/rxe: Don't trust the user space SQ producer index

From: Shuai Liu

Date: Fri Nov 20 2026 - 06:42:49 EST


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@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=fef38133c495aeb48297
Fixes: 5bcf5a59c41e1 ("RDMA/rxe: Protext kernel index from user space")
Signed-off-by: Shuai Liu <847807867@xxxxxx>
---
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