syzbot


possible deadlock in sco_connect_cfm

Status: upstream: reported on 2024/07/20 05:54
Reported-by: syzbot+e5845d1878e6475d83be@syzkaller.appspotmail.com
First crash: 49d, last: 49d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in sco_connect_cfm bluetooth 8 13d 61d 0/27 upstream: reported on 2024/07/08 18:22
linux-5.15 possible deadlock in sco_connect_cfm origin:lts-only C inconclusive 5 50d 117d 0/3 upstream: reported C repro on 2024/05/13 19:57

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.100-syzkaller #0 Not tainted
------------------------------------------------------
kworker/u5:4/3559 is trying to acquire lock:
ffff88805fb4c130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1748 [inline]
ffff88805fb4c130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: sco_conn_ready net/bluetooth/sco.c:1291 [inline]
ffff88805fb4c130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: sco_connect_cfm+0x450/0xb10 net/bluetooth/sco.c:1363

but task is already holding lock:
ffff888073d38220 (&conn->lock#2){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff888073d38220 (&conn->lock#2){+.+.}-{2:2}, at: sco_conn_ready net/bluetooth/sco.c:1278 [inline]
ffff888073d38220 (&conn->lock#2){+.+.}-{2:2}, at: sco_connect_cfm+0x279/0xb10 net/bluetooth/sco.c:1363

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&conn->lock#2){+.+.}-{2:2}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:351 [inline]
       sco_chan_del+0x64/0x1d0 net/bluetooth/sco.c:167
       sco_sock_shutdown+0x160/0x3d0 net/bluetooth/sco.c:1226
       __sys_shutdown_sock net/socket.c:2355 [inline]
       __sys_shutdown net/socket.c:2367 [inline]
       __do_sys_shutdown net/socket.c:2375 [inline]
       __se_sys_shutdown+0x147/0x1a0 net/socket.c:2373
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       lock_sock_nested+0x44/0x100 net/core/sock.c:3485
       lock_sock include/net/sock.h:1748 [inline]
       sco_conn_ready net/bluetooth/sco.c:1291 [inline]
       sco_connect_cfm+0x450/0xb10 net/bluetooth/sco.c:1363
       hci_connect_cfm include/net/bluetooth/hci_core.h:1793 [inline]
       hci_sync_conn_complete_evt+0x54b/0xac0 net/bluetooth/hci_event.c:5107
       hci_event_func net/bluetooth/hci_event.c:7539 [inline]
       hci_event_packet+0xa9d/0x1510 net/bluetooth/hci_event.c:7591
       hci_rx_work+0x3cd/0xce0 net/bluetooth/hci_core.c:4129
       process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
       worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
       kthread+0x28d/0x320 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&conn->lock#2);
                               lock(sk_lock-AF_BLUETOOTH-BTPROTO_SCO);
                               lock(&conn->lock#2);
  lock(sk_lock-AF_BLUETOOTH-BTPROTO_SCO);

 *** DEADLOCK ***

5 locks held by kworker/u5:4/3559:
 #0: ffff8880296b5938 ((wq_completion)hci0#2){+.+.}-{0:0}, at: process_one_work+0x7a9/0x11d0 kernel/workqueue.c:2267
 #1: ffffc9000461fd20 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0}, at: process_one_work+0x7a9/0x11d0 kernel/workqueue.c:2267
 #2: ffff888072d24078 (&hdev->lock){+.+.}-{3:3}, at: hci_sync_conn_complete_evt+0xaa/0xac0 net/bluetooth/hci_event.c:5021
 #3: ffffffff8e3f0f48 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_connect_cfm include/net/bluetooth/hci_core.h:1790 [inline]
 #3: ffffffff8e3f0f48 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_sync_conn_complete_evt+0x4d5/0xac0 net/bluetooth/hci_event.c:5107
 #4: ffff888073d38220 (&conn->lock#2){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #4: ffff888073d38220 (&conn->lock#2){+.+.}-{2:2}, at: sco_conn_ready net/bluetooth/sco.c:1278 [inline]
 #4: ffff888073d38220 (&conn->lock#2){+.+.}-{2:2}, at: sco_connect_cfm+0x279/0xb10 net/bluetooth/sco.c:1363

stack backtrace:
CPU: 1 PID: 3559 Comm: kworker/u5:4 Not tainted 6.1.100-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Workqueue: hci0 hci_rx_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 lock_sock_nested+0x44/0x100 net/core/sock.c:3485
 lock_sock include/net/sock.h:1748 [inline]
 sco_conn_ready net/bluetooth/sco.c:1291 [inline]
 sco_connect_cfm+0x450/0xb10 net/bluetooth/sco.c:1363
 hci_connect_cfm include/net/bluetooth/hci_core.h:1793 [inline]
 hci_sync_conn_complete_evt+0x54b/0xac0 net/bluetooth/hci_event.c:5107
 hci_event_func net/bluetooth/hci_event.c:7539 [inline]
 hci_event_packet+0xa9d/0x1510 net/bluetooth/hci_event.c:7591
 hci_rx_work+0x3cd/0xce0 net/bluetooth/hci_core.c:4129
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>
BUG: sleeping function called from invalid context at net/core/sock.c:3487
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 3559, name: kworker/u5:4
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
INFO: lockdep is turned off.
Preemption disabled at:
[<0000000000000000>] 0x0
CPU: 1 PID: 3559 Comm: kworker/u5:4 Not tainted 6.1.100-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Workqueue: hci0 hci_rx_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 __might_resched+0x5cb/0x780 kernel/sched/core.c:9945
 lock_sock_nested+0x59/0x100 net/core/sock.c:3487
 lock_sock include/net/sock.h:1748 [inline]
 sco_conn_ready net/bluetooth/sco.c:1291 [inline]
 sco_connect_cfm+0x450/0xb10 net/bluetooth/sco.c:1363
 hci_connect_cfm include/net/bluetooth/hci_core.h:1793 [inline]
 hci_sync_conn_complete_evt+0x54b/0xac0 net/bluetooth/hci_event.c:5107
 hci_event_func net/bluetooth/hci_event.c:7539 [inline]
 hci_event_packet+0xa9d/0x1510 net/bluetooth/hci_event.c:7591
 hci_rx_work+0x3cd/0xce0 net/bluetooth/hci_core.c:4129
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>
Bluetooth: hci0: link tx timeout
Bluetooth: hci0: killing stalled connection 11:aa:aa:aa:aa:aa

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/07/20 05:54 linux-6.1.y 9b3f9a5b12dc 890ce4f3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in sco_connect_cfm
* Struck through repros no longer work on HEAD.