syzbot


possible deadlock in sco_sock_timeout

Status: auto-obsoleted due to no activity on 2023/02/07 11:14
Subsystems: bluetooth
[Documentation on labels]
Reported-by: syzbot+10c46e34f156f51a28ad@syzkaller.appspotmail.com
First crash: 574d, last: 574d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] possible deadlock in sco_sock_timeout 0 (1) 2022/10/10 11:53
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 possible deadlock in sco_sock_timeout 2 272d 291d 0/3 auto-obsoleted due to no activity on 2023/11/15 21:15
linux-6.1 possible deadlock in sco_sock_timeout (2) 2 29d 29d 0/3 upstream: reported on 2024/04/07 02:01
linux-6.1 possible deadlock in sco_sock_timeout 2 296d 314d 0/3 auto-obsoleted due to no activity on 2023/10/23 03:23

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.0.0-rc7-syzkaller-18095-gbbed346d5a96 #0 Not tainted
------------------------------------------------------
kworker/1:2/31873 is trying to acquire lock:
ffff000115941130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1712 [inline]
ffff000115941130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: sco_sock_timeout+0x88/0x1b8 net/bluetooth/sco.c:97

but task is already holding lock:
ffff8000149abd80 ((work_completion)(&(&conn->timeout_work)->work)){+.+.}-{0:0}, at: process_one_work+0x29c/0x504 kernel/workqueue.c:2264

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 ((work_completion)(&(&conn->timeout_work)->work)){+.+.}-{0:0}:
       __flush_work+0x9c/0x144 kernel/workqueue.c:3069
       __cancel_work_timer+0x1c4/0x2ac kernel/workqueue.c:3160
       cancel_delayed_work_sync+0x24/0x38 kernel/workqueue.c:3301
       sco_conn_del+0x140/0x234 net/bluetooth/sco.c:205
       sco_disconn_cfm+0x64/0xa8 net/bluetooth/sco.c:1379
       hci_disconn_cfm include/net/bluetooth/hci_core.h:1779 [inline]
       hci_conn_hash_flush+0x88/0x148 net/bluetooth/hci_conn.c:2366
       hci_dev_close_sync+0x48c/0x9e0 net/bluetooth/hci_sync.c:4476
       hci_dev_do_close net/bluetooth/hci_core.c:554 [inline]
       hci_error_reset+0xac/0x154 net/bluetooth/hci_core.c:1050
       process_one_work+0x2d8/0x504 kernel/workqueue.c:2289
       worker_thread+0x340/0x610 kernel/workqueue.c:2436
       kthread+0x12c/0x158 kernel/kthread.c:376
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860

-> #2 (hci_cb_list_lock){+.+.}-{3:3}:
       __mutex_lock_common+0xd4/0xca8 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
       hci_connect_cfm include/net/bluetooth/hci_core.h:1761 [inline]
       hci_remote_features_evt+0x274/0x50c net/bluetooth/hci_event.c:3757
       hci_event_func net/bluetooth/hci_event.c:7443 [inline]
       hci_event_packet+0x5c4/0x60c net/bluetooth/hci_event.c:7495
       hci_rx_work+0x1a4/0x2f4 net/bluetooth/hci_core.c:4007
       process_one_work+0x2d8/0x504 kernel/workqueue.c:2289
       worker_thread+0x340/0x610 kernel/workqueue.c:2436
       kthread+0x12c/0x158 kernel/kthread.c:376
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860

-> #1 (&hdev->lock){+.+.}-{3:3}:
       __mutex_lock_common+0xd4/0xca8 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
       sco_sock_connect+0x104/0x220 net/bluetooth/sco.c:593
       __sys_connect_file net/socket.c:1976 [inline]
       __sys_connect+0x184/0x190 net/socket.c:1993
       __do_sys_connect net/socket.c:2003 [inline]
       __se_sys_connect net/socket.c:2000 [inline]
       __arm64_sys_connect+0x28/0x3c net/socket.c:2000
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
       el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
       el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:636
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:654
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #0 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3095 [inline]
       check_prevs_add kernel/locking/lockdep.c:3214 [inline]
       validate_chain kernel/locking/lockdep.c:3829 [inline]
       __lock_acquire+0x1530/0x30a4 kernel/locking/lockdep.c:5053
       lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5666
       lock_sock_nested+0x70/0xd8 net/core/sock.c:3393
       lock_sock include/net/sock.h:1712 [inline]
       sco_sock_timeout+0x88/0x1b8 net/bluetooth/sco.c:97
       process_one_work+0x2d8/0x504 kernel/workqueue.c:2289
       worker_thread+0x340/0x610 kernel/workqueue.c:2436
       kthread+0x12c/0x158 kernel/kthread.c:376
       ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860

other info that might help us debug this:

Chain exists of:
  sk_lock-AF_BLUETOOTH-BTPROTO_SCO --> hci_cb_list_lock --> (work_completion)(&(&conn->timeout_work)->work)

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock((work_completion)(&(&conn->timeout_work)->work));
                               lock(hci_cb_list_lock);
                               lock((work_completion)(&(&conn->timeout_work)->work));
  lock(sk_lock-AF_BLUETOOTH-BTPROTO_SCO);

 *** DEADLOCK ***

2 locks held by kworker/1:2/31873:
 #0: ffff0000c0010738 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x270/0x504 kernel/workqueue.c:2262
 #1: ffff8000149abd80 ((work_completion)(&(&conn->timeout_work)->work)){+.+.}-{0:0}, at: process_one_work+0x29c/0x504 kernel/workqueue.c:2264

stack backtrace:
CPU: 1 PID: 31873 Comm: kworker/1:2 Not tainted 6.0.0-rc7-syzkaller-18095-gbbed346d5a96 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/30/2022
Workqueue: events sco_sock_timeout
Call trace:
 dump_backtrace+0x1c4/0x1f0 arch/arm64/kernel/stacktrace.c:156
 show_stack+0x2c/0x54 arch/arm64/kernel/stacktrace.c:163
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x104/0x16c lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 print_circular_bug+0x2c4/0x2c8 kernel/locking/lockdep.c:2053
 check_noncircular+0x14c/0x154 kernel/locking/lockdep.c:2175
 check_prev_add kernel/locking/lockdep.c:3095 [inline]
 check_prevs_add kernel/locking/lockdep.c:3214 [inline]
 validate_chain kernel/locking/lockdep.c:3829 [inline]
 __lock_acquire+0x1530/0x30a4 kernel/locking/lockdep.c:5053
 lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5666
 lock_sock_nested+0x70/0xd8 net/core/sock.c:3393
 lock_sock include/net/sock.h:1712 [inline]
 sco_sock_timeout+0x88/0x1b8 net/bluetooth/sco.c:97
 process_one_work+0x2d8/0x504 kernel/workqueue.c:2289
 worker_thread+0x340/0x610 kernel/workqueue.c:2436
 kthread+0x12c/0x158 kernel/kthread.c:376
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/10/10 11:13 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 aea5da89 .config console log report info [disk image] [vmlinux] ci-upstream-gce-arm64 possible deadlock in sco_sock_timeout
* Struck through repros no longer work on HEAD.