syzbot


possible deadlock in hci_dev_reset

Status: auto-closed as invalid on 2021/09/07 07:26
Reported-by: syzbot+b5ec077268f7db74005b@syzkaller.appspotmail.com
First crash: 1293d, last: 1293d

Sample crash report:
======================================================
base_sock_release(ffff888069c6f180) sk=ffff88806f949480
WARNING: possible circular locking dependency detected
4.14.232-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/3390 is trying to acquire lock:
 ("%s"hdev->name#2){+.+.}, at: [<ffffffff81366797>] start_flush_work kernel/workqueue.c:2860 [inline]
 ("%s"hdev->name#2){+.+.}, at: [<ffffffff81366797>] flush_work+0x387/0x770 kernel/workqueue.c:2892

but task is already holding lock:
 (&hdev->lock){+.+.}, at: [<ffffffff866035cc>] hci_dev_do_reset net/bluetooth/hci_core.c:1722 [inline]
 (&hdev->lock){+.+.}, at: [<ffffffff866035cc>] hci_dev_reset+0x12c/0x3a0 net/bluetooth/hci_core.c:1763

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:5330
       hci_rx_work+0x427/0xb40 net/bluetooth/hci_core.c:4246
       process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
       worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
       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:2092
       worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
       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:2861 [inline]
       flush_work+0x3ac/0x770 kernel/workqueue.c:2892
       __cancel_work_timer+0x321/0x460 kernel/workqueue.c:2964
       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_reset net/bluetooth/hci_core.c:1724 [inline]
       hci_dev_reset+0x13c/0x3a0 net/bluetooth/hci_core.c:1763
       hci_sock_ioctl+0x429/0x690 net/bluetooth/hci_sock.c:1023
       sock_do_ioctl net/socket.c:974 [inline]
       sock_ioctl+0x2cc/0x4c0 net/socket.c:1071
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:500 [inline]
       do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
       SYSC_ioctl fs/ioctl.c:701 [inline]
       SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       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/3390:
 #0:  (&hdev->req_lock){+.+.}, at: [<ffffffff86603578>] hci_dev_do_reset net/bluetooth/hci_core.c:1711 [inline]
 #0:  (&hdev->req_lock){+.+.}, at: [<ffffffff86603578>] hci_dev_reset+0xd8/0x3a0 net/bluetooth/hci_core.c:1763
 #1:  (&hdev->lock){+.+.}, at: [<ffffffff866035cc>] hci_dev_do_reset net/bluetooth/hci_core.c:1722 [inline]
 #1:  (&hdev->lock){+.+.}, at: [<ffffffff866035cc>] hci_dev_reset+0x12c/0x3a0 net/bluetooth/hci_core.c:1763

stack backtrace:
CPU: 0 PID: 3390 Comm: syz-executor.0 Not tainted 4.14.232-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:2861 [inline]
 flush_work+0x3ac/0x770 kernel/workqueue.c:2892
 __cancel_work_timer+0x321/0x460 kernel/workqueue.c:2964
 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_reset net/bluetooth/hci_core.c:1724 [inline]
 hci_dev_reset+0x13c/0x3a0 net/bluetooth/hci_core.c:1763
 hci_sock_ioctl+0x429/0x690 net/bluetooth/hci_sock.c:1023
 sock_do_ioctl net/socket.c:974 [inline]
 sock_ioctl+0x2cc/0x4c0 net/socket.c:1071
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x4665f9
RSP: 002b:00007ff33bbd5188 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000056c008 RCX: 00000000004665f9
RDX: 0000000000000000 RSI: 00000000400448cb RDI: 0000000000000005
RBP: 00000000004bfce1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056c008
R13: 00007ffed0ea65af R14: 00007ff33bbd5300 R15: 0000000000022000
base_sock_release(ffff888070658540) sk=ffff88809933f240
base_sock_release(ffff8880778c0140) sk=ffff8880b4438e40
base_sock_release(ffff888068cc7040) sk=ffff88809cadce00
base_sock_release(ffff88806ff8e4c0) sk=ffff8880a2aa8cc0
base_sock_release(ffff88807057e680) sk=ffff888093bae640
base_sock_release(ffff888069761a40) sk=ffff88807348c580
base_sock_release(ffff888069f5fac0) sk=ffff88807ccfe500
base_sock_release(ffff88806ff71080) sk=ffff88809b2e0440
base_sock_release(ffff88806b25a140) sk=ffff88809de70440
base_sock_release(ffff8880745f6ac0) sk=ffff8880ac00aac0
base_sock_release(ffff88807044f4c0) sk=ffff8880762feec0
base_sock_release(ffff88807278b4c0) sk=ffff8880af823680
base_sock_release(ffff88806eb224c0) sk=ffff8880a47254c0
base_sock_release(ffff88807686c0c0) sk=ffff8880815412c0
base_sock_release(ffff888068945a40) sk=ffff88808dbf9100

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/05/10 07:25 linux-4.14.y 7d7d1c0ab3eb bc5434be .config console log report info ci2-linux-4-14 possible deadlock in hci_dev_reset
* Struck through repros no longer work on HEAD.