possible deadlock in hci_dev_reset

7 views
Skip to first unread message

syzbot

unread,
May 10, 2021, 3:26:24 AM5/10/21
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 7d7d1c0a Linux 4.14.232
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=17f55f2dd00000
kernel config: https://syzkaller.appspot.com/x/.config?x=17ee8a0e183900d8
dashboard link: https://syzkaller.appspot.com/bug?extid=b5ec077268f7db74005b

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b5ec07...@syzkaller.appspotmail.com

======================================================
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


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Sep 7, 2021, 3:26:18 AM9/7/21
to syzkaller...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages