syzbot


possible deadlock in sco_conn_del

Status: upstream: reported C repro on 2022/04/07 22:08
Reported-by: syzbot+b825d87fe2d043e3e652@syzkaller.appspotmail.com
First crash: 303d, last: 2d12h

Cause bisection: introduced by (bisect log) :
commit 92b8aa6d18f7a9ae36a0f71d31742aeef201207a
Author: Ying Hsu <yinghsu@chromium.org>
Date: Sat Mar 26 07:09:28 2022 +0000

  Bluetooth: fix dangling sco_conn and use-after-free in sco_sock_timeout

Crash: possible deadlock in sco_conn_del (log)
Repro: C syz .config
Last patch testing requests:
Created Duration User Patch Repo Result
2022/04/12 01:54 11m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/ d12d7e1cfe38 OK
2022/04/11 23:27 8m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/ d12d7e1cfe38 report log

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.2.0-rc1-syzkaller-00095-ge4cf7c25bae5 #0 Not tainted
------------------------------------------------------
syz-executor112/5101 is trying to acquire lock:
ffff888028432130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1725 [inline]
ffff888028432130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: sco_conn_del+0xfe/0x2f0 net/bluetooth/sco.c:197

but task is already holding lock:
ffffffff8e7be5a8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_disconn_cfm include/net/bluetooth/hci_core.h:1790 [inline]
ffffffff8e7be5a8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_conn_hash_flush+0xb8/0x240 net/bluetooth/hci_conn.c:2427

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (hci_cb_list_lock){+.+.}-{3:3}:
       lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
       __mutex_lock_common+0x1de/0x26c0 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
       hci_connect_cfm include/net/bluetooth/hci_core.h:1775 [inline]
       hci_remote_features_evt+0x610/0xa60 net/bluetooth/hci_event.c:3768
       hci_event_func net/bluetooth/hci_event.c:7482 [inline]
       hci_event_packet+0x842/0x10c0 net/bluetooth/hci_event.c:7534
       hci_rx_work+0x2fc/0x4a0 net/bluetooth/hci_core.c:4043
       process_one_work+0x81c/0xd10 kernel/workqueue.c:2289
       worker_thread+0xb14/0x1330 kernel/workqueue.c:2436
       kthread+0x266/0x300 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

-> #1 (&hdev->lock){+.+.}-{3:3}:
       lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
       __mutex_lock_common+0x1de/0x26c0 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
       sco_sock_connect+0x168/0x350 net/bluetooth/sco.c:593
       __sys_connect_file net/socket.c:1976 [inline]
       __sys_connect+0x29b/0x2d0 net/socket.c:1993
       __do_sys_connect net/socket.c:2003 [inline]
       __se_sys_connect net/socket.c:2000 [inline]
       __x64_sys_connect+0x76/0x80 net/socket.c:2000
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain+0x184a/0x6470 kernel/locking/lockdep.c:3831
       __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
       lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
       lock_sock_nested+0x44/0xf0 net/core/sock.c:3470
       lock_sock include/net/sock.h:1725 [inline]
       sco_conn_del+0xfe/0x2f0 net/bluetooth/sco.c:197
       hci_disconn_cfm include/net/bluetooth/hci_core.h:1793 [inline]
       hci_conn_hash_flush+0x112/0x240 net/bluetooth/hci_conn.c:2427
       hci_dev_close_sync+0x76d/0xd70 net/bluetooth/hci_sync.c:4850
       hci_dev_do_close net/bluetooth/hci_core.c:554 [inline]
       hci_rfkill_set_block+0x123/0x1c0 net/bluetooth/hci_core.c:956
       rfkill_set_block+0x1e7/0x430 net/rfkill/core.c:345
       rfkill_fop_write+0x5fb/0x7b0 net/rfkill/core.c:1286
       vfs_write+0x2e5/0xbb0 fs/read_write.c:582
       ksys_write+0x19b/0x2c0 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

Chain exists of:
  sk_lock-AF_BLUETOOTH-BTPROTO_SCO --> &hdev->lock --> hci_cb_list_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(hci_cb_list_lock);
                               lock(&hdev->lock);
                               lock(hci_cb_list_lock);
  lock(sk_lock-AF_BLUETOOTH-BTPROTO_SCO);

 *** DEADLOCK ***

4 locks held by syz-executor112/5101:
 #0: ffffffff8e914b88 (rfkill_global_mutex){+.+.}-{3:3}, at: rfkill_fop_write+0x1c2/0x7b0 net/rfkill/core.c:1278
 #1: ffff8880228f5028 (&hdev->req_lock){+.+.}-{3:3}, at: hci_dev_do_close net/bluetooth/hci_core.c:552 [inline]
 #1: ffff8880228f5028 (&hdev->req_lock){+.+.}-{3:3}, at: hci_rfkill_set_block+0x11b/0x1c0 net/bluetooth/hci_core.c:956
 #2: ffff8880228f4078 (&hdev->lock){+.+.}-{3:3}, at: hci_dev_close_sync+0x456/0xd70 net/bluetooth/hci_sync.c:4837
 #3: ffffffff8e7be5a8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_disconn_cfm include/net/bluetooth/hci_core.h:1790 [inline]
 #3: ffffffff8e7be5a8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_conn_hash_flush+0xb8/0x240 net/bluetooth/hci_conn.c:2427

stack backtrace:
CPU: 1 PID: 5101 Comm: syz-executor112 Not tainted 6.2.0-rc1-syzkaller-00095-ge4cf7c25bae5 #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+0x1e3/0x2d0 lib/dump_stack.c:106
 check_noncircular+0x2f9/0x3b0 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+0x184a/0x6470 kernel/locking/lockdep.c:3831
 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
 lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
 lock_sock_nested+0x44/0xf0 net/core/sock.c:3470
 lock_sock include/net/sock.h:1725 [inline]
 sco_conn_del+0xfe/0x2f0 net/bluetooth/sco.c:197
 hci_disconn_cfm include/net/bluetooth/hci_core.h:1793 [inline]
 hci_conn_hash_flush+0x112/0x240 net/bluetooth/hci_conn.c:2427
 hci_dev_close_sync+0x76d/0xd70 net/bluetooth/hci_sync.c:4850
 hci_dev_do_close net/bluetooth/hci_core.c:554 [inline]
 hci_rfkill_set_block+0x123/0x1c0 net/bluetooth/hci_core.c:956
 rfkill_set_block+0x1e7/0x430 net/rfkill/core.c:345
 rfkill_fop_write+0x5fb/0x7b0 net/rfkill/core.c:1286
 vfs_write+0x2e5/0xbb0 fs/read_write.c:582
 ksys_write+0x19b/0x2c0 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f85fb012529
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 d1 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd977b92b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f85fb012529
RDX: 0000000000000008 RSI: 0000000020000080 RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000000150 R09: 0000000000000150
R10: 0000000000000150 R11: 0000000000000246 R12: 0000555555ff12b8
R13: 0000000000000011 R14: 00007ffd977b9320 R15: 0000000000000003
 </TASK>

Crashes (241):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-kasan-gce-smack-root 2023/01/01 09:52 upstream e4cf7c25bae5 ab32d508 .config strace log report syz C [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-selinux-root 2022/12/29 03:22 upstream 1b929c02afd3 44712fbc .config strace log report syz C [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2022/11/15 02:35 upstream 094226ad94f4 943f4cb8 .config strace log report syz C [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-root 2022/09/05 19:38 upstream 7e18e42e4b28 922294ab .config strace log report syz C possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2022/08/15 06:29 upstream 7ebfc85e2cd7 8dfcaa3d .config strace log report syz C possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2022/08/07 09:26 upstream 200e340f2196 88e3a122 .config strace log report syz C possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2022/08/05 12:37 upstream 200e340f2196 1c9013ac .config console log report syz C possible deadlock in sco_conn_del
ci-upstream-kasan-gce-root 2022/06/29 08:35 upstream 941e3e791269 496a8536 .config strace log report syz C possible deadlock in sco_conn_del
ci-upstream-kasan-gce-root 2022/06/20 11:22 upstream a111daf0c53a 8f633d84 .config strace log report syz C possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2022/11/19 16:45 linux-next 15f3bff12cf6 5bb70014 .config strace log report syz C [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2022/08/04 01:17 linux-next cb71b93c2dc3 1c9013ac .config strace log report syz C possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2022/04/11 18:50 linux-next d12d7e1cfe38 af01ee7d .config console log report syz C possible deadlock in sco_conn_del
ci-upstream-gce-arm64 2022/10/10 05:52 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 aea5da89 .config console log report syz C [disk image] [vmlinux] possible deadlock in sco_conn_del
ci-upstream-gce-arm64 2022/09/06 07:10 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 85413d1e802e 9dcd38fc .config console log report syz C possible deadlock in sco_conn_del
ci-upstream-kasan-gce-selinux-root 2022/09/04 02:22 upstream d895ec7938c4 28811d0a .config strace log report syz [disk image] [vmlinux] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2023/01/30 04:35 upstream ab072681eabe 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-root 2023/01/28 03:45 upstream 83abd4d4c4be 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-selinux-root 2023/01/26 21:19 upstream 7c46948a6e9c 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-qemu-upstream 2023/01/26 14:48 upstream 7c46948a6e9c 7374c4e5 .config console log report info possible deadlock in sco_conn_del
ci-upstream-kasan-gce-root 2023/01/24 03:09 upstream 7bf70dbb1882 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-root 2023/01/22 04:31 upstream f67144022885 559a440a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-qemu-upstream 2023/01/21 01:49 upstream edc00350d205 7374c4e5 .config console log report info possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2023/01/18 15:25 upstream c1649ec55708 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-selinux-root 2023/01/17 04:40 upstream d532dd102151 a63719e7 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2023/01/11 18:43 upstream 7dd4b804e080 96166539 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2023/01/10 19:23 upstream 40c18f363a08 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-qemu-upstream 2023/01/08 13:27 upstream 9b43a525db12 1dac8c7a .config console log report info possible deadlock in sco_conn_del
ci-upstream-kasan-gce-root 2023/01/06 00:46 upstream 41c03ba9beea 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2023/01/04 23:21 upstream 512dee0c00ad 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2022/12/30 17:45 upstream bff687b3dad6 44712fbc .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2022/12/25 00:23 upstream 72a85e2b0a1e 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-root 2022/12/24 18:05 upstream 72a85e2b0a1e 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-qemu-upstream 2022/12/21 19:03 upstream 7c0846125358 4067838e .config console log report info possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2022/12/21 12:26 upstream b6bb9676f216 4067838e .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-kasan-gce-smack-root 2022/12/17 20:48 upstream 75caf5940899 05494336 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-qemu-upstream 2022/12/16 18:59 upstream 84e57d292203 fcac021f .config console log report info possible deadlock in sco_conn_del
ci-upstream-kasan-gce-root 2022/12/10 04:20 upstream 0d1409e4ff08 67be1ae7 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-qemu-upstream-386 2023/01/28 18:11 upstream 5af6ce704936 7374c4e5 .config console log report info possible deadlock in sco_conn_del
ci-qemu-upstream-386 2023/01/13 17:38 upstream d863f0539b52 529798b0 .config console log report info possible deadlock in sco_conn_del
ci-qemu-upstream-386 2022/12/26 01:30 upstream 1b929c02afd3 9da18ae8 .config console log report info possible deadlock in sco_conn_del
ci-qemu-upstream-386 2022/12/18 09:48 upstream f9ff5644bcc0 05494336 .config console log report info possible deadlock in sco_conn_del
ci-upstream-net-this-kasan-gce 2023/01/23 12:18 net e38553bdc377 44388686 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-this-kasan-gce 2023/01/20 22:51 net 45a919bbb21c 559a440a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-this-kasan-gce 2023/01/17 05:51 net 87b93b678e95 a63719e7 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-this-kasan-gce 2023/01/12 18:54 net ae9dcb91c606 96166539 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-this-kasan-gce 2023/01/09 11:29 net 60ea6f00c57d 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-this-kasan-gce 2023/01/07 18:44 net b4e9b8763e41 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-this-kasan-gce 2022/12/22 11:00 net 609d3bc62305 c692fab1 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-this-kasan-gce 2022/12/22 05:52 net 609d3bc62305 4067838e .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-this-kasan-gce 2022/12/16 13:39 net 32f1002ed485 79e1d513 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-kasan-gce 2023/01/27 09:02 net-next 0313afe8b83a 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-kasan-gce 2023/01/24 00:16 net-next 40e0b0908142 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-kasan-gce 2023/01/16 20:43 net-next 5129bd8e8840 a63719e7 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-kasan-gce 2023/01/09 21:23 net-next fb59bf28cd63 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-kasan-gce 2022/12/31 04:40 net-next c183e6c3ec34 ab32d508 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-net-kasan-gce 2022/12/10 07:11 net-next ce098da1497c 67be1ae7 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2023/01/23 20:27 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2023/01/04 10:27 linux-next c76083fac3ba 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2022/12/26 09:56 linux-next c76083fac3ba 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2022/12/23 06:35 linux-next e45fb347b630 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2022/12/19 06:45 linux-next d650871875b2 05494336 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2022/04/04 03:35 linux-next 696206280c5e 79a2a8fc .config console log report info possible deadlock in sco_conn_del
ci-upstream-linux-next-kasan-gce-root 2022/04/03 22:02 linux-next e5071887cd22 79a2a8fc .config console log report info possible deadlock in sco_conn_del
ci-upstream-gce-arm64 2023/01/24 16:37 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 2e84eedb182e 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-gce-arm64 2023/01/14 13:52 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 9598c377d828 a63719e7 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-gce-arm64 2023/01/06 22:02 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci ae87308093bc 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
ci-upstream-gce-arm64 2022/12/22 23:15 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a5541c0811a0 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in sco_conn_del
* Struck through repros no longer work on HEAD.