[syzbot] INFO: task hung in hci_dev_do_open (2)

12 views
Skip to first unread message

syzbot

unread,
May 14, 2022, 3:17:20 AM5/14/22
to da...@davemloft.net, edum...@google.com, johan....@gmail.com, ku...@kernel.org, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, luiz....@gmail.com, mar...@holtmann.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 38a288f5941e Add linux-next specific files for 20220506
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=10e9fd3ef00000
kernel config: https://syzkaller.appspot.com/x/.config?x=6f4fbf50aa82985b
dashboard link: https://syzkaller.appspot.com/bug?extid=e68a3899a8927b14f863
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=111555fef00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1629b3eaf00000

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

INFO: task kworker/u5:1:3738 blocked for more than 143 seconds.
Not tainted 5.18.0-rc5-next-20220506-syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/u5:1 state:D stack:27952 pid: 3738 ppid: 2 flags:0x00004000
Workqueue: hci0 hci_power_on
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5109 [inline]
__schedule+0xa9a/0x4cc0 kernel/sched/core.c:6424
schedule+0xd2/0x1f0 kernel/sched/core.c:6496
schedule_preempt_disabled+0xf/0x20 kernel/sched/core.c:6555
__mutex_lock_common kernel/locking/mutex.c:679 [inline]
__mutex_lock+0xa70/0x1350 kernel/locking/mutex.c:747
hci_dev_do_open+0x2a/0x70 net/bluetooth/hci_core.c:480
hci_power_on+0x133/0x630 net/bluetooth/hci_core.c:963
process_one_work+0x996/0x1610 kernel/workqueue.c:2289
worker_thread+0x665/0x1080 kernel/workqueue.c:2436
kthread+0x2e9/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
</TASK>
INFO: task syz-executor271:4065 blocked for more than 143 seconds.
Not tainted 5.18.0-rc5-next-20220506-syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz-executor271 state:D stack:27952 pid: 4065 ppid: 3735 flags:0x00004002
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5109 [inline]
__schedule+0xa9a/0x4cc0 kernel/sched/core.c:6424
schedule+0xd2/0x1f0 kernel/sched/core.c:6496
schedule_timeout+0x1db/0x2a0 kernel/time/timer.c:1883
do_wait_for_common kernel/sched/completion.c:85 [inline]
__wait_for_common+0x378/0x530 kernel/sched/completion.c:106
__flush_work+0x56c/0xb10 kernel/workqueue.c:3098
__cancel_work_timer+0x3f9/0x570 kernel/workqueue.c:3185
hci_dev_close_sync+0x8d/0x1150 net/bluetooth/hci_sync.c:4092
hci_dev_do_close+0x32/0x70 net/bluetooth/hci_core.c:553
hci_unregister_dev+0x1c4/0x550 net/bluetooth/hci_core.c:2685
hci_uart_tty_close+0x241/0x2a0 drivers/bluetooth/hci_ldisc.c:548
tty_ldisc_close+0x110/0x190 drivers/tty/tty_ldisc.c:456
tty_ldisc_kill+0x94/0x150 drivers/tty/tty_ldisc.c:608
tty_ldisc_release+0xe1/0x2a0 drivers/tty/tty_ldisc.c:776
tty_release_struct+0x20/0xe0 drivers/tty/tty_io.c:1694
tty_release+0xc70/0x1200 drivers/tty/tty_io.c:1865
__fput+0x277/0x9d0 fs/file_table.c:317
task_work_run+0xdd/0x1a0 kernel/task_work.c:177
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xaff/0x2a00 kernel/exit.c:795
do_group_exit+0xd2/0x2f0 kernel/exit.c:925
__do_sys_exit_group kernel/exit.c:936 [inline]
__se_sys_exit_group kernel/exit.c:934 [inline]
__x64_sys_exit_group+0x3a/0x50 kernel/exit.c:934
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fd7dadc9c69
RSP: 002b:00007ffe0ae022a8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007fd7dae363d0 RCX: 00007fd7dadc9c69
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 00007ffe0ae02320
R10: 00007ffe0ae02320 R11: 0000000000000246 R12: 00007fd7dae363d0
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001
</TASK>

Showing all locks held in the system:
1 lock held by rcu_tasks_kthre/12:
#0: ffffffff8bd84f50 (rcu_tasks.tasks_gp_mutex){+.+.}-{3:3}, at: rcu_tasks_one_gp+0x26/0xc70 kernel/rcu/tasks.h:502
1 lock held by rcu_tasks_trace/13:
#0: ffffffff8bd84bd0 (rcu_tasks_trace.tasks_gp_mutex){+.+.}-{3:3}, at: rcu_tasks_one_gp+0x26/0xc70 kernel/rcu/tasks.h:502
1 lock held by khungtaskd/29:
#0: ffffffff8bd85aa0 (rcu_read_lock){....}-{1:2}, at: debug_show_all_locks+0x53/0x260 kernel/locking/lockdep.c:6491
2 locks held by getty/3366:
#0: ffff888024cd1098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x22/0x80 drivers/tty/tty_ldisc.c:244
#1: ffffc90002ce62e8 (&ldata->atomic_read_lock){+.+.}-{3:3}, at: n_tty_read+0xe50/0x13c0 drivers/tty/n_tty.c:2118
3 locks held by kworker/u5:1/3738:
#0: ffff888019af7138 ((wq_completion)hci0){+.+.}-{0:0}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline]
#0: ffff888019af7138 ((wq_completion)hci0){+.+.}-{0:0}, at: arch_atomic_long_set include/linux/atomic/atomic-long.h:41 [inline]
#0: ffff888019af7138 ((wq_completion)hci0){+.+.}-{0:0}, at: atomic_long_set include/linux/atomic/atomic-instrumented.h:1280 [inline]
#0: ffff888019af7138 ((wq_completion)hci0){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:636 [inline]
#0: ffff888019af7138 ((wq_completion)hci0){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:663 [inline]
#0: ffff888019af7138 ((wq_completion)hci0){+.+.}-{0:0}, at: process_one_work+0x87a/0x1610 kernel/workqueue.c:2260
#1: ffffc9000323fda8 ((work_completion)(&hdev->power_on)){+.+.}-{0:0}, at: process_one_work+0x8ae/0x1610 kernel/workqueue.c:2264
#2: ffff88807ec49048 (&hdev->req_lock){+.+.}-{3:3}, at: hci_dev_do_open+0x2a/0x70 net/bluetooth/hci_core.c:480
3 locks held by syz-executor271/4065:
#0: ffff88801d49b098 (&tty->ldisc_sem){++++}-{0:0}, at: __tty_ldisc_lock drivers/tty/tty_ldisc.c:290 [inline]
#0: ffff88801d49b098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_lock_pair_timeout drivers/tty/tty_ldisc.c:336 [inline]
#0: ffff88801d49b098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_lock_pair drivers/tty/tty_ldisc.c:367 [inline]
#0: ffff88801d49b098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_release+0x15c/0x2a0 drivers/tty/tty_ldisc.c:775
#1: ffff88801d49c098 (&tty->ldisc_sem/1){+.+.}-{0:0}, at: __tty_ldisc_lock_nested drivers/tty/tty_ldisc.c:296 [inline]
#1: ffff88801d49c098 (&tty->ldisc_sem/1){+.+.}-{0:0}, at: tty_ldisc_lock_pair_timeout drivers/tty/tty_ldisc.c:338 [inline]
#1: ffff88801d49c098 (&tty->ldisc_sem/1){+.+.}-{0:0}, at: tty_ldisc_lock_pair drivers/tty/tty_ldisc.c:367 [inline]
#1: ffff88801d49c098 (&tty->ldisc_sem/1){+.+.}-{0:0}, at: tty_ldisc_release+0x20f/0x2a0 drivers/tty/tty_ldisc.c:775
#2: ffff88807ec49048 (&hdev->req_lock){+.+.}-{3:3}, at: hci_dev_do_close+0x2a/0x70 net/bluetooth/hci_core.c:551

=============================================

NMI backtrace for cpu 0
CPU: 0 PID: 29 Comm: khungtaskd Not tainted 5.18.0-rc5-next-20220506-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
nmi_cpu_backtrace.cold+0x47/0x144 lib/nmi_backtrace.c:111
nmi_trigger_cpumask_backtrace+0x1e6/0x230 lib/nmi_backtrace.c:62
trigger_all_cpu_backtrace include/linux/nmi.h:146 [inline]
check_hung_uninterruptible_tasks kernel/hung_task.c:220 [inline]
watchdog+0xc22/0xf90 kernel/hung_task.c:378
kthread+0x2e9/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
</TASK>
Sending NMI from CPU 0 to CPUs 1:
NMI backtrace for cpu 1 skipped: idling at native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline]
NMI backtrace for cpu 1 skipped: idling at arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline]
NMI backtrace for cpu 1 skipped: idling at acpi_safe_halt drivers/acpi/processor_idle.c:111 [inline]
NMI backtrace for cpu 1 skipped: idling at acpi_idle_do_entry+0x1c6/0x250 drivers/acpi/processor_idle.c:554


---
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 can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Hillf Danton

unread,
May 14, 2022, 4:18:35 AM5/14/22
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Sat, 14 May 2022 00:17:18 -0700
hci_dev_do_close hci_power_on
=== ===
hci_req_sync_lock(hdev);
hci_dev_do_open
hci_req_sync_lock(hdev);
hci_dev_close_sync(hdev);
cancel_work_sync(&hdev->power_on);

DEADLOCK

To fix the deadlock, move cancel_work_sync() out of the
req_sync_lock.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/ 38a288f5941e

diff -pur a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
--- a/net/bluetooth/hci_core.c 2022-05-14 15:50:24.949518600 +0800
+++ b/net/bluetooth/hci_core.c 2022-05-14 15:56:36.582294000 +0800
@@ -548,6 +548,7 @@ int hci_dev_do_close(struct hci_dev *hde

BT_DBG("%s %p", hdev->name, hdev);

+ cancel_work_sync(&hdev->power_on);
hci_req_sync_lock(hdev);

err = hci_dev_close_sync(hdev);
@@ -2675,6 +2676,7 @@ void hci_unregister_dev(struct hci_dev *
list_del(&hdev->list);
write_unlock(&hci_dev_list_lock);

+ cancel_work_sync(&hdev->power_on);
hci_cmd_sync_clear(hdev);

if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks))
diff -pur a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
--- a/net/bluetooth/hci_sync.c 2022-05-14 15:50:22.392948600 +0800
+++ b/net/bluetooth/hci_sync.c 2022-05-14 15:54:53.628039700 +0800
@@ -4089,7 +4089,6 @@ int hci_dev_close_sync(struct hci_dev *h

bt_dev_dbg(hdev, "");

- cancel_work_sync(&hdev->power_on);
cancel_delayed_work(&hdev->power_off);
cancel_delayed_work(&hdev->ncmd_timer);

--

syzbot

unread,
May 14, 2022, 4:31:15 AM5/14/22
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: use-after-free Read in hci_cmd_timeout

==================================================================
BUG: KASAN: use-after-free in hci_cmd_timeout+0x24b/0x250 net/bluetooth/hci_core.c:1475
Read of size 2 at addr ffff88807933d408 by task kworker/1:3/145

CPU: 1 PID: 145 Comm: kworker/1:3 Not tainted 5.18.0-rc5-next-20220506-syzkaller-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events hci_cmd_timeout
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
print_report mm/kasan/report.c:429 [inline]
kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
hci_cmd_timeout+0x24b/0x250 net/bluetooth/hci_core.c:1475
process_one_work+0x996/0x1610 kernel/workqueue.c:2289
worker_thread+0x665/0x1080 kernel/workqueue.c:2436
kthread+0x2e9/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
</TASK>

Allocated by task 3681:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
kasan_set_track mm/kasan/common.c:45 [inline]
set_alloc_info mm/kasan/common.c:436 [inline]
____kasan_kmalloc mm/kasan/common.c:515 [inline]
____kasan_kmalloc mm/kasan/common.c:474 [inline]
__kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524
kmalloc include/linux/slab.h:600 [inline]
kzalloc include/linux/slab.h:733 [inline]
fib6_info_alloc+0xc1/0x210 net/ipv6/ip6_fib.c:156
ip6_route_net_init+0x75/0x8c0 net/ipv6/route.c:6465
ops_init+0xaf/0x470 net/core/net_namespace.c:134
setup_net+0x5d1/0xc50 net/core/net_namespace.c:325
copy_net_ns+0x318/0x760 net/core/net_namespace.c:471
create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110
unshare_nsproxy_namespaces+0xc1/0x1f0 kernel/nsproxy.c:226
ksys_unshare+0x445/0x920 kernel/fork.c:3137
__do_sys_unshare kernel/fork.c:3208 [inline]
__se_sys_unshare kernel/fork.c:3206 [inline]
__x64_sys_unshare+0x2d/0x40 kernel/fork.c:3206
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae

Freed by task 48:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
kasan_set_track+0x21/0x30 mm/kasan/common.c:45
kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
____kasan_slab_free mm/kasan/common.c:366 [inline]
____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328
kasan_slab_free include/linux/kasan.h:200 [inline]
slab_free_hook mm/slub.c:1727 [inline]
slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1753
slab_free mm/slub.c:3507 [inline]
kfree+0xd6/0x4d0 mm/slub.c:4555
skb_free_head+0xac/0x110 net/core/skbuff.c:654
skb_release_data+0x67a/0x810 net/core/skbuff.c:676
skb_release_all net/core/skbuff.c:741 [inline]
__kfree_skb net/core/skbuff.c:755 [inline]
kfree_skb_reason.part.0+0xc3/0x2f0 net/core/skbuff.c:775
kfree_skb_reason+0x85/0x110 include/linux/refcount.h:279
kfree_skb include/linux/skbuff.h:1275 [inline]
hci_dev_open_sync+0xb8c/0x2160 net/bluetooth/hci_sync.c:4053
hci_dev_do_open+0x32/0x70 net/bluetooth/hci_core.c:482
hci_power_on+0x133/0x630 net/bluetooth/hci_core.c:964
process_one_work+0x996/0x1610 kernel/workqueue.c:2289
worker_thread+0x665/0x1080 kernel/workqueue.c:2436
kthread+0x2e9/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

The buggy address belongs to the object at ffff88807933d400
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 8 bytes inside of
512-byte region [ffff88807933d400, ffff88807933d600)

The buggy address belongs to the physical page:
page:ffffea0001e4cf00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7933c
head:ffffea0001e4cf00 order:2 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea00006b4900 dead000000000002 ffff888010c41c80
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3049, tgid 3049 (udevadm), ts 15378275467, free_ts 12707670800
prep_new_page mm/page_alloc.c:2431 [inline]
get_page_from_freelist+0xba2/0x3e00 mm/page_alloc.c:4172
__alloc_pages+0x1b2/0x500 mm/page_alloc.c:5393
alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272
alloc_slab_page mm/slub.c:1797 [inline]
allocate_slab+0x26c/0x3c0 mm/slub.c:1942
new_slab mm/slub.c:2002 [inline]
___slab_alloc+0x985/0xd90 mm/slub.c:3002
__slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3089
slab_alloc_node mm/slub.c:3180 [inline]
__kmalloc_node_track_caller+0x2cb/0x360 mm/slub.c:4950
kmalloc_reserve net/core/skbuff.c:353 [inline]
__alloc_skb+0xde/0x340 net/core/skbuff.c:425
alloc_skb include/linux/skbuff.h:1326 [inline]
alloc_uevent_skb+0x7b/0x210 lib/kobject_uevent.c:290
uevent_net_broadcast_untagged lib/kobject_uevent.c:326 [inline]
kobject_uevent_net_broadcast lib/kobject_uevent.c:409 [inline]
kobject_uevent_env+0xc42/0x1660 lib/kobject_uevent.c:593
kobject_synth_uevent+0x701/0x850 lib/kobject_uevent.c:208
uevent_store+0x42/0x90 drivers/base/bus.c:581
drv_attr_store+0x6d/0xa0 drivers/base/bus.c:77
sysfs_kf_write+0x110/0x160 fs/sysfs/file.c:136
kernfs_fop_write_iter+0x3f8/0x610 fs/kernfs/file.c:290
call_write_iter include/linux/fs.h:2045 [inline]
new_sync_write+0x38a/0x560 fs/read_write.c:504
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1346 [inline]
free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1396
free_unref_page_prepare mm/page_alloc.c:3318 [inline]
free_unref_page+0x19/0x6a0 mm/page_alloc.c:3413
free_contig_range+0xb1/0x180 mm/page_alloc.c:9281
destroy_args+0xa8/0x646 mm/debug_vm_pgtable.c:1031
debug_vm_pgtable+0x2a08/0x2a99 mm/debug_vm_pgtable.c:1354
do_one_initcall+0x103/0x650 init/main.c:1301
do_initcall_level init/main.c:1376 [inline]
do_initcalls init/main.c:1392 [inline]
do_basic_setup init/main.c:1411 [inline]
kernel_init_freeable+0x6b1/0x73a init/main.c:1618
kernel_init+0x1a/0x1d0 init/main.c:1507
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Memory state around the buggy address:
ffff88807933d300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88807933d380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807933d400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807933d480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807933d500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: 38a288f5 Add linux-next specific files for 20220506
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/
console output: https://syzkaller.appspot.com/x/log.txt?x=115e78e6f00000
kernel config: https://syzkaller.appspot.com/x/.config?x=6f4fbf50aa82985b
dashboard link: https://syzkaller.appspot.com/bug?extid=e68a3899a8927b14f863
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=165e78e6f00000

Hillf Danton

unread,
May 14, 2022, 7:07:41 AM5/14/22
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Sat, 14 May 2022 01:31:15 -0700
v1, To fix the deadlock, move cancel_work_sync() out of the
req_sync_lock.
v2, To fix uaf, cancel work before freeing skb.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/ 38a288f5941e

diff -pur a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
--- a/net/bluetooth/hci_core.c 2022-05-14 15:50:24.949518600 +0800
+++ b/net/bluetooth/hci_core.c 2022-05-14 15:56:36.582294000 +0800
@@ -548,6 +548,7 @@ int hci_dev_do_close(struct hci_dev *hde

BT_DBG("%s %p", hdev->name, hdev);

+ cancel_work_sync(&hdev->power_on);
hci_req_sync_lock(hdev);

err = hci_dev_close_sync(hdev);
@@ -2675,6 +2676,7 @@ void hci_unregister_dev(struct hci_dev *
list_del(&hdev->list);
write_unlock(&hci_dev_list_lock);

+ cancel_work_sync(&hdev->power_on);
hci_cmd_sync_clear(hdev);

if (!test_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks))
diff -pur a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
--- a/net/bluetooth/hci_sync.c 2022-05-14 15:50:22.392948600 +0800
+++ b/net/bluetooth/hci_sync.c 2022-05-14 18:49:47.178204500 +0800
@@ -4050,6 +4050,7 @@ setup_failed:
hdev->flush(hdev);

if (hdev->sent_cmd) {
+ cancel_delayed_work_sync(&hdev->cmd_timer);
kfree_skb(hdev->sent_cmd);
hdev->sent_cmd = NULL;
}
@@ -4089,7 +4090,6 @@ int hci_dev_close_sync(struct hci_dev *h

syzbot

unread,
May 14, 2022, 7:40:13 AM5/14/22
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+e68a38...@syzkaller.appspotmail.com

Tested on:

commit: 38a288f5 Add linux-next specific files for 20220506
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/
kernel config: https://syzkaller.appspot.com/x/.config?x=6f4fbf50aa82985b
dashboard link: https://syzkaller.appspot.com/bug?extid=e68a3899a8927b14f863
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=10eefe69f00000

Note: testing is done by a robot and is best-effort only.

syzbot

unread,
Jun 22, 2022, 12:37:08 AM6/22/22
to da...@davemloft.net, edum...@google.com, hda...@sina.com, johan....@gmail.com, ku...@kernel.org, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, luiz....@gmail.com, luiz.vo...@intel.com, mar...@holtmann.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit d0b137062b2de75b264b84143d21c98abc5f5ad2
Author: Luiz Augusto von Dentz <luiz.vo...@intel.com>
Date: Wed Oct 27 23:58:59 2021 +0000

Bluetooth: hci_sync: Rework init stages

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1376c63ff00000
start commit: 38a288f5941e Add linux-next specific files for 20220506
git tree: linux-next
final oops: https://syzkaller.appspot.com/x/report.txt?x=10f6c63ff00000
console output: https://syzkaller.appspot.com/x/log.txt?x=1776c63ff00000
Reported-by: syzbot+e68a38...@syzkaller.appspotmail.com
Fixes: d0b137062b2d ("Bluetooth: hci_sync: Rework init stages")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
May 17, 2023, 3:00:36 PM5/17/23
to syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Reply all
Reply to author
Forward
0 new messages