syzbot


possible deadlock in hci_unregister_dev

Status: upstream: reported on 2022/08/22 09:30
Reported-by: syzbot+c933391d8e4089f1f53e@syzkaller.appspotmail.com
First crash: 103d, last: 7h34m

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc5-syzkaller-00008-ge01d50cbd6ee #0 Not tainted
------------------------------------------------------
syz-executor.5/18824 is trying to acquire lock:
ffff88807cd84a00 ((work_completion)(&(&hdev->discov_off)->work)){+.+.}-{0:0}, at: __flush_work+0xdd/0xae0 kernel/workqueue.c:3066

but task is already holding lock:
ffff88807cd84078 (&hdev->lock){+.+.}-{3:3}, at: hci_unregister_dev+0x347/0x4e0 net/bluetooth/hci_core.c:2707

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&hdev->lock){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x12f/0x1350 kernel/locking/mutex.c:747
       discov_off+0x88/0x1a0 net/bluetooth/mgmt.c:1037
       process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289
       worker_thread+0x665/0x1080 kernel/workqueue.c:2436
       kthread+0x2e4/0x3a0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

-> #0 ((work_completion)(&(&hdev->discov_off)->work)){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain kernel/locking/lockdep.c:3831 [inline]
       __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055
       lock_acquire kernel/locking/lockdep.c:5668 [inline]
       lock_acquire+0x1df/0x630 kernel/locking/lockdep.c:5633
       __flush_work+0x105/0xae0 kernel/workqueue.c:3069
       __cancel_work_timer+0x3f9/0x570 kernel/workqueue.c:3160
       mgmt_index_removed+0x218/0x340 net/bluetooth/mgmt.c:9433
       hci_unregister_dev+0x34f/0x4e0 net/bluetooth/hci_core.c:2708
       vhci_release+0x7c/0xf0 drivers/bluetooth/hci_vhci.c:568
       __fput+0x27c/0xa90 fs/file_table.c:320
       task_work_run+0x16b/0x270 kernel/task_work.c:179
       exit_task_work include/linux/task_work.h:38 [inline]
       do_exit+0xb35/0x2a20 kernel/exit.c:820
       do_group_exit+0xd0/0x2a0 kernel/exit.c:950
       get_signal+0x21a1/0x2430 kernel/signal.c:2858
       arch_do_signal_or_restart+0x82/0x2300 arch/x86/kernel/signal.c:869
       exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
       exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203
       irqentry_exit_to_user_mode+0x5/0x30 kernel/entry/common.c:309
       exc_page_fault+0xbc/0x170 arch/x86/mm/fault.c:1578
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&hdev->lock);
                               lock((work_completion)(&(&hdev->discov_off)->work));
                               lock(&hdev->lock);
  lock((work_completion)(&(&hdev->discov_off)->work));

 *** DEADLOCK ***

1 lock held by syz-executor.5/18824:
 #0: ffff88807cd84078 (&hdev->lock){+.+.}-{3:3}, at: hci_unregister_dev+0x347/0x4e0 net/bluetooth/hci_core.c:2707

stack backtrace:
CPU: 0 PID: 18824 Comm: syz-executor.5 Not tainted 6.1.0-rc5-syzkaller-00008-ge01d50cbd6ee #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain kernel/locking/lockdep.c:3831 [inline]
 __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055
 lock_acquire kernel/locking/lockdep.c:5668 [inline]
 lock_acquire+0x1df/0x630 kernel/locking/lockdep.c:5633
 __flush_work+0x105/0xae0 kernel/workqueue.c:3069
 __cancel_work_timer+0x3f9/0x570 kernel/workqueue.c:3160
 mgmt_index_removed+0x218/0x340 net/bluetooth/mgmt.c:9433
 hci_unregister_dev+0x34f/0x4e0 net/bluetooth/hci_core.c:2708
 vhci_release+0x7c/0xf0 drivers/bluetooth/hci_vhci.c:568
 __fput+0x27c/0xa90 fs/file_table.c:320
 task_work_run+0x16b/0x270 kernel/task_work.c:179
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0xb35/0x2a20 kernel/exit.c:820
 do_group_exit+0xd0/0x2a0 kernel/exit.c:950
 get_signal+0x21a1/0x2430 kernel/signal.c:2858
 arch_do_signal_or_restart+0x82/0x2300 arch/x86/kernel/signal.c:869
 exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
 exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203
 irqentry_exit_to_user_mode+0x5/0x30 kernel/entry/common.c:309
 exc_page_fault+0xbc/0x170 arch/x86/mm/fault.c:1578
 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0033:0x7fa431c8b641
Code: Unable to access opcode bytes at 0x7fa431c8b617.
RSP: 002b:0000000000000030 EFLAGS: 00010217
RAX: 0000000000000000 RBX: 00007fa431dabf80 RCX: 00007fa431c8b639
RDX: 0000000000000000 RSI: 0000000000000030 RDI: 0000000000020000
RBP: 00007fa431ce6ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000
R13: 00007ffcf6902eaf R14: 00007fa4329c3300 R15: 0000000000022000
 </TASK>

Crashes (49):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2022/11/15 10:56 upstream e01d50cbd6ee 97de9cfc .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-smack-root 2022/11/05 18:23 upstream b208b9fbbcba 6d752409 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-selinux-root 2022/11/04 14:43 upstream ee6050c8af96 6d752409 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-smack-root 2022/10/05 09:07 upstream 2bca25eaeba6 eab8f949 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-selinux-root 2022/09/30 08:52 upstream 987a926c1d8a 1d385642 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-smack-root 2022/09/28 16:07 upstream 49c13ed0316d e2556bc3 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-smack-root 2022/09/26 22:31 upstream 3800a713b607 10323ddf .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-root 2022/09/26 11:15 upstream f76349cf4145 d59ba983 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-selinux-root 2022/09/26 03:00 upstream f76349cf4145 0042f2b4 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-root 2022/09/25 14:17 upstream 105a36f3694e 0042f2b4 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-kasan-gce-root 2022/09/25 12:54 upstream 105a36f3694e 0042f2b4 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/11/28 02:16 net 369eb2c9f1f7 74a66371 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/11/25 20:52 net 31d929de5a11 74a66371 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/11/12 17:29 net 9cbd48d5fa14 3ead01ad .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/11/08 21:21 net ce9e57feeed8 060f945e .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/20 21:27 net fa182ea26ff0 a0fd4dab .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/20 21:15 net fa182ea26ff0 a0fd4dab .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/19 05:20 net fa182ea26ff0 b31320fc .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/15 02:32 net fa182ea26ff0 67cb024c .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/14 08:48 net fa182ea26ff0 4954e4b2 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/13 12:05 net fa182ea26ff0 adf90437 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/12 18:38 net 3a732b46736c 89b5a509 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/11 16:14 net 0cf3cae9697b 1353c374 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/11 09:24 net b15e2e49bfc4 2b253ced .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/11 03:20 net b15e2e49bfc4 2b253ced .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/10 12:38 net af7d23f9d96a aea5da89 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/08 08:07 net aabf6155dfb8 0de35f24 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/07 08:34 net 87d1aa8b90d8 8a212197 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/06 10:29 net 1d22f78d0573 131b38ac .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/05 22:11 net 0326074ff465 2c6543ad .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/05 10:47 net 0326074ff465 267e3bb1 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/10/04 09:00 net 93e2be344a7d feb56351 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/09/30 23:06 net 0bafedc53649 feb56351 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-this-kasan-gce 2022/09/30 00:44 net 511cce163b75 1d385642 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/11/29 03:02 net-next c672e3727989 ca9683b8 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/15 01:36 net-next 0326074ff465 67cb024c .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/14 20:53 net-next 0326074ff465 4954e4b2 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/14 06:33 net-next 0326074ff465 4954e4b2 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/12 04:57 net-next 0326074ff465 16a9c9e0 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/11 14:14 net-next 0326074ff465 1353c374 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/10 22:09 net-next 0326074ff465 aea5da89 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/10 20:46 net-next 0326074ff465 aea5da89 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/06 00:48 net-next 0326074ff465 2c6543ad .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/05 09:59 net-next 0326074ff465 267e3bb1 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/05 09:28 net-next 0326074ff465 eab8f949 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/01 22:27 net-next bc37b24ee05e feb56351 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-net-kasan-gce 2022/10/01 04:11 net-next 5fcc2cfc14ae feb56351 .config log report info possible deadlock in hci_unregister_dev
ci-upstream-linux-next-kasan-gce-root 2022/11/08 22:38 linux-next 0cdb3579f1ee 060f945e .config log report info possible deadlock in hci_unregister_dev
ci-upstream-linux-next-kasan-gce-root 2022/08/18 09:21 linux-next 5b6a4bf680d6 d58e263f .config log report info possible deadlock in hci_unregister_dev
* Struck through repros no longer work on HEAD.