syzbot


inconsistent lock state in xa_destroy

Status: fixed on 2020/11/16 12:12
Reported-by: syzbot+cdcbdc0bd42e559b52b9@syzkaller.appspotmail.com
Fix commit: ca6484cd308a io_uring: no need to call xa_destroy() on empty xarray
First crash: 674d, last: 673d

Sample crash report:
================================
WARNING: inconsistent lock state
5.9.0-rc8-next-20201008-syzkaller #0 Not tainted
--------------------------------
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
ksoftirqd/0/9 [HC0[0]:SC1[1]:HE0:SE0] takes:
ffff88801bb5ac18 (&xa->xa_lock#7){+.?.}-{2:2}, at: xa_destroy+0xaa/0x350 lib/xarray.c:2205
{SOFTIRQ-ON-W} state was registered at:
  lock_acquire+0x1f2/0xaa0 kernel/locking/lockdep.c:5419
  __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_uring_add_task_file fs/io_uring.c:8607 [inline]
  io_uring_add_task_file+0x207/0x430 fs/io_uring.c:8590
  io_uring_get_fd fs/io_uring.c:9116 [inline]
  io_uring_create fs/io_uring.c:9280 [inline]
  io_uring_setup+0x2727/0x3660 fs/io_uring.c:9314
  do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
  entry_SYSCALL_64_after_hwframe+0x44/0xa9
irq event stamp: 307741
hardirqs last  enabled at (307740): [<ffffffff8847f0df>] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline]
hardirqs last  enabled at (307740): [<ffffffff8847f0df>] _raw_spin_unlock_irqrestore+0x6f/0x90 kernel/locking/spinlock.c:191
hardirqs last disabled at (307741): [<ffffffff8847f6c9>] __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:108 [inline]
hardirqs last disabled at (307741): [<ffffffff8847f6c9>] _raw_spin_lock_irqsave+0xa9/0xd0 kernel/locking/spinlock.c:159
softirqs last  enabled at (307628): [<ffffffff81472c9f>] run_ksoftirqd kernel/softirq.c:653 [inline]
softirqs last  enabled at (307628): [<ffffffff81472c9f>] run_ksoftirqd+0xcf/0x170 kernel/softirq.c:645
softirqs last disabled at (307633): [<ffffffff81472c9f>] run_ksoftirqd kernel/softirq.c:653 [inline]
softirqs last disabled at (307633): [<ffffffff81472c9f>] run_ksoftirqd+0xcf/0x170 kernel/softirq.c:645

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

       CPU0
       ----
  lock(&xa->xa_lock#7);
  <Interrupt>
    lock(&xa->xa_lock#7);

 *** DEADLOCK ***

1 lock held by ksoftirqd/0/9:
 #0: ffffffff8a554c80 (rcu_callback){....}-{0:0}, at: rcu_do_batch kernel/rcu/tree.c:2474 [inline]
 #0: ffffffff8a554c80 (rcu_callback){....}-{0:0}, at: rcu_core+0x5d8/0x1240 kernel/rcu/tree.c:2718

stack backtrace:
CPU: 0 PID: 9 Comm: ksoftirqd/0 Not tainted 5.9.0-rc8-next-20201008-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x198/0x1fb lib/dump_stack.c:118
 print_usage_bug kernel/locking/lockdep.c:3715 [inline]
 valid_state kernel/locking/lockdep.c:3726 [inline]
 mark_lock_irq kernel/locking/lockdep.c:3929 [inline]
 mark_lock.cold+0x32/0x74 kernel/locking/lockdep.c:4396
 mark_usage kernel/locking/lockdep.c:4281 [inline]
 __lock_acquire+0x118a/0x56d0 kernel/locking/lockdep.c:4771
 lock_acquire+0x1f2/0xaa0 kernel/locking/lockdep.c:5419
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x94/0xd0 kernel/locking/spinlock.c:159
 xa_destroy+0xaa/0x350 lib/xarray.c:2205
 __io_uring_free+0x60/0xc0 fs/io_uring.c:7693
 io_uring_free include/linux/io_uring.h:40 [inline]
 __put_task_struct+0xff/0x3f0 kernel/fork.c:732
 put_task_struct include/linux/sched/task.h:111 [inline]
 delayed_put_task_struct+0x1f6/0x340 kernel/exit.c:172
 rcu_do_batch kernel/rcu/tree.c:2484 [inline]
 rcu_core+0x645/0x1240 kernel/rcu/tree.c:2718
 __do_softirq+0x203/0xab6 kernel/softirq.c:298
 run_ksoftirqd kernel/softirq.c:653 [inline]
 run_ksoftirqd+0xcf/0x170 kernel/softirq.c:645
 smpboot_thread_fn+0x655/0x9e0 kernel/smpboot.c:165
 kthread+0x3af/0x4a0 kernel/kthread.c:292
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296

Crashes (755):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2020/10/09 09:05 linux-next e4fb79c771fb 92390980 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/10/09 04:34 linux-next e4fb79c771fb 92390980 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/10/08 22:02 linux-next e4fb79c771fb 92390980 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/10/08 21:58 linux-next e4fb79c771fb 92390980 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/10/08 21:46 linux-next e4fb79c771fb 92390980 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/10/08 21:18 linux-next e4fb79c771fb 92390980 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/10/08 21:13 linux-next e4fb79c771fb 92390980 .config log report syz C
ci-upstream-linux-next-kasan-gce-root 2020/10/09 10:34 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 10:34 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 09:32 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 08:07 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 07:24 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 06:47 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 06:12 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 05:30 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 04:43 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 04:05 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 03:13 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 03:12 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 01:42 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 01:14 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 00:13 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/09 00:03 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 22:58 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 20:39 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 19:59 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 19:40 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 19:17 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 19:01 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 18:42 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 18:26 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 18:09 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 17:51 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 17:35 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 17:20 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 17:02 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 16:45 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 16:24 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 16:09 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 15:52 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 15:35 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 15:24 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 15:09 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 14:53 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 14:39 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 14:30 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 14:28 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 14:28 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 14:27 linux-next e4fb79c771fb 92390980 .config log report info
ci-upstream-linux-next-kasan-gce-root 2020/10/08 13:57 linux-next e4fb79c771fb 1880b4a9 .config log report info