WARNING in __rxe_cleanup
Subsystems (2)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: c03c1a14507d Linux 7.3 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1796a621580000 kernel config: https://syzkaller.appspot.com/x/.config?x=c4b098695335c89f dashboard link: https://syzkaller.appspot.com/bug?extid=fef38133c495aeb48297 compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c9d4a36731a6/disk-c03c1a14.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/3c00e4e185bb/vmlinux-c03c1a14.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1f95d3156291/bzImage-c03c1a14.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
------------[ cut here ]------------ !ret WARNING: drivers/infiniband/sw/rxe/rxe_pool.c:212 at __rxe_cleanup+0x311/0x350 drivers/infiniband/sw/rxe/rxe_pool.c:212, CPU#0: kworker/u8:9/3389 Modules linked in: CPU: 0 UID: 0 PID: 3389 Comm: kworker/u8:9 Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2026 Workqueue: krds_cp_wq#0/0 rds_shutdown_worker RIP: 0010:__rxe_cleanup+0x311/0x350 drivers/infiniband/sw/rxe/rxe_pool.c:212 Code: f7 be 03 00 00 00 e8 7e 15 e8 fb 40 84 ed 0f 85 26 fe ff ff e9 5b fe ff ff e8 5b 89 cf f8 90 0f 0b 90 eb 09 e8 50 89 cf f8 90 <0f> 0b 90 41 be 92 ff ff ff e9 47 ff ff ff 44 89 f1 80 e1 07 80 c1 RSP: 0018:ffffc9000f2ff6d0 EFLAGS: 00010293 RAX: ffffffff88f888b0 RBX: ffff88807f162250 RCX: ffff888034160000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000001 R08: ffffffff917a757f R09: 1ffffffff22f4eaf R10: dffffc0000000000 R11: fffffbfff22f4eb0 R12: ffff88807e7615a0 R13: 00000000ffffffff R14: 0000000000000000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff888123abf000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffd5380382c CR3: 000000003558f000 CR4: 0000000000350ef0 Call Trace: <TASK> rxe_destroy_qp+0x74/0x270 drivers/infiniband/sw/rxe/rxe_verbs.c:661 ib_destroy_qp_user+0x354/0x5a0 drivers/infiniband/core/verbs.c:2182 ib_destroy_qp include/rdma/ib_verbs.h:4103 [inline] rdma_destroy_qp+0xd0/0x250 drivers/infiniband/core/cma.c:1170 rds_ib_conn_path_shutdown+0x9bd/0x1820 net/rds/ib_cm.c:1113 rds_conn_shutdown+0x477/0xb20 net/rds/connection.c:440 process_one_work kernel/workqueue.c:3396 [inline] process_scheduled_works+0xc3d/0x1630 kernel/workqueue.c:3479 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3560 kthread+0x38b/0x480 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK>
---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
Quoted 21 lines · syzbot
Hello,
syzbot found the following issue on:
HEAD commit: c03c1a14507d Linux 7.3 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1796a621580000 kernel config: https://syzkaller.appspot.com/x/.config?x=c4b098695335c89f dashboard link: https://syzkaller.appspot.com/bug?extid=fef38133c495aeb48297 compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8Unfortunately, I don't have any reproducer for this issue yet.
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c9d4a36731a6/disk-c03c1a14.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/3c00e4e185bb/vmlinux-c03c1a14.xz
kernel image: https://storage.googleapis.com/syzbot-assets/1f95d3156291/bzImage-c03c1a14.xzIMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by [email protected]
Quoted 9 lines
------------[ cut here ]------------ !ret WARNING: drivers/infiniband/sw/rxe/rxe_pool.c:212 at __rxe_cleanup+0x311/0x350 drivers/infiniband/sw/rxe/rxe_pool.c:212, CPU#0: kworker/u8:9/3389 Modules linked in: CPU: 0 UID: 0 PID: 3389 Comm: kworker/u8:9 Tainted: G L syzkaller #0 PREEMPT(full) Tainted: [L]=SOFTLOCKUP Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2026 Workqueue: krds_cp_wq#0/0 rds_shutdown_worker RIP: 0010:__rxe_cleanup+0x311/0x350 drivers/infiniband/sw/rxe/rxe_pool.c:212
Hi,
Looking at the stack trace and rxe_pool.c:212:
203 if (sleepable) {
204 if (!completion_done(&elem->complete)) {
205 ret = wait_for_completion_timeout(&elem->complete,
206 msecs_to_jiffies(50000));
207
208 /* Shouldn't happen. There are still references to
209 * the object but, rather than deadlock, free the 210 * object or pass back to rdma-core. 211 */
212 if (WARN_ON(!ret))
213 err = -ETIMEDOUT;
214 }
215 }
The WARNING triggers because __rxe_cleanup() timed out waiting 50s for the QP reference count to drop to zero during destruction.
This indicates an unreleased QP reference leak on the upper layer side (RDS) during connection teardown (rds_shutdown_worker -> rds_ib_conn_path_shutdown).
While RXE forces object cleanup after 50 seconds to prevent a deadlock, the root cause lies in net/rds failing to drop all held QP references prior to calling rdma_destroy_qp(). This needs to be addressed on the RDS layer.
Thanks.
Yanjun Zhu
Quoted 47 lines
Code: f7 be 03 00 00 00 e8 7e 15 e8 fb 40 84 ed 0f 85 26 fe ff ff e9 5b fe ff ff e8 5b 89 cf f8 90 0f 0b 90 eb 09 e8 50 89 cf f8 90 <0f> 0b 90 41 be 92 ff ff ff e9 47 ff ff ff 44 89 f1 80 e1 07 80 c1 RSP: 0018:ffffc9000f2ff6d0 EFLAGS: 00010293 RAX: ffffffff88f888b0 RBX: ffff88807f162250 RCX: ffff888034160000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000001 R08: ffffffff917a757f R09: 1ffffffff22f4eaf R10: dffffc0000000000 R11: fffffbfff22f4eb0 R12: ffff88807e7615a0 R13: 00000000ffffffff R14: 0000000000000000 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff888123abf000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffd5380382c CR3: 000000003558f000 CR4: 0000000000350ef0 Call Trace: <TASK> rxe_destroy_qp+0x74/0x270 drivers/infiniband/sw/rxe/rxe_verbs.c:661 ib_destroy_qp_user+0x354/0x5a0 drivers/infiniband/core/verbs.c:2182 ib_destroy_qp include/rdma/ib_verbs.h:4103 [inline] rdma_destroy_qp+0xd0/0x250 drivers/infiniband/core/cma.c:1170 rds_ib_conn_path_shutdown+0x9bd/0x1820 net/rds/ib_cm.c:1113 rds_conn_shutdown+0x477/0xb20 net/rds/connection.c:440 process_one_work kernel/workqueue.c:3396 [inline] process_scheduled_works+0xc3d/0x1630 kernel/workqueue.c:3479 worker_thread+0xa47/0xfb0 kernel/workqueue.c:3560 kthread+0x38b/0x480 kernel/kthread.c:436 ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 </TASK>---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-titleIf you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-reportIf you want to undo deduplication, reply with:
#syz undup
syzbot
syzbotsyzbot has found a reproducer for the following issue on:
syzbot has found a reproducer for the following issue on:
HEAD commit: a041bdbe1f3a arm64: Drop stdint.h type overrides from asm/.. git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci console output: https://syzkaller.appspot.com/x/log.txt?x=14adccd5580000 kernel config: https://syzkaller.appspot.com/x/.config?x=4e8e6c1701ad8af2 dashboard link: https://syzkaller.appspot.com/bug?extid=fef38133c495aeb48297 compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8 userspace arch: arm64 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14f37403580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11d60153580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ed0e5cdd75d2/disk-a041bdbe.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/219ccd252cd7/vmlinux-a041bdbe.xz
kernel image: https://storage.googleapis.com/syzbot-assets/adb21ff27181/Image-a041bdbe.gz.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
------------[ cut here ]------------ WARNING: drivers/infiniband/sw/rxe/rxe_pool.c:212 at __rxe_cleanup+0x244/0x28c drivers/infiniband/sw/rxe/rxe_pool.c:212, CPU#1: syz.0.17/4954 Modules linked in: CPU: 1 UID: 0 PID: 4954 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026 pstate: 83400005 (Nzcv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--) pc : __rxe_cleanup+0x244/0x28c drivers/infiniband/sw/rxe/rxe_pool.c:212 lr : __rxe_cleanup+0x244/0x28c drivers/infiniband/sw/rxe/rxe_pool.c:212
sp : ffff800098747650
x29: ffff800098747650 x28: 1fffe0001b49bc03 x27: dfff800000000000
x26: ffff8000987476e0 x25: 00000000da70a250 x24: 0000000000000000
x23: dfff800000000000 x22: ffff0000d512d5b0 x21: ffff0000da70a250
x20: 0000000000000000 x19: ffff0000da70a250 x18: 1fffe000359d3e28
x17: 0000000000000003 x16: ffff8000898b7000 x15: ffff80008b586000
x14: 00000000005ab704 x13: 0000000000000001 x12: 0000000000000003
x11: 0000000000000000 x10: 0000000000000001 x9 : 0000000000000000 x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000 x5 : 0000000000000001 x4 : 0000000000000008 x3 : ffff800084641254 x2 : 0000000000000000 x1 : ffff0000d15d0000 x0 : 0000000000000000
Call trace: __rxe_cleanup+0x244/0x28c drivers/infiniband/sw/rxe/rxe_pool.c:212 (P) rxe_destroy_qp+0x80/0x270 drivers/infiniband/sw/rxe/rxe_verbs.c:661 ib_destroy_qp_user+0x2d8/0x548 drivers/infiniband/core/verbs.c:2182 uverbs_free_qp+0xdc/0x188 drivers/infiniband/core/uverbs_std_types_qp.c:34 destroy_hw_idr_uobject+0x90/0x120 drivers/infiniband/core/rdma_core.c:579 uverbs_destroy_uobject+0x23c/0x4f4 drivers/infiniband/core/rdma_core.c:172 __uverbs_cleanup_ufile+0x1e8/0x334 drivers/infiniband/core/rdma_core.c:959 uverbs_destroy_ufile_hw+0x88/0x210 drivers/infiniband/core/uverbs_main.c:1003 ib_uverbs_close+0x54/0x200 drivers/infiniband/core/uverbs_main.c:1018 __fput+0x338/0x74c fs/file_table.c:512 ____fput+0x20/0x30 fs/file_table.c:541 task_work_run+0x1cc/0x25c kernel/task_work.c:233 exit_task_work include/linux/task_work.h:40 [inline] do_exit+0x570/0x1a64 kernel/exit.c:980 do_group_exit+0x198/0x238 kernel/exit.c:1123 __do_sys_exit_group kernel/exit.c:1134 [inline] __se_sys_exit_group kernel/exit.c:1132 [inline] pid_child_should_wake+0x0/0x104 kernel/exit.c:1132 __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline] invoke_syscall+0x98/0x244 arch/arm64/kernel/syscall.c:49 el0_svc_common+0xec/0x23c arch/arm64/kernel/syscall.c:121 do_el0_svc+0x4c/0x5c arch/arm64/kernel/syscall.c:140 el0_svc+0x60/0x1d8 arch/arm64/kernel/entry-common.c:797 el0t_64_sync_handler+0x44/0x104 arch/arm64/kernel/entry-common.c:816 el0t_64_sync+0x198/0x19c arch/arm64/kernel/entry.S:606 irq event stamp: 2998 hardirqs last enabled at (2997): [<ffff80008697a52c>] __raw_spin_unlock_irq include/linux/spinlock_api_smp.h:219 [inline] hardirqs last enabled at (2997): [<ffff80008697a52c>] _raw_spin_unlock_irq+0x30/0x80 kernel/locking/spinlock.c:229 hardirqs last disabled at (2998): [<ffff8000869540f0>] el1_brk64+0x20/0x54 arch/arm64/kernel/entry-common.c:484 softirqs last enabled at (2638): [<ffff8000800204f4>] __do_softirq+0x14/0x20 kernel/softirq.c:703 softirqs last disabled at (1173): [<ffff8000800204f4>] __do_softirq+0x14/0x20 kernel/softirq.c:703 ---[ end trace 0000000000000000 ]---
rxe0: qp#17 rxe_destroy_qp: cleanup failed, err = -110
PATCH 1/1 RDMA/rxe: Don't trust the user space SQ producer index
In reply to syzbotThe 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.
--- drivers/infiniband/sw/rxe/rxe_req.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_req.c +7 -1
@@ -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);
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH rdma-next v1] RDMA/rxe: Don't trust the user space SQ producer index
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] RDMA/rxe: requester and completer SQ index desync on out-of-range prod - [Medium] RDMA/rxe…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] RDMA/rxe: requester and completer SQ index desync on out-of-range prod
- [Medium] RDMA/rxe: unvalidated SQ producer index read in rxe_qp_init_req()
- [Low] RDMA/rxe: wrong Fixes trailer and IB_QPS_ERR loop description --
commit 216db84647f6c90b4699ba426a623f31c2b768e8
Author: Shuai Liu <[email protected]>
Quoted 32 lines
RDMA/rxe: Don't trust the user space SQ producer index
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 butreq_retry()resets it back to the consumer index, and each pass callsrxe_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, soib_destroy_qp()waits for the QP reference to drop until it times out after 50 seconds and theWARN_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 = -110Fix 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_qphangs for 50 seconds and hits the WARNING above; with this patch the reproducer runs cleanly.
Quoted 4 lines
Reported-by [email protected]Fixes 5bcf5a59c41e1 ("RDMA/rxe: Protext kernel index from user space")Signed-off-by Shuai Liu <[email protected]>
[Severity: Low]
Should the Fixes tag point to ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues") instead? In 5bcf5a59c41e ("RDMA/rxe: Protext kernel index from user space"), producer_index() still masked the user-space value with q->index_mask; ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues") replaced producer_index() with queue_get_producer() and dropped that mask.
Also, when qp_state(qp) == IB_QPS_ERR, rxe_requester() jumps directly to
err: or exit: without reaching req_retry(); qp->req.wqe_index wraps back to the consumer index via queue_next_index() at err: because queue_next_index() masks with q->index_mask and never matches the out-of-range prod.
Quoted 18 lines
drivers/infiniband/sw/rxe/rxe_req.c +6
-0@@ -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 ;
drivers/infiniband/sw/rxe/rxe_req.c static struct rxe_send_wqe *__req_next_wqe(struct rxe_qp *qp) · line 200
Quoted 8 lines
drivers/infiniband/sw/rxe/rxe_req.c +1
-1@@ -188,7 +194,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);
[Severity: Medium]
Can treating out-of-range prod as an empty queue here desynchronize qp->req.wqe_index from the completer's consumer index q->index?
queue_empty() in drivers/infiniband/sw/rxe/rxe_queue.h masks the index difference with q->index_mask:
drivers/infiniband/sw/rxe/rxe_queue.h:queue_empty() {
u32 prod = queue_get_producer(q, type);
u32 cons = queue_get_consumer(q, type);
return ((prod - cons) & q->index_mask) == 0;
}When user space writes a producer index where (prod & ~q->index_mask) != 0 and ((prod - cons) & q->index_mask) != 0, __req_next_wqe() treats the queue as empty and leaves qp->req.wqe_index at cons, while rxe_completer() (via get_wqe() or flush_send_queue() -> queue_head() -> queue_empty()) sees a non-empty queue and advances cons to prod & q->index_mask. If user space then writes an in-range prod equal to the new cons, __req_next_wqe() sees index != prod and processes or flushes already-consumed and unposted WQE slots across the ring buffer.
In addition, if WQEs are already in flight (cons != qp->req.wqe_index) when user space sets upper bits in prod, clamping prod = cons in req_retry() rewinds qp->req.wqe_index to cons and qp->req.psn to qp->comp.psn while skipping the retry loop, leaving those in-flight WQEs stuck in wqe_state_pending with exhausted DMA residuals.
Masking prod with q->index_mask in queue_get_producer() for QUEUE_TYPE_FROM_CLIENT (as producer_index() did prior to ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues")) would keep the requester, completer, and queue helpers consistent.
[Severity: Medium]
Does rxe_qp_init_req() also read an unvalidated user producer index into qp->req.wqe_index?
drivers/infiniband/sw/rxe/rxe_qp.c:rxe_qp_init_req() {
...
err = rxe_init_sq(qp, init, udata, uresp);
if (err)
return err;
qp->req.wqe_index = queue_get_producer(qp->sq.queue,
QUEUE_TYPE_FROM_CLIENT);
...
}rxe_init_sq() calls do_mmap_info(), which copies the mmap info to user space and registers it in rxe->pending_mmaps before returning. If user space maps the buffer and writes to q->buf->producer_index before rxe_qp_init_req() reads it, qp->req.wqe_index is initialized to an unvalidated value while the consumer index q->index starts at 0, so a subsequent valid prod == 0 causes __req_next_wqe() to see index != prod and process unposted WQE slots on an empty queue.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH 1/1 RDMA/rxe: Mask the SQ producer index read from user space
In reply to Shuai LiuThe 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() and compares it against its own local index which is always masked.
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 WQEs forever: the flush path advances the WQE index with the masked queue_next_index() but the producer index stays out of range, 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 masking the producer index with q->index_mask when reading it in queue_get_producer() for QUEUE_TYPE_FROM_CLIENT. This restores what producer_index() did before commit ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues") replaced it with queue_get_producer() and dropped the mask, and keeps the requester, the completer and the queue helpers, which all compare the difference of the two indices modulo index_mask, consistent. rxe_qp_init_req() also initializes qp->req.wqe_index from this value so it gets validated as well.
Masking the index in queue_get_producer() instead of checking it at the two requester call sites was suggested by the Sashiko AI review of v1 of this patch.
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.
---
Changes since v1:
- Mask the producer index in queue_get_producer() for QUEUE_TYPE_FROM_CLIENT instead of checking it at the two requester call sites, as suggested by the Sashiko AI review of v1. This also covers rxe_qp_init_req(), which initializes qp->req.wqe_index from the same value, and keeps the requester, the completer and the queue helpers consistent with each other.
- Point Fixes at commit ae6e843fe08d, which dropped the mask that producer_index() had, instead of commit 5bcf5a59c41e.
- Reword the commit message: the flush loop never converges because the WQE index is advanced with the masked queue_next_index() while the producer index stays out of range; the req_retry() reset detail in the v1 description was inaccurate.
- Update the subject to describe the actual mechanism.
drivers/infiniband/sw/rxe/rxe_queue.h | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/sw/rxe/rxe_queue.h +1 -0
@@ -106,6 +106,7 @@ static inline u32 queue_get_producer(const struct rxe_queue *q,case QUEUE_TYPE_FROM_CLIENT :/* used by rxe, client owns the index */ prod =smp_load_acquire (&q->buf->producer_index); + prod &= q->index_mask;break ;case QUEUE_TYPE_TO_CLIENT :/* used by rxe which owns the index */
Signature · 1 line
2.43.0
PATCH v2 1/1 RDMA/rxe: Mask the SQ producer index read from user space
In reply to Shuai LiuThe 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() and compares it against its own local index which is always masked.
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 WQEs forever: the flush path advances the WQE index with the masked queue_next_index() but the producer index stays out of range, 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 masking the producer index with q->index_mask when reading it in queue_get_producer() for QUEUE_TYPE_FROM_CLIENT. This restores what producer_index() did before commit ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues") replaced it with queue_get_producer() and dropped the mask, and keeps the requester, the completer and the queue helpers, which all compare the difference of the two indices modulo index_mask, consistent. rxe_qp_init_req() also initializes qp->req.wqe_index from this value so it gets validated as well.
Masking the index in queue_get_producer() instead of checking it at the two requester call sites was suggested by the Sashiko AI review of v1 of this patch.
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.
---
Changes since v1:
- Mask the producer index in queue_get_producer() for QUEUE_TYPE_FROM_CLIENT instead of checking it at the two requester call sites, as suggested by the Sashiko AI review of v1. This also covers rxe_qp_init_req(), which initializes qp->req.wqe_index from the same value, and keeps the requester, the completer and the queue helpers consistent with each other.
- Point Fixes at commit ae6e843fe08d, which dropped the mask that producer_index() had, instead of commit 5bcf5a59c41e.
- Reword the commit message: the flush loop never converges because the WQE index is advanced with the masked queue_next_index() while the producer index stays out of range; the req_retry() reset detail in the v1 description was inaccurate.
- Update the subject to describe the actual mechanism.
drivers/infiniband/sw/rxe/rxe_queue.h | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/sw/rxe/rxe_queue.h +1 -0
@@ -106,6 +106,7 @@ static inline u32 queue_get_producer(const struct rxe_queue *q,case QUEUE_TYPE_FROM_CLIENT :/* used by rxe, client owns the index */ prod =smp_load_acquire (&q->buf->producer_index); + prod &= q->index_mask;break ;case QUEUE_TYPE_TO_CLIENT :/* used by rxe which owns the index */
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH] RDMA/rxe: Mask the SQ producer index read from user space
In reply to Shuai LiuSashiko has reviewed this patch and found no issues.
Quoted 17 lines
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()and compares it against its own local index which is always masked.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 WQEs forever: the flush path advances the WQE index with the maskedqueue_next_index()but the producer index stays out of range, and each pass callsrxe_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, soib_destroy_qp()waits for the QP [ ... ]
Quoted 4 lines
Reported-by [email protected]Fixes ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues")Signed-off-by Shuai Liu <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH rdma-next v2] RDMA/rxe: Mask the SQ producer index read from user space
In reply to Shuai LiuSashiko has reviewed this patch and found no issues.
Quoted 17 lines
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()and compares it against its own local index which is always masked.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 WQEs forever: the flush path advances the WQE index with the maskedqueue_next_index()but the producer index stays out of range, and each pass callsrxe_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, soib_destroy_qp()waits for the QP [ ... ]
Quoted 4 lines
Reported-by [email protected]Fixes ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues")Signed-off-by Shuai Liu <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH rdma-next v2] RDMA/rxe: Mask the SQ producer index read from user space
In reply to Shuai LiuQuoted 34 lines · Shuai Liu
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()and compares it against its own local index which is always masked.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 WQEs forever: the flush path advances the WQE index with the maskedqueue_next_index()but the producer index stays out of range, and each pass callsrxe_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, soib_destroy_qp()waits for the QP reference to drop until it times out after 50 seconds and theWARN_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 = -110Fix this by masking the producer index with
q->index_maskwhen reading it inqueue_get_producer()forQUEUE_TYPE_FROM_CLIENT. This restores whatproducer_index()did before commitae6e843fe08d("RDMA/rxe: Add memory barriers to kernel queues") replaced it withqueue_get_producer()and dropped the mask, and keeps the requester, the completer and the queue helpers, which all compare the difference of the two indices moduloindex_mask, consistent.rxe_qp_init_req()also initializesqp->req.wqe_indexfrom this value so it gets validated as well.
Quoted 7 lines
Masking the index in
queue_get_producer()instead of checking it at the two requester call sites was suggested by the Sashiko AI review of v1 of this patch.Verified with the syzbot reproducer in QEMU: without this patch every
destroy_qphangs for 50 seconds and hits the WARNING above; with this patch the reproducer runs cleanly.
Thanks for the patch. A couple of questions/comments on this:
The commit message mentions that this fix was verified with the syzbot reproducer in QEMU, but I didn't see any corresponding verification email or test report thread on the list. Could you please share the link/reference to that email or provide a bit more detail on the test setup and baseline kernel used for verification?
In queue_get_producer(), there are also other queue types such as QUEUE_TYPE_TO_CLIENT, QUEUE_TYPE_FROM_ULP, and QUEUE_TYPE_TO_ULP. Have you checked whether any of those types could suffer from a similar out-of-range producer index issue? If so, please let us know and include any necessary fixes (either here or in a follow-up patch, as appropriate).
Thanks a lot.
Yanjun Zhu
Quoted 36 lines
Reported-by [email protected]Fixes ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues")Signed-off-by Shuai Liu <[email protected]>---
Changes since v1:
- Mask the producer index inqueue_get_producer()forQUEUE_TYPE_FROM_CLIENTinstead of checking it at the two requester call sites, as suggested by the Sashiko AI review of v1. This also coversrxe_qp_init_req(), which initializesqp->req.wqe_indexfrom the same value, and keeps the requester, the completer and the queue helpers consistent with each other.
- Point Fixes at commitae6e843fe08d, which dropped the mask thatproducer_index()had, instead of commit5bcf5a59c41e.
- Reword the commit message: the flush loop never converges because the WQE index is advanced with the maskedqueue_next_index()while the producer index stays out of range; thereq_retry()reset detail in the v1 description was inaccurate.
- Update the subject to describe the actual mechanism.drivers/infiniband/sw/rxe/rxe_queue.h | 1 + 1 file changed, 1 insertion(+)drivers/infiniband/sw/rxe/rxe_queue.h +1
-0@@ -106,6 +106,7 @@ static inline u32 queue_get_producer(const struct rxe_queue *q,case QUEUE_TYPE_FROM_CLIENT :/* used by rxe, client owns the index */ prod =smp_load_acquire (&q->buf->producer_index); + prod &= q->index_mask;break ;case QUEUE_TYPE_TO_CLIENT :/* used by rxe which owns the index */
Re: [PATCH rdma-next v2] RDMA/rxe: Mask the SQ producer index read from user space
In reply to a message not in the archiveHi Yanjun,
I tried to use #syz test, but the command is currently disabled for the email interface. See
https://github.com/google/syzkaller/issues/8122
"syzbot: #syz test command is temporarily disabled" (opened 2026-11-11, still open)
and the dashboard silently drops such requests without sending a reply, so there is currently no way to get a syzbot test result for this patch.
For now, the full serial logs of my local verification are attached (gzipped). Both runs use the same kernel and the same syzbot reproducer, only difference is whether the patch is applied:
fix-v2-run10.log.gz
- patched kernel, reproducer bounded to 100 seconds
- zero "rxe_pool.c:212 at __rxe_cleanup" warnings, no BUG/Oops
- "=== REPRO DONE rc=143 ===" and "reboot: Power down"
base-run4.log.gz
- same kernel with this patch reverted, same 100 second bound
- the same WARNING repeats once per reproducer iteration, together with "rxe0: qp#17 rxe_destroy_qp: cleanup failed, err = -110"
I will re-send #syz test on this patch as soon as the command is enabled again and follow up on this thread with the result.
Best regards,
Shuai Liu
Re: [PATCH rdma-next v2] RDMA/rxe: Mask the SQ producer index read from user space
Quoted 21 lines · Shuai Liu
Hi Yanjun,
I tried to use #syz test, but the command is currently disabled for the email interface. See
https://github.com/google/syzkaller/issues/8122
"syzbot:#syz testcommand is temporarily disabled" (opened 2026-11-11, still open)and the dashboard silently drops such requests without sending a reply, so there is currently no way to get a syzbot test result for this patch.
For now, the full serial logs of my local verification are attached (gzipped). Both runs use the same kernel and the same syzbot reproducer, only difference is whether the patch is applied:
fix-v2-run10.log.gz
- patched kernel, reproducer bounded to 100 seconds
- zero "rxe_pool.c:212 at__rxe_cleanup" warnings, no BUG/Oops
- "=== REPRO DONE rc=143 ===" and "reboot: Power down"
Quoted 7 lines
base-run4.log.gz
- same kernel with this patch reverted, same 100 second bound
- the same WARNING repeats once per reproducer iteration, together with "rxe0: qp#17rxe_destroy_qp: cleanup failed, err = -110"I will re-send #syz test on this patch as soon as the command is enabled again and follow up on this thread with the result.
Thanks a lot. I checked the dmesg logs in the attachment. I am fine with this commit.
Zhu Yanjun
Quoted 3 lines
Best regards,
Shuai Liu
Signature · 2 lines
Best Regards, Yanjun.Zhu
Re: [PATCH rdma-next v2] RDMA/rxe: Mask the SQ producer index read from user space
In reply to Shuai LiuQuoted 38 lines · Shuai Liu
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()and compares it against its own local index which is always masked.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 WQEs forever: the flush path advances the WQE index with the maskedqueue_next_index()but the producer index stays out of range, and each pass callsrxe_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, soib_destroy_qp()waits for the QP reference to drop until it times out after 50 seconds and theWARN_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 = -110Fix this by masking the producer index with
q->index_maskwhen reading it inqueue_get_producer()forQUEUE_TYPE_FROM_CLIENT. This restores whatproducer_index()did before commitae6e843fe08d("RDMA/rxe: Add memory barriers to kernel queues") replaced it withqueue_get_producer()and dropped the mask, and keeps the requester, the completer and the queue helpers, which all compare the difference of the two indices moduloindex_mask, consistent.rxe_qp_init_req()also initializesqp->req.wqe_indexfrom this value so it gets validated as well.Masking the index in
queue_get_producer()instead of checking it at the two requester call sites was suggested by the Sashiko AI review of v1 of this patch.
Quoted 8 lines
Verified with the syzbot reproducer in QEMU: without this patch every
destroy_qphangs for 50 seconds and hits the WARNING above; with this patch the reproducer runs cleanly.Reported-by [email protected]Fixes ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues")Signed-off-by Shuai Liu <[email protected]>
Thanks a lot.
Zhu Yanjun
Quoted 31 lines
---
Changes since v1:
- Mask the producer index inqueue_get_producer()forQUEUE_TYPE_FROM_CLIENTinstead of checking it at the two requester call sites, as suggested by the Sashiko AI review of v1. This also coversrxe_qp_init_req(), which initializesqp->req.wqe_indexfrom the same value, and keeps the requester, the completer and the queue helpers consistent with each other.
- Point Fixes at commitae6e843fe08d, which dropped the mask thatproducer_index()had, instead of commit5bcf5a59c41e.
- Reword the commit message: the flush loop never converges because the WQE index is advanced with the maskedqueue_next_index()while the producer index stays out of range; thereq_retry()reset detail in the v1 description was inaccurate.
- Update the subject to describe the actual mechanism.drivers/infiniband/sw/rxe/rxe_queue.h | 1 + 1 file changed, 1 insertion(+)drivers/infiniband/sw/rxe/rxe_queue.h +1
-0@@ -106,6 +106,7 @@ static inline u32 queue_get_producer(const struct rxe_queue *q,case QUEUE_TYPE_FROM_CLIENT :/* used by rxe, client owns the index */ prod =smp_load_acquire (&q->buf->producer_index); + prod &= q->index_mask;break ;case QUEUE_TYPE_TO_CLIENT :/* used by rxe which owns the index */
Signature · 2 lines
Best Regards, Yanjun.Zhu