Subject: [syzbot] [bluetooth?] BUG: sleeping function called from invalid context in __hci_cmd_sync_sk

From: syzbot <[email-masked]>
Date: Sat, 17 Jun 2023 04:12:47 -0700

Hello,

syzbot found the following issue on:

HEAD commit:    1f6ce8392d6f Add linux-next specific files for 20230613
git tree:       linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=14adff43280000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d103d5f9125e9fe9
dashboard link: https://syzkaller.appspot.com/bug?extid=c715e1bd8dfbcb1ab176
compiler:       gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=11287563280000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14395963280000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/2d9bf45aeae9/disk-1f6ce839.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/e0b03ef83e17/vmlinux-1f6ce839.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b6c21a24174d/bzImage-1f6ce839.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email-masked]

BUG: sleeping function called from invalid context at net/bluetooth/hci_sync.c:166
in_atomic(): 0, irqs_disabled(): 0, non_block: 0, pid: 4430, name: kworker/u5:1
preempt_count: 0, expected: 0
RCU nest depth: 1, expected: 0
4 locks held by kworker/u5:1/4430:
 #0: ffff888020183138 ((wq_completion)hci0#2){+.+.}-{0:0}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:20 [inline]
 #0: ffff888020183138 ((wq_completion)hci0#2){+.+.}-{0:0}, at: raw_atomic64_set include/linux/atomic/atomic-arch-fallback.h:2608 [inline]
 #0: ffff888020183138 ((wq_completion)hci0#2){+.+.}-{0:0}, at: raw_atomic_long_set include/linux/atomic/atomic-long.h:79 [inline]
 #0: ffff888020183138 ((wq_completion)hci0#2){+.+.}-{0:0}, at: atomic_long_set include/linux/atomic/atomic-instrumented.h:3196 [inline]
 #0: ffff888020183138 ((wq_completion)hci0#2){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:675 [inline]
 #0: ffff888020183138 ((wq_completion)hci0#2){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:702 [inline]
 #0: ffff888020183138 ((wq_completion)hci0#2){+.+.}-{0:0}, at: process_one_work+0x8fd/0x16f0 kernel/workqueue.c:2564
 #1: ffffc900057a7db0 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0}, at: process_one_work+0x930/0x16f0 kernel/workqueue.c:2568
 #2: ffff88802b78c078 (&hdev->lock){+.+.}-{3:3}, at: hci_le_create_big_complete_evt+0xe9/0xab0 net/bluetooth/hci_event.c:6947
 #3: ffffffff8c9a2840 (rcu_read_lock){....}-{1:2}, at: hci_le_ev_skb_pull net/bluetooth/hci_event.c:79 [inline]
 #3: ffffffff8c9a2840 (rcu_read_lock){....}-{1:2}, at: hci_le_create_big_complete_evt+0xcc/0xab0 net/bluetooth/hci_event.c:6943
CPU: 0 PID: 4430 Comm: kworker/u5:1 Not tainted 6.4.0-rc6-next-20230613-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023
Workqueue: hci0 hci_rx_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x136/0x150 lib/dump_stack.c:106
 __might_resched+0x358/0x580 kernel/sched/core.c:10188
 __hci_cmd_sync_sk+0x359/0xe30 net/bluetooth/hci_sync.c:166
 __hci_cmd_sync_status_sk+0x45/0x160 net/bluetooth/hci_sync.c:247
 __hci_cmd_sync_status net/bluetooth/hci_sync.c:273 [inline]
 hci_le_terminate_big_sync+0xa4/0xd0 net/bluetooth/hci_sync.c:1671
 hci_le_create_big_complete_evt+0x741/0xab0 net/bluetooth/hci_event.c:6982
 hci_le_meta_evt+0x2bc/0x510 net/bluetooth/hci_event.c:7182
 hci_event_func net/bluetooth/hci_event.c:7512 [inline]
 hci_event_packet+0x641/0xfd0 net/bluetooth/hci_event.c:7567
 hci_rx_work+0xaeb/0x1340 net/bluetooth/hci_core.c:4064
 process_one_work+0xa34/0x16f0 kernel/workqueue.c:2594
 worker_thread+0x67d/0x10c0 kernel/workqueue.c:2745
 kthread+0x344/0x440 kernel/kthread.c:379
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>
------------[ cut here ]------------
Voluntary context switch within RCU read-side critical section!
WARNING: CPU: 0 PID: 4430 at kernel/rcu/tree_plugin.h:320 rcu_note_context_switch+0xbb9/0x1800 kernel/rcu/tree_plugin.h:320
Modules linked in:
CPU: 0 PID: 4430 Comm: kworker/u5:1 Tainted: G        W          6.4.0-rc6-next-20230613-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023
Workqueue: hci0 hci_rx_work
RIP: 0010:rcu_note_context_switch+0xbb9/0x1800 kernel/rcu/tree_plugin.h:320
Code: 1d 44 68 00 4c 8b 4c 24 30 8b 4c 24 28 48 8b 54 24 20 e9 8f 03 00 00 48 c7 c7 c0 32 6e 8a c6 05 10 41 24 0d 01 e8 87 83 dc ff <0f> 0b e9 4c f5 ff ff 81 e5 ff ff ff 7f 0f 84 d7 f6 ff ff 65 48 8b
RSP: 0018:ffffc900057a74c0 EFLAGS: 00010086
RAX: 0000000000000000 RBX: ffff8880b983d340 RCX: 0000000000000000
RDX: ffff88802c40bb80 RSI: ffffffff814bf5f7 RDI: 0000000000000001
RBP: ffff88802c40bb80 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000
R13: ffff88802c40bb80 R14: ffffffff8ea9aff0 R15: ffff8880b983c440
FS:  0000000000000000(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f802b262fc8 CR3: 000000002812e000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 __schedule+0x276/0x5790 kernel/sched/core.c:6609
 schedule+0xde/0x1a0 kernel/sched/core.c:6785
 schedule_timeout+0x14e/0x2b0 kernel/time/timer.c:2167
 __hci_cmd_sync_sk+0xc1d/0xe30 net/bluetooth/hci_sync.c:166
 __hci_cmd_sync_status_sk+0x45/0x160 net/bluetooth/hci_sync.c:247
 __hci_cmd_sync_status net/bluetooth/hci_sync.c:273 [inline]
 hci_le_terminate_big_sync+0xa4/0xd0 net/bluetooth/hci_sync.c:1671
 hci_le_create_big_complete_evt+0x741/0xab0 net/bluetooth/hci_event.c:6982
 hci_le_meta_evt+0x2bc/0x510 net/bluetooth/hci_event.c:7182
 hci_event_func net/bluetooth/hci_event.c:7512 [inline]
 hci_event_packet+0x641/0xfd0 net/bluetooth/hci_event.c:7567
 hci_rx_work+0xaeb/0x1340 net/bluetooth/hci_core.c:4064
 process_one_work+0xa34/0x16f0 kernel/workqueue.c:2594
 worker_thread+0x67d/0x10c0 kernel/workqueue.c:2745
 kthread+0x344/0x440 kernel/kthread.c:379
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>

---
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 [email-masked].

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

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup