[syzbot] [bluetooth?] KASAN: slab-use-after-free Read in hci_req_cmd_complete

From: syzbot
Date: Mon Oct 14 2024 - 02:17:38 EST


Hello,

syzbot found the following issue on:

HEAD commit: fc20a3e57247 Merge tag 'for-linus-6.12a-rc2-tag' of git://..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10117380580000
kernel config: https://syzkaller.appspot.com/x/.config?x=ba92623fdea824c9
dashboard link: https://syzkaller.appspot.com/bug?extid=2615eb80cf127508089a
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/dbcdc0af26ea/disk-fc20a3e5.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/0cc74223e92f/vmlinux-fc20a3e5.xz
kernel image: https://storage.googleapis.com/syzbot-assets/ad8cbbe121b2/bzImage-fc20a3e5.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+2615eb80cf127508089a@xxxxxxxxxxxxxxxxxxxxxxxxx

Bluetooth: hci6: unexpected cc 0x1003 length: 249 > 9
Bluetooth: hci6: unexpected cc 0x1001 length: 249 > 9
Bluetooth: hci6: command 0x1005 tx timeout
==================================================================
BUG: KASAN: slab-use-after-free in hci_cmd_data net/bluetooth/hci_core.c:3107 [inline]
BUG: KASAN: slab-use-after-free in hci_sent_cmd_data net/bluetooth/hci_core.c:3124 [inline]
BUG: KASAN: slab-use-after-free in hci_req_cmd_complete+0x85e/0x9c0 net/bluetooth/hci_core.c:3920
Read of size 4 at addr ffff888065bb9930 by task kworker/u9:3/5229

CPU: 1 UID: 0 PID: 5229 Comm: kworker/u9:3 Not tainted 6.12.0-rc1-syzkaller-00330-gfc20a3e57247 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: hci6 hci_rx_work
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:377 [inline]
print_report+0x169/0x550 mm/kasan/report.c:488
kasan_report+0x143/0x180 mm/kasan/report.c:601
hci_cmd_data net/bluetooth/hci_core.c:3107 [inline]
hci_sent_cmd_data net/bluetooth/hci_core.c:3124 [inline]
hci_req_cmd_complete+0x85e/0x9c0 net/bluetooth/hci_core.c:3920
hci_cmd_complete_evt+0x51b/0x8b0 net/bluetooth/hci_event.c:4221
hci_event_func net/bluetooth/hci_event.c:7440 [inline]
hci_event_packet+0xa57/0x1540 net/bluetooth/hci_event.c:7495
hci_rx_work+0x3fe/0xd80 net/bluetooth/hci_core.c:4025
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa65/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f2/0x390 kernel/kthread.c:389
ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
</TASK>

Allocated by task 5229:
kasan_save_stack mm/kasan/common.c:47 [inline]
kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
unpoison_slab_object mm/kasan/common.c:319 [inline]
__kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:345
kasan_slab_alloc include/linux/kasan.h:247 [inline]
slab_post_alloc_hook mm/slub.c:4085 [inline]
slab_alloc_node mm/slub.c:4134 [inline]
kmem_cache_alloc_noprof+0x135/0x2a0 mm/slub.c:4141
skb_clone+0x20c/0x390 net/core/skbuff.c:2084
hci_send_cmd_sync net/bluetooth/hci_core.c:4058 [inline]
hci_cmd_work+0xe7/0x6c0 net/bluetooth/hci_core.c:4094
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa65/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f2/0x390 kernel/kthread.c:389
ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

The buggy address belongs to the object at ffff888065bb98c0
which belongs to the cache skbuff_head_cache of size 240
The buggy address is located 112 bytes inside of
freed 240-byte region [ffff888065bb98c0, ffff888065bb99b0)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x65bb9
memcg:ffff88802fbe5a01
ksm flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000000 ffff88801e6d5000 ffffea0000bea0c0 dead000000000003
raw: 0000000000000000 00000000000c000c 00000001f5000000 ffff88802fbe5a01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 55, tgid 55 (kworker/u9:0), ts 138302256503, free_ts 138190182467
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1537
prep_new_page mm/page_alloc.c:1545 [inline]
get_page_from_freelist+0x3045/0x3190 mm/page_alloc.c:3457
__alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4733
alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
alloc_slab_page+0x6a/0x120 mm/slub.c:2412
allocate_slab+0x5a/0x2f0 mm/slub.c:2578
new_slab mm/slub.c:2631 [inline]
___slab_alloc+0xcd1/0x14b0 mm/slub.c:3818
__slab_alloc+0x58/0xa0 mm/slub.c:3908
__slab_alloc_node mm/slub.c:3961 [inline]
slab_alloc_node mm/slub.c:4122 [inline]
kmem_cache_alloc_noprof+0x1c1/0x2a0 mm/slub.c:4141
skb_clone+0x20c/0x390 net/core/skbuff.c:2084
hci_event_packet+0x227/0x1540 net/bluetooth/hci_event.c:7461
hci_rx_work+0x3fe/0xd80 net/bluetooth/hci_core.c:4025
process_one_work kernel/workqueue.c:3229 [inline]
process_scheduled_works+0xa65/0x1850 kernel/workqueue.c:3310
worker_thread+0x870/0xd30 kernel/workqueue.c:3391
kthread+0x2f2/0x390 kernel/kthread.c:389
ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
page last free pid 5231 tgid 5231 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
free_pages_prepare mm/page_alloc.c:1108 [inline]
free_unref_page+0xcfb/0xf20 mm/page_alloc.c:2638
vfree+0x186/0x2e0 mm/vmalloc.c:3361
kcov_put kernel/kcov.c:439 [inline]
kcov_close+0x28/0x50 kernel/kcov.c:535
__fput+0x241/0x880 fs/file_table.c:431
task_work_run+0x251/0x310 kernel/task_work.c:228
exit_task_work include/linux/task_work.h:40 [inline]
do_exit+0xa2f/0x28e0 kernel/exit.c:939
do_group_exit+0x207/0x2c0 kernel/exit.c:1088
get_signal+0x16a3/0x1740 kernel/signal.c:2917
arch_do_signal_or_restart+0x96/0x860 arch/x86/kernel/signal.c:337
exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
__syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
syscall_exit_to_user_mode+0xc9/0x370 kernel/entry/common.c:218
do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
ffff888065bb9800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
ffff888065bb9880: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff888065bb9900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888065bb9980: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
ffff888065bb9a00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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 syzkaller@xxxxxxxxxxxxxxxx.

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

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

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

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

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