syzbot


possible deadlock in __io_commit_cqring_flush

Status: closed as dup on 2021/11/26 14:28
Reported-by: syzbot+ff49a3059d49b0ca0eec@syzkaller.appspotmail.com
Fix commit: 6af3f48bf615 io_uring: fix link traversal locking
First crash: 377d, last: 375d
Duplicate of (1):
Title Repro Cause bisect Fix bisect Count Last Reported
possible deadlock in io_flush_timeouts 5 376d 377d

Sample crash report:
============================================
WARNING: possible recursive locking detected
5.16.0-rc2-syzkaller #0 Not tainted
--------------------------------------------
syz-executor.2/15350 is trying to acquire lock:
ffff88801d8fa418 (&ctx->timeout_lock){+.+.}-{2:2}, at: spin_lock_irq include/linux/spinlock.h:374 [inline]
ffff88801d8fa418 (&ctx->timeout_lock){+.+.}-{2:2}, at: io_flush_timeouts fs/io_uring.c:1587 [inline]
ffff88801d8fa418 (&ctx->timeout_lock){+.+.}-{2:2}, at: __io_commit_cqring_flush+0x108/0x50d fs/io_uring.c:1618

but task is already holding lock:
ffff88801d8fa418 (&ctx->timeout_lock){+.+.}-{2:2}, at: spin_lock_irq include/linux/spinlock.h:374 [inline]
ffff88801d8fa418 (&ctx->timeout_lock){+.+.}-{2:2}, at: io_poll_remove_all+0x50/0x235 fs/io_uring.c:5702

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&ctx->timeout_lock);
  lock(&ctx->timeout_lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by syz-executor.2/15350:
 #0: ffff88801d8fa3d8 (&ctx->completion_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:349 [inline]
 #0: ffff88801d8fa3d8 (&ctx->completion_lock){+.+.}-{2:2}, at: io_poll_remove_all+0x48/0x235 fs/io_uring.c:5701
 #1: ffff88801d8fa418 (&ctx->timeout_lock){+.+.}-{2:2}, at: spin_lock_irq include/linux/spinlock.h:374 [inline]
 #1: ffff88801d8fa418 (&ctx->timeout_lock){+.+.}-{2:2}, at: io_poll_remove_all+0x50/0x235 fs/io_uring.c:5702

stack backtrace:
CPU: 1 PID: 15350 Comm: syz-executor.2 Not tainted 5.16.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_deadlock_bug kernel/locking/lockdep.c:2956 [inline]
 check_deadlock kernel/locking/lockdep.c:2999 [inline]
 validate_chain kernel/locking/lockdep.c:3788 [inline]
 __lock_acquire.cold+0x149/0x3ab kernel/locking/lockdep.c:5027
 lock_acquire kernel/locking/lockdep.c:5637 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5602
 __raw_spin_lock_irq include/linux/spinlock_api_smp.h:119 [inline]
 _raw_spin_lock_irq+0x32/0x50 kernel/locking/spinlock.c:170
 spin_lock_irq include/linux/spinlock.h:374 [inline]
 io_flush_timeouts fs/io_uring.c:1587 [inline]
 __io_commit_cqring_flush+0x108/0x50d fs/io_uring.c:1618
 io_commit_cqring fs/io_uring.c:1626 [inline]
 io_poll_remove_one fs/io_uring.c:5684 [inline]
 io_poll_remove_one.cold+0xd/0x12 fs/io_uring.c:5674
 io_poll_remove_all+0x1af/0x235 fs/io_uring.c:5709
 io_ring_ctx_wait_and_kill+0x1cc/0x322 fs/io_uring.c:9534
 io_uring_release+0x42/0x46 fs/io_uring.c:9554
 __fput+0x286/0x9f0 fs/file_table.c:280
 task_work_run+0xdd/0x1a0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:175 [inline]
 exit_to_user_mode_prepare+0x27e/0x290 kernel/entry/common.c:207
 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300
 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fc6a7990b32
Code: 00 00 00 00 00 0f 1f 00 41 f7 c1 ff 0f 00 00 75 27 55 48 89 fd 53 89 cb 48 85 ff 74 3b 41 89 da 48 89 ef b8 09 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 66 5b 5d c3 0f 1f 00 48 c7 c0 bc ff ff ff 64
RSP: 002b:00007fc6a4ee50f8 EFLAGS: 00000206 ORIG_RAX: 0000000000000009
RAX: 0000000020ee7000 RBX: 0000000000008011 RCX: 00007fc6a7990b32
RDX: 0000000000000003 RSI: 0000000000020000 RDI: 0000000020ee7000
RBP: 0000000020ee7000 R08: 0000000000000006 R09: 0000000010000000
R10: 0000000000008011 R11: 0000000000000206 R12: 0000000020000040
R13: 0000000020ee7000 R14: 00000000200014c0 R15: 0000000020ffc000
 </TASK>

Crashes (10):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2021/11/28 08:06 upstream 741392771338 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
ci-upstream-kasan-gce-selinux-root 2021/11/28 03:34 upstream 741392771338 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
ci-upstream-kasan-gce-root 2021/11/28 02:25 upstream 741392771338 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
ci-upstream-kasan-gce-root 2021/11/27 19:25 upstream c5c17547b778 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
ci-upstream-kasan-gce-selinux-root 2021/11/27 08:41 upstream c5c17547b778 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
ci-upstream-kasan-gce-selinux-root 2021/11/27 07:24 upstream c5c17547b778 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
ci-upstream-kasan-gce-root 2021/11/27 00:04 upstream c5c17547b778 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
ci-upstream-kasan-gce-root 2021/11/26 12:26 upstream a4849f6000e2 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
ci-upstream-kasan-gce-386 2021/11/27 09:25 upstream c5c17547b778 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
ci-qemu-upstream-386 2021/11/27 09:05 upstream 1bff7d7e8c48 63eeac02 .config log report info possible deadlock in __io_commit_cqring_flush
* Struck through repros no longer work on HEAD.