syzbot


possible deadlock in free_ioctx_users (2)

Status: fixed on 2020/05/10 10:41
Reported-by: syzbot+832aabf700bc3ec920b9@syzkaller.appspotmail.com
Fix commit: 63f818f46af9 proc: Use a dedicated lock in struct pid
First crash: 1474d, last: 1466d
Cause bisection: introduced by (bisect log) :
commit 7bc3e6e55acf065500a24621f3b313e7e5998acf
Author: Eric W. Biederman <ebiederm@xmission.com>
Date: Thu Feb 20 00:22:26 2020 +0000

  proc: Use a list of inodes to flush from proc

Crash: possible deadlock in free_ioctx_users (log)
Repro: C syz .config
  
Discussions (3)
Title Replies (including bot) Last reply
[GIT PULL] proc fix for 5.7-rc1 2 (2) 2020/04/10 20:40
[PATCH] proc: Use a dedicated lock in struct pid 2 (2) 2020/04/09 08:35
possible deadlock in free_ioctx_users (2) 0 (2) 2020/04/03 06:35
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in free_ioctx_users fuse C 509 1664d 2045d 13/26 fixed on 2019/10/15 23:40
linux-4.19 possible deadlock in free_ioctx_users C done 77 1654d 1777d 1/1 fixed on 2019/12/12 05:11

Sample crash report:
========================================================
WARNING: possible irq lock inversion dependency detected
5.6.0-syzkaller #0 Not tainted
--------------------------------------------------------
swapper/1/0 just changed the state of lock:
ffff8880a243bcd8 (&ctx->ctx_lock){..-.}-{2:2}, at: spin_lock_irq include/linux/spinlock.h:378 [inline]
ffff8880a243bcd8 (&ctx->ctx_lock){..-.}-{2:2}, at: free_ioctx_users+0x2b/0x450 fs/aio.c:618
but this lock took another, SOFTIRQ-unsafe lock in the past:
 (&pid->wait_pidfd){+.+.}-{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(&pid->wait_pidfd);
                               local_irq_disable();
                               lock(&ctx->ctx_lock);
                               lock(&pid->wait_pidfd);
  <Interrupt>
    lock(&ctx->ctx_lock);

 *** DEADLOCK ***

2 locks held by swapper/1/0:
 #0: ffffffff899bc060 (rcu_callback){....}-{0:0}, at: rcu_do_batch kernel/rcu/tree.c:2196 [inline]
 #0: ffffffff899bc060 (rcu_callback){....}-{0:0}, at: rcu_core+0x520/0x1370 kernel/rcu/tree.c:2433
 #1: ffffffff899bc180 (rcu_read_lock){....}-{1:2}, at: percpu_ref_call_confirm_rcu lib/percpu-refcount.c:127 [inline]
 #1: ffffffff899bc180 (rcu_read_lock){....}-{1:2}, at: percpu_ref_switch_to_atomic_rcu+0x209/0x540 lib/percpu-refcount.c:166

the shortest dependencies between 2nd lock and 1st lock:
 -> (&pid->wait_pidfd){+.+.}-{2:2} {
    HARDIRQ-ON-W at:
                      lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4923
                      __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:353 [inline]
                      proc_pid_make_inode+0x1f9/0x3c0 fs/proc/base.c:1880
                      proc_pid_instantiate+0x51/0x150 fs/proc/base.c:3285
                      proc_pid_lookup+0x1da/0x340 fs/proc/base.c:3320
                      proc_root_lookup+0x20/0x60 fs/proc/root.c:243
                      __lookup_slow+0x256/0x490 fs/namei.c:1530
                      lookup_slow fs/namei.c:1547 [inline]
                      walk_component+0x418/0x6a0 fs/namei.c:1846
                      link_path_walk.part.0+0x4f1/0xb50 fs/namei.c:2166
                      link_path_walk fs/namei.c:2098 [inline]
                      path_openat+0x25a/0x27d0 fs/namei.c:3342
                      do_filp_open+0x192/0x260 fs/namei.c:3373
                      do_sys_openat2+0x585/0x7d0 fs/open.c:1148
                      do_sys_open+0xc3/0x140 fs/open.c:1164
                      do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
                      entry_SYSCALL_64_after_hwframe+0x49/0xb3
    SOFTIRQ-ON-W at:
                      lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4923
                      __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:353 [inline]
                      proc_pid_make_inode+0x1f9/0x3c0 fs/proc/base.c:1880
                      proc_pid_instantiate+0x51/0x150 fs/proc/base.c:3285
                      proc_pid_lookup+0x1da/0x340 fs/proc/base.c:3320
                      proc_root_lookup+0x20/0x60 fs/proc/root.c:243
                      __lookup_slow+0x256/0x490 fs/namei.c:1530
                      lookup_slow fs/namei.c:1547 [inline]
                      walk_component+0x418/0x6a0 fs/namei.c:1846
                      link_path_walk.part.0+0x4f1/0xb50 fs/namei.c:2166
                      link_path_walk fs/namei.c:2098 [inline]
                      path_openat+0x25a/0x27d0 fs/namei.c:3342
                      do_filp_open+0x192/0x260 fs/namei.c:3373
                      do_sys_openat2+0x585/0x7d0 fs/open.c:1148
                      do_sys_open+0xc3/0x140 fs/open.c:1164
                      do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
                      entry_SYSCALL_64_after_hwframe+0x49/0xb3
    INITIAL USE at:
                     lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4923
                     __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
                     _raw_spin_lock_irqsave+0x8c/0xbf kernel/locking/spinlock.c:159
                     __wake_up_common_lock+0xb4/0x130 kernel/sched/wait.c:122
                     do_notify_pidfd kernel/signal.c:1900 [inline]
                     do_notify_parent+0x19e/0xe60 kernel/signal.c:1927
                     exit_notify kernel/exit.c:660 [inline]
                     do_exit+0x238f/0x2dd0 kernel/exit.c:816
                     call_usermodehelper_exec_async+0x507/0x710 kernel/umh.c:125
                     ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
  }
  ... key      at: [<ffffffff8bbc62c0>] __key.53831+0x0/0x40
  ... acquired at:
   __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:353 [inline]
   aio_poll fs/aio.c:1767 [inline]
   __io_submit_one fs/aio.c:1841 [inline]
   io_submit_one+0xc1b/0x2ec0 fs/aio.c:1878
   __do_sys_io_submit fs/aio.c:1937 [inline]
   __se_sys_io_submit fs/aio.c:1907 [inline]
   __x64_sys_io_submit+0x1bd/0x540 fs/aio.c:1907
   do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
   entry_SYSCALL_64_after_hwframe+0x49/0xb3

-> (&ctx->ctx_lock){..-.}-{2:2} {
   IN-SOFTIRQ-W at:
                    lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4923
                    __raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline]
                    _raw_spin_lock_irq+0x5b/0x80 kernel/locking/spinlock.c:167
                    spin_lock_irq include/linux/spinlock.h:378 [inline]
                    free_ioctx_users+0x2b/0x450 fs/aio.c:618
                    percpu_ref_put_many include/linux/percpu-refcount.h:309 [inline]
                    percpu_ref_put include/linux/percpu-refcount.h:325 [inline]
                    percpu_ref_call_confirm_rcu lib/percpu-refcount.c:131 [inline]
                    percpu_ref_switch_to_atomic_rcu+0x494/0x540 lib/percpu-refcount.c:166
                    rcu_do_batch kernel/rcu/tree.c:2206 [inline]
                    rcu_core+0x59f/0x1370 kernel/rcu/tree.c:2433
                    __do_softirq+0x26c/0x9f7 kernel/softirq.c:292
                    invoke_softirq kernel/softirq.c:373 [inline]
                    irq_exit+0x192/0x1d0 kernel/softirq.c:413
                    exiting_irq arch/x86/include/asm/apic.h:546 [inline]
                    smp_apic_timer_interrupt+0x19e/0x600 arch/x86/kernel/apic/apic.c:1140
                    apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:829
                    native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:60
                    arch_safe_halt arch/x86/include/asm/paravirt.h:144 [inline]
                    default_idle+0x49/0x350 arch/x86/kernel/process.c:697
                    cpuidle_idle_call kernel/sched/idle.c:154 [inline]
                    do_idle+0x393/0x690 kernel/sched/idle.c:269
                    cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:361
                    start_secondary+0x2f3/0x400 arch/x86/kernel/smpboot.c:268
                    secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:242
   INITIAL USE at:
                   lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4923
                   __raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline]
                   _raw_spin_lock_irq+0x5b/0x80 kernel/locking/spinlock.c:167
                   spin_lock_irq include/linux/spinlock.h:378 [inline]
                   aio_poll fs/aio.c:1765 [inline]
                   __io_submit_one fs/aio.c:1841 [inline]
                   io_submit_one+0xbd6/0x2ec0 fs/aio.c:1878
                   __do_sys_io_submit fs/aio.c:1937 [inline]
                   __se_sys_io_submit fs/aio.c:1907 [inline]
                   __x64_sys_io_submit+0x1bd/0x540 fs/aio.c:1907
                   do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
                   entry_SYSCALL_64_after_hwframe+0x49/0xb3
 }
 ... key      at: [<ffffffff8c682c20>] __key.55314+0x0/0x40
 ... acquired at:
   mark_lock_irq kernel/locking/lockdep.c:3585 [inline]
   mark_lock+0x624/0xf10 kernel/locking/lockdep.c:3935
   mark_usage kernel/locking/lockdep.c:3834 [inline]
   __lock_acquire+0x1d28/0x4e00 kernel/locking/lockdep.c:4298
   lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4923
   __raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline]
   _raw_spin_lock_irq+0x5b/0x80 kernel/locking/spinlock.c:167
   spin_lock_irq include/linux/spinlock.h:378 [inline]
   free_ioctx_users+0x2b/0x450 fs/aio.c:618
   percpu_ref_put_many include/linux/percpu-refcount.h:309 [inline]
   percpu_ref_put include/linux/percpu-refcount.h:325 [inline]
   percpu_ref_call_confirm_rcu lib/percpu-refcount.c:131 [inline]
   percpu_ref_switch_to_atomic_rcu+0x494/0x540 lib/percpu-refcount.c:166
   rcu_do_batch kernel/rcu/tree.c:2206 [inline]
   rcu_core+0x59f/0x1370 kernel/rcu/tree.c:2433
   __do_softirq+0x26c/0x9f7 kernel/softirq.c:292
   invoke_softirq kernel/softirq.c:373 [inline]
   irq_exit+0x192/0x1d0 kernel/softirq.c:413
   exiting_irq arch/x86/include/asm/apic.h:546 [inline]
   smp_apic_timer_interrupt+0x19e/0x600 arch/x86/kernel/apic/apic.c:1140
   apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:829
   native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:60
   arch_safe_halt arch/x86/include/asm/paravirt.h:144 [inline]
   default_idle+0x49/0x350 arch/x86/kernel/process.c:697
   cpuidle_idle_call kernel/sched/idle.c:154 [inline]
   do_idle+0x393/0x690 kernel/sched/idle.c:269
   cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:361
   start_secondary+0x2f3/0x400 arch/x86/kernel/smpboot.c:268
   secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:242


stack backtrace:
CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.6.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:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 print_irq_inversion_bug kernel/locking/lockdep.c:3448 [inline]
 check_usage_forwards.cold+0x20/0x29 kernel/locking/lockdep.c:3472
 mark_lock_irq kernel/locking/lockdep.c:3585 [inline]
 mark_lock+0x624/0xf10 kernel/locking/lockdep.c:3935
 mark_usage kernel/locking/lockdep.c:3834 [inline]
 __lock_acquire+0x1d28/0x4e00 kernel/locking/lockdep.c:4298
 lock_acquire+0x1f2/0x8f0 kernel/locking/lockdep.c:4923
 __raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline]
 _raw_spin_lock_irq+0x5b/0x80 kernel/locking/spinlock.c:167
 spin_lock_irq include/linux/spinlock.h:378 [inline]
 free_ioctx_users+0x2b/0x450 fs/aio.c:618
 percpu_ref_put_many include/linux/percpu-refcount.h:309 [inline]
 percpu_ref_put include/linux/percpu-refcount.h:325 [inline]
 percpu_ref_call_confirm_rcu lib/percpu-refcount.c:131 [inline]
 percpu_ref_switch_to_atomic_rcu+0x494/0x540 lib/percpu-refcount.c:166
 rcu_do_batch kernel/rcu/tree.c:2206 [inline]
 rcu_core+0x59f/0x1370 kernel/rcu/tree.c:2433
 __do_softirq+0x26c/0x9f7 kernel/softirq.c:292
 invoke_softirq kernel/softirq.c:373 [inline]
 irq_exit+0x192/0x1d0 kernel/softirq.c:413
 exiting_irq arch/x86/include/asm/apic.h:546 [inline]
 smp_apic_timer_interrupt+0x19e/0x600 arch/x86/kernel/apic/apic.c:1140
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:829
 </IRQ>
RIP: 0010:native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:61
Code: cc cc cc cc cc cc cc cc cc cc cc cc e9 07 00 00 00 0f 00 2d 84 1e 59 00 f4 c3 66 90 e9 07 00 00 00 0f 00 2d 74 1e 59 00 fb f4 <c3> cc 41 56 41 55 41 54 55 53 e8 83 91 91 f9 e8 ce 2c ca fb 0f 1f
RSP: 0018:ffffc90000d3fdb8 EFLAGS: 00000286 ORIG_RAX: ffffffffffffff13
RAX: 1ffffffff132930f RBX: ffff8880a95f2340 RCX: 0000000000000000
RDX: dffffc0000000000 RSI: 0000000000000006 RDI: ffff8880a95f2c04
RBP: dffffc0000000000 R08: ffff8880a95f2340 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffed10152be468
R13: 0000000000000001 R14: ffffffff8a890cc0 R15: 0000000000000000
 arch_safe_halt arch/x86/include/asm/paravirt.h:144 [inline]
 default_idle+0x49/0x350 arch/x86/kernel/process.c:697
 cpuidle_idle_call kernel/sched/idle.c:154 [inline]
 do_idle+0x393/0x690 kernel/sched/idle.c:269
 cpu_startup_entry+0x14/0x20 kernel/sched/idle.c:361
 start_secondary+0x2f3/0x400 arch/x86/kernel/smpboot.c:268
 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:242

Crashes (44):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/04/10 18:04 upstream c0cc271173b2 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce
2020/04/10 17:34 upstream c0cc271173b2 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce
2020/04/10 14:20 upstream c0cc271173b2 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/10 14:02 upstream c0cc271173b2 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/09 21:37 upstream 5d30bcacd91a a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/09 21:21 upstream 5d30bcacd91a a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/09 11:26 upstream ae46d2aa6a7f a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce
2020/04/09 09:48 upstream ae46d2aa6a7f a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce
2020/04/09 08:27 upstream ae46d2aa6a7f a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/09 08:10 upstream ae46d2aa6a7f a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/09 07:58 upstream ae46d2aa6a7f a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce
2020/04/09 02:36 upstream ae46d2aa6a7f db9bcd4b .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/08 21:56 upstream f5e94d10e4c4 db9bcd4b .config console log report syz C ci-upstream-kasan-gce
2020/04/08 13:23 upstream f5e94d10e4c4 db9bcd4b .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/08 13:07 upstream f5e94d10e4c4 db9bcd4b .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/08 00:49 upstream 763dede1b248 db9bcd4b .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/08 00:32 upstream 763dede1b248 db9bcd4b .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/07 01:05 upstream 7e63420847ae 99a96044 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/07 00:50 upstream 7e63420847ae 99a96044 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/03 15:23 upstream bef7b2a7be28 5ed396e6 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/03 15:06 upstream bef7b2a7be28 5ed396e6 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/03 00:20 upstream 7be97138e727 a34e2c33 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/03 00:06 upstream 7be97138e727 a34e2c33 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/04/10 15:51 upstream c0cc271173b2 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/10 15:30 upstream c0cc271173b2 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/10 10:50 upstream 87ebc45d2d32 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/09 22:45 upstream 87ebc45d2d32 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/09 22:19 upstream 87ebc45d2d32 a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/09 09:43 upstream 5d30bcacd91a a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/09 09:21 upstream 5d30bcacd91a a8c6a3f8 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/09 02:23 upstream ae46d2aa6a7f db9bcd4b .config console log report syz C ci-upstream-kasan-gce-386
2020/04/09 01:59 upstream ae46d2aa6a7f db9bcd4b .config console log report syz C ci-upstream-kasan-gce-386
2020/04/08 13:13 upstream f5e94d10e4c4 db9bcd4b .config console log report syz C ci-upstream-kasan-gce-386
2020/04/08 12:52 upstream f5e94d10e4c4 db9bcd4b .config console log report syz C ci-upstream-kasan-gce-386
2020/04/08 00:45 upstream 763dede1b248 db9bcd4b .config console log report syz C ci-upstream-kasan-gce-386
2020/04/07 09:48 upstream 7e63420847ae 99a96044 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/07 01:08 upstream 7e63420847ae 99a96044 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/07 00:46 upstream 7e63420847ae 99a96044 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/03 14:14 upstream bef7b2a7be28 5ed396e6 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/03 10:09 upstream 7be97138e727 a34e2c33 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/03 00:26 upstream 7be97138e727 a34e2c33 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/03 00:06 upstream 7be97138e727 a34e2c33 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/09 00:39 upstream ae46d2aa6a7f db9bcd4b .config console log report ci-upstream-kasan-gce-smack-root
2020/04/07 21:25 upstream 763dede1b248 db9bcd4b .config console log report ci-upstream-kasan-gce-386
* Struck through repros no longer work on HEAD.