syzbot


possible deadlock in io_link_timeout_fn

Status: auto-closed as invalid on 2021/06/23 17:59
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+9a512c5bdc15635eab70@syzkaller.appspotmail.com
First crash: 1157d, last: 1156d
Discussions (1)
Title Replies (including bot) Last reply
possible deadlock in io_link_timeout_fn 1 (2) 2021/02/23 13:50

Sample crash report:
========================================================
WARNING: possible irq lock inversion dependency detected
5.11.0-syzkaller #0 Not tainted
--------------------------------------------------------
syz-executor.4/12873 just changed the state of lock:
ffff88806e5ea718 (&ctx->completion_lock){-...}-{2:2}, at: io_link_timeout_fn+0x84/0x700 fs/io_uring.c:6495
but this lock took another, HARDIRQ-unsafe lock in the past:
 (&fs->lock){+.+.}-{2:2}


and interrupts could create inverse lock ordering between them.


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

       CPU0                    CPU1
       ----                    ----
  lock(&fs->lock);
                               local_irq_disable();
                               lock(&ctx->completion_lock);
                               lock(&fs->lock);
  <Interrupt>
    lock(&ctx->completion_lock);

 *** DEADLOCK ***

1 lock held by syz-executor.4/12873:
 #0: ffff88806e5ea128 (&ctx->uring_lock){+.+.}-{3:3}, at: __io_req_task_submit+0x4a/0x1a0 fs/io_uring.c:2341

the shortest dependencies between 2nd lock and 1st lock:
 -> (&fs->lock){+.+.}-{2:2} {
    HARDIRQ-ON-W at:
                      lock_acquire+0x114/0x5f0 kernel/locking/lockdep.c:5510
                      __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
                      _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151
                      spin_lock include/linux/spinlock.h:354 [inline]
                      set_fs_pwd+0x41/0x220 fs/fs_struct.c:39
                      init_chdir+0xe2/0x10b fs/init.c:54
                      devtmpfs_setup+0xa5/0xd4 drivers/base/devtmpfs.c:415
                      devtmpfsd+0x11/0x40 drivers/base/devtmpfs.c:430
                      kthread+0x39a/0x3c0 kernel/kthread.c:292
                      ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
    SOFTIRQ-ON-W at:
                      lock_acquire+0x114/0x5f0 kernel/locking/lockdep.c:5510
                      __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
                      _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151
                      spin_lock include/linux/spinlock.h:354 [inline]
                      set_fs_pwd+0x41/0x220 fs/fs_struct.c:39
                      init_chdir+0xe2/0x10b fs/init.c:54
                      devtmpfs_setup+0xa5/0xd4 drivers/base/devtmpfs.c:415
                      devtmpfsd+0x11/0x40 drivers/base/devtmpfs.c:430
                      kthread+0x39a/0x3c0 kernel/kthread.c:292
                      ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
    INITIAL USE at:
                     lock_acquire+0x114/0x5f0 kernel/locking/lockdep.c:5510
                     __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
                     _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151
                     spin_lock include/linux/spinlock.h:354 [inline]
                     set_fs_pwd+0x41/0x220 fs/fs_struct.c:39
                     init_chdir+0xe2/0x10b fs/init.c:54
                     devtmpfs_setup+0xa5/0xd4 drivers/base/devtmpfs.c:415
                     devtmpfsd+0x11/0x40 drivers/base/devtmpfs.c:430
                     kthread+0x39a/0x3c0 kernel/kthread.c:292
                     ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
  }
  ... key      at: [<ffffffff90006000>] copy_fs_struct.__key+0x0/0x40
  ... acquired at:
   lock_acquire+0x114/0x5f0 kernel/locking/lockdep.c:5510
   __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
   _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:151
   spin_lock include/linux/spinlock.h:354 [inline]
   io_req_clean_work fs/io_uring.c:1405 [inline]
   io_dismantle_req+0x406/0xaa0 fs/io_uring.c:2051
   io_req_complete_post+0xaa/0x530 fs/io_uring.c:1933
   __io_req_complete fs/io_uring.c:1963 [inline]
   io_req_complete fs/io_uring.c:1968 [inline]
   io_cancel_defer_files fs/io_uring.c:8945 [inline]
   io_uring_cancel_task_requests+0xce2/0x1460 fs/io_uring.c:9052
   __io_uring_files_cancel+0x102/0x2c0 fs/io_uring.c:9140
   io_uring_files_cancel include/linux/io_uring.h:65 [inline]
   do_exit+0x289/0x2380 kernel/exit.c:780
   do_group_exit+0x168/0x2d0 kernel/exit.c:922
   get_signal+0x1734/0x1ef0 kernel/signal.c:2773
   arch_do_signal_or_restart+0x3c/0x610 arch/x86/kernel/signal.c:811
   handle_signal_work kernel/entry/common.c:147 [inline]
   exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
   exit_to_user_mode_prepare+0xac/0x1e0 kernel/entry/common.c:208
   __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
   syscall_exit_to_user_mode+0x48/0x180 kernel/entry/common.c:301
   entry_SYSCALL_64_after_hwframe+0x44/0xae

-> (&ctx->completion_lock){-...}-{2:2} {
   IN-HARDIRQ-W at:
                    lock_acquire+0x114/0x5f0 kernel/locking/lockdep.c:5510
                    __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
                    _raw_spin_lock_irqsave+0x73/0xa0 kernel/locking/spinlock.c:159
                    io_link_timeout_fn+0x84/0x700 fs/io_uring.c:6495
                    __run_hrtimer kernel/time/hrtimer.c:1519 [inline]
                    __hrtimer_run_queues+0x4c9/0xa00 kernel/time/hrtimer.c:1583
                    hrtimer_interrupt+0x393/0xf70 kernel/time/hrtimer.c:1645
                    local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1089 [inline]
                    __sysvec_apic_timer_interrupt+0xf9/0x270 arch/x86/kernel/apic/apic.c:1106
                    asm_call_irq_on_stack+0xf/0x20
                    __run_sysvec_on_irqstack arch/x86/include/asm/irq_stack.h:37 [inline]
                    run_sysvec_on_irqstack_cond arch/x86/include/asm/irq_stack.h:89 [inline]
                    sysvec_apic_timer_interrupt+0x9f/0xf0 arch/x86/kernel/apic/apic.c:1100
                    asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:635
                    __raw_spin_unlock_irq include/linux/spinlock_api_smp.h:169 [inline]
                    _raw_spin_unlock_irq+0x25/0x40 kernel/locking/spinlock.c:199
                    spin_unlock_irq include/linux/spinlock.h:404 [inline]
                    io_queue_linked_timeout fs/io_uring.c:6541 [inline]
                    __io_queue_sqe+0xc0b/0x1810 fs/io_uring.c:6607
                    __io_req_task_submit+0x141/0x1a0 fs/io_uring.c:2344
                    __tctx_task_work fs/io_uring.c:2204 [inline]
                    tctx_task_work+0xee/0x280 fs/io_uring.c:2230
                    task_work_run+0x146/0x1c0 kernel/task_work.c:140
                    tracehook_notify_signal include/linux/tracehook.h:212 [inline]
                    handle_signal_work kernel/entry/common.c:145 [inline]
                    exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
                    exit_to_user_mode_prepare+0x9b/0x1e0 kernel/entry/common.c:208
                    __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
                    syscall_exit_to_user_mode+0x48/0x180 kernel/entry/common.c:301
                    entry_SYSCALL_64_after_hwframe+0x44/0xae
   INITIAL USE at:
                   lock_acquire+0x114/0x5f0 kernel/locking/lockdep.c:5510
                   __raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline]
                   _raw_spin_lock_irq+0x6f/0xa0 kernel/locking/spinlock.c:167
                   spin_lock_irq include/linux/spinlock.h:379 [inline]
                   io_req_defer fs/io_uring.c:6197 [inline]
                   io_queue_sqe+0x4f1/0xdf0 fs/io_uring.c:6614
                   io_submit_sqe fs/io_uring.c:6707 [inline]
                   io_submit_sqes+0x1575/0x3060 fs/io_uring.c:6939
                   __do_sys_io_uring_enter fs/io_uring.c:9454 [inline]
                   __se_sys_io_uring_enter+0x1cd/0x1d60 fs/io_uring.c:9397
                   do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
                   entry_SYSCALL_64_after_hwframe+0x44/0xae
 }
 ... key      at: [<ffffffff900079a0>] io_ring_ctx_alloc.__key.123+0x0/0x40
 ... acquired at:
   mark_usage kernel/locking/lockdep.c:4370 [inline]
   __lock_acquire+0xb97/0x5e60 kernel/locking/lockdep.c:4854
   lock_acquire+0x114/0x5f0 kernel/locking/lockdep.c:5510
   __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
   _raw_spin_lock_irqsave+0x73/0xa0 kernel/locking/spinlock.c:159
   io_link_timeout_fn+0x84/0x700 fs/io_uring.c:6495
   __run_hrtimer kernel/time/hrtimer.c:1519 [inline]
   __hrtimer_run_queues+0x4c9/0xa00 kernel/time/hrtimer.c:1583
   hrtimer_interrupt+0x393/0xf70 kernel/time/hrtimer.c:1645
   local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1089 [inline]
   __sysvec_apic_timer_interrupt+0xf9/0x270 arch/x86/kernel/apic/apic.c:1106
   asm_call_irq_on_stack+0xf/0x20
   __run_sysvec_on_irqstack arch/x86/include/asm/irq_stack.h:37 [inline]
   run_sysvec_on_irqstack_cond arch/x86/include/asm/irq_stack.h:89 [inline]
   sysvec_apic_timer_interrupt+0x9f/0xf0 arch/x86/kernel/apic/apic.c:1100
   asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:635
   __raw_spin_unlock_irq include/linux/spinlock_api_smp.h:169 [inline]
   _raw_spin_unlock_irq+0x25/0x40 kernel/locking/spinlock.c:199
   spin_unlock_irq include/linux/spinlock.h:404 [inline]
   io_queue_linked_timeout fs/io_uring.c:6541 [inline]
   __io_queue_sqe+0xc0b/0x1810 fs/io_uring.c:6607
   __io_req_task_submit+0x141/0x1a0 fs/io_uring.c:2344
   __tctx_task_work fs/io_uring.c:2204 [inline]
   tctx_task_work+0xee/0x280 fs/io_uring.c:2230
   task_work_run+0x146/0x1c0 kernel/task_work.c:140
   tracehook_notify_signal include/linux/tracehook.h:212 [inline]
   handle_signal_work kernel/entry/common.c:145 [inline]
   exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
   exit_to_user_mode_prepare+0x9b/0x1e0 kernel/entry/common.c:208
   __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
   syscall_exit_to_user_mode+0x48/0x180 kernel/entry/common.c:301
   entry_SYSCALL_64_after_hwframe+0x44/0xae


stack backtrace:
CPU: 0 PID: 12873 Comm: syz-executor.4 Not tainted 5.11.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x125/0x19e lib/dump_stack.c:120
 print_irq_inversion_bug+0xa93/0xe00 kernel/locking/lockdep.c:3885
 check_usage_forwards kernel/locking/lockdep.c:2480 [inline]
 mark_lock_irq kernel/locking/lockdep.c:4048 [inline]
 mark_lock+0x1120/0x1fe0 kernel/locking/lockdep.c:4478
 mark_usage kernel/locking/lockdep.c:4370 [inline]
 __lock_acquire+0xb97/0x5e60 kernel/locking/lockdep.c:4854
 lock_acquire+0x114/0x5f0 kernel/locking/lockdep.c:5510
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x73/0xa0 kernel/locking/spinlock.c:159
 io_link_timeout_fn+0x84/0x700 fs/io_uring.c:6495
 __run_hrtimer kernel/time/hrtimer.c:1519 [inline]
 __hrtimer_run_queues+0x4c9/0xa00 kernel/time/hrtimer.c:1583
 hrtimer_interrupt+0x393/0xf70 kernel/time/hrtimer.c:1645
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1089 [inline]
 __sysvec_apic_timer_interrupt+0xf9/0x270 arch/x86/kernel/apic/apic.c:1106
 asm_call_irq_on_stack+0xf/0x20
 </IRQ>
 __run_sysvec_on_irqstack arch/x86/include/asm/irq_stack.h:37 [inline]
 run_sysvec_on_irqstack_cond arch/x86/include/asm/irq_stack.h:89 [inline]
 sysvec_apic_timer_interrupt+0x9f/0xf0 arch/x86/kernel/apic/apic.c:1100
 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:635
RIP: 0010:__raw_spin_unlock_irq include/linux/spinlock_api_smp.h:169 [inline]
RIP: 0010:_raw_spin_unlock_irq+0x25/0x40 kernel/locking/spinlock.c:199
Code: f7 eb f5 66 90 53 48 89 fb 48 83 c7 18 48 8b 74 24 08 e8 4e b8 0b f8 48 89 df e8 26 8a 0d f8 e8 31 f1 2d f8 fb bf 01 00 00 00 <e8> 16 d7 01 f8 65 8b 05 db 60 b1 76 85 c0 74 02 5b c3 e8 1b bc af
RSP: 0018:ffffc9000205fd78 EFLAGS: 00000286
RAX: 9b88923734b29500 RBX: ffff88806e5ea700 RCX: ffffffff815c8c5a
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: 0000000000000000 R08: dffffc0000000000 R09: fffffbfff1f288c9
R10: fffffbfff1f288c9 R11: 0000000000000000 R12: 1ffff1100266ce32
R13: ffff888013367140 R14: 0000000000000000 R15: ffff88806e5ea700
 spin_unlock_irq include/linux/spinlock.h:404 [inline]
 io_queue_linked_timeout fs/io_uring.c:6541 [inline]
 __io_queue_sqe+0xc0b/0x1810 fs/io_uring.c:6607
 __io_req_task_submit+0x141/0x1a0 fs/io_uring.c:2344
 __tctx_task_work fs/io_uring.c:2204 [inline]
 tctx_task_work+0xee/0x280 fs/io_uring.c:2230
 task_work_run+0x146/0x1c0 kernel/task_work.c:140
 tracehook_notify_signal include/linux/tracehook.h:212 [inline]
 handle_signal_work kernel/entry/common.c:145 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
 exit_to_user_mode_prepare+0x9b/0x1e0 kernel/entry/common.c:208
 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
 syscall_exit_to_user_mode+0x48/0x180 kernel/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x465ef9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f962090c188 EFLAGS: 00000246 ORIG_RAX: 00000000000001aa
RAX: 0000000000000100 RBX: 000000000056bf60 RCX: 0000000000465ef9
RDX: 0000000000000000 RSI: 0000000000004510 RDI: 0000000000000004
RBP: 00000000004bcd1c R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056bf60
R13: 00007ffdd5c4329f R14: 00007f962090c300 R15: 0000000000022000

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/02/23 17:58 upstream 3b9cdafb5358 fcc6d71b .config console log report info ci-upstream-kasan-gce-smack-root possible deadlock in io_link_timeout_fn
2021/02/22 16:01 upstream 31caf8b2a847 c26fb06b .config console log report info ci-qemu-upstream possible deadlock in io_link_timeout_fn
* Struck through repros no longer work on HEAD.