syzbot


possible deadlock in hci_dev_do_close (2)

Status: auto-closed as invalid on 2022/05/12 19:44
Reported-by: syzbot+bc26aee76044cf5f809e@syzkaller.appspotmail.com
First crash: 1045d, last: 1045d
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in hci_dev_do_close (2) bluetooth C done 10 205d 210d 0/28 auto-obsoleted due to no activity on 2024/06/10 18:42
upstream possible deadlock in hci_dev_do_close bluetooth C done done 6476 337d 425d 0/28 closed as dup on 2024/02/02 20:04
linux-4.14 possible deadlock in hci_dev_do_close 11 1310d 1548d 0/1 auto-closed as invalid on 2021/08/21 08:03
linux-4.14 possible deadlock in hci_dev_do_close (3) 1 751d 751d 0/1 auto-obsoleted due to no activity on 2023/03/03 05:50
linux-5.15 possible deadlock in hci_dev_do_close origin:upstream missing-backport C inconclusive 7636 1h49m 394d 0/3 upstream: reported C repro on 2023/10/25 12:10

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
4.14.262-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/13068 is trying to acquire lock:
 ("%s"hdev->name#2){+.+.}, at: [<ffffffff81367967>] start_flush_work kernel/workqueue.c:2861 [inline]
 ("%s"hdev->name#2){+.+.}, at: [<ffffffff81367967>] flush_work+0x387/0x770 kernel/workqueue.c:2893

but task is already holding lock:
 (&hdev->lock){+.+.}, at: [<ffffffff86612904>] hci_dev_do_close+0x264/0xd80 net/bluetooth/hci_core.c:1628

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&hdev->lock){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
       hci_cc_write_scan_enable net/bluetooth/hci_event.c:375 [inline]
       hci_cmd_complete_evt+0x4d34/0xb490 net/bluetooth/hci_event.c:2831
       hci_event_packet+0x21ce/0x7510 net/bluetooth/hci_event.c:5346
       hci_rx_work+0x427/0xb40 net/bluetooth/hci_core.c:4265
       process_one_work+0x793/0x14a0 kernel/workqueue.c:2117
       worker_thread+0x5cc/0xff0 kernel/workqueue.c:2251
       kthread+0x30d/0x420 kernel/kthread.c:232
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

-> #1 ((&hdev->rx_work)){+.+.}:
       process_one_work+0x736/0x14a0 kernel/workqueue.c:2093
       worker_thread+0x5cc/0xff0 kernel/workqueue.c:2251
       kthread+0x30d/0x420 kernel/kthread.c:232
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

-> #0 ("%s"hdev->name#2){+.+.}:
       lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
       start_flush_work kernel/workqueue.c:2862 [inline]
       flush_work+0x3ac/0x770 kernel/workqueue.c:2893
       __cancel_work_timer+0x321/0x460 kernel/workqueue.c:2965
       hci_conn_del+0x52/0x6f0 net/bluetooth/hci_conn.c:575
       hci_conn_hash_flush+0x19c/0x260 net/bluetooth/hci_conn.c:1394
       hci_dev_do_close+0x57d/0xd80 net/bluetooth/hci_core.c:1641
       hci_unregister_dev+0x143/0x420 net/bluetooth/hci_core.c:3208
       vhci_release+0x70/0xe0 drivers/bluetooth/hci_vhci.c:354
       __fput+0x25f/0x7a0 fs/file_table.c:210
       task_work_run+0x11f/0x190 kernel/task_work.c:113
       exit_task_work include/linux/task_work.h:22 [inline]
       do_exit+0xa44/0x2850 kernel/exit.c:868
       do_group_exit+0x100/0x2e0 kernel/exit.c:965
       get_signal+0x38d/0x1ca0 kernel/signal.c:2412
       do_signal+0x7c/0x1550 arch/x86/kernel/signal.c:792
       exit_to_usermode_loop+0x160/0x200 arch/x86/entry/common.c:160
       prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
       syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
       do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
       entry_SYSCALL_64_after_hwframe+0x46/0xbb

other info that might help us debug this:

Chain exists of:
  "%s"hdev->name#2 --> (&hdev->rx_work) --> &hdev->lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&hdev->lock);
                               lock((&hdev->rx_work));
                               lock(&hdev->lock);
  lock("%s"hdev->name#2);

 *** DEADLOCK ***

2 locks held by syz-executor.0/13068:
 #0:  (&hdev->req_lock){+.+.}, at: [<ffffffff86612748>] hci_dev_do_close+0xa8/0xd80 net/bluetooth/hci_core.c:1589
 #1:  (&hdev->lock){+.+.}, at: [<ffffffff86612904>] hci_dev_do_close+0x264/0xd80 net/bluetooth/hci_core.c:1628

stack backtrace:
CPU: 0 PID: 13068 Comm: syz-executor.0 Not tainted 4.14.262-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x281 lib/dump_stack.c:58
 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1258
 check_prev_add kernel/locking/lockdep.c:1905 [inline]
 check_prevs_add kernel/locking/lockdep.c:2022 [inline]
 validate_chain kernel/locking/lockdep.c:2464 [inline]
 __lock_acquire+0x2e0e/0x3f20 kernel/locking/lockdep.c:3491
 lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
 start_flush_work kernel/workqueue.c:2862 [inline]
 flush_work+0x3ac/0x770 kernel/workqueue.c:2893
 __cancel_work_timer+0x321/0x460 kernel/workqueue.c:2965
 hci_conn_del+0x52/0x6f0 net/bluetooth/hci_conn.c:575
 hci_conn_hash_flush+0x19c/0x260 net/bluetooth/hci_conn.c:1394
 hci_dev_do_close+0x57d/0xd80 net/bluetooth/hci_core.c:1641
 hci_unregister_dev+0x143/0x420 net/bluetooth/hci_core.c:3208
 vhci_release+0x70/0xe0 drivers/bluetooth/hci_vhci.c:354
 __fput+0x25f/0x7a0 fs/file_table.c:210
 task_work_run+0x11f/0x190 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xa44/0x2850 kernel/exit.c:868
 do_group_exit+0x100/0x2e0 kernel/exit.c:965
 get_signal+0x38d/0x1ca0 kernel/signal.c:2412
 do_signal+0x7c/0x1550 arch/x86/kernel/signal.c:792
 exit_to_usermode_loop+0x160/0x200 arch/x86/entry/common.c:160
 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
 do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x7f7d2921eeb9
RSP: 002b:00007f7d27b73218 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007f7d29332038 RCX: 00007f7d2921eeb9
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007f7d29332038
RBP: 00007f7d29332030 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f7d2933203c
R13: 00007ffd85113ccf R14: 00007f7d27b73300 R15: 0000000000022000

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/01/12 19:43 linux-4.14.y 4ba8e26127c3 44d1319a .config console log report info ci2-linux-4-14 possible deadlock in hci_dev_do_close
* Struck through repros no longer work on HEAD.