syzbot


KASAN: use-after-free Read in hci_sock_get_cookie

Status: upstream: reported on 2025/06/27 19:58
Reported-by: syzbot+73145f028c2f7b7e088a@syzkaller.appspotmail.com
First crash: 29d, last: 29d
Similar bugs (3)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in hci_sock_get_cookie 19 1 221d 221d 0/3 auto-obsoleted due to no activity on 2025/03/28 01:01
upstream KASAN: slab-use-after-free Read in hci_sock_get_cookie bluetooth 19 2 444d 451d 0/29 closed as invalid on 2024/06/04 19:11
upstream KASAN: slab-use-after-free Read in hci_sock_get_cookie (2) bluetooth 19 47 75d 402d 0/29 upstream: reported on 2024/06/19 17:02

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in hci_sock_get_cookie+0x41/0x50 net/bluetooth/hci_sock.c:96
Read of size 4 at addr ffff888019e79578 by task syz.5.270/6067

CPU: 1 PID: 6067 Comm: syz.5.270 Not tainted 6.1.142-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x22e lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0xa8/0x220 mm/kasan/report.c:427
 kasan_report+0x10b/0x140 mm/kasan/report.c:531
 hci_sock_get_cookie+0x41/0x50 net/bluetooth/hci_sock.c:96
 mgmt_cmd_status+0x1b1/0x4b0 net/bluetooth/mgmt_util.c:149
 cmd_status_rsp net/bluetooth/mgmt.c:1461 [inline]
 cmd_complete_rsp+0x103/0x190 net/bluetooth/mgmt.c:1481
 mgmt_pending_foreach+0xc1/0x110 net/bluetooth/mgmt_util.c:259
 __mgmt_power_off+0x15c/0x330 net/bluetooth/mgmt.c:9524
 hci_dev_close_sync+0x57c/0xf40 net/bluetooth/hci_sync.c:5184
 hci_dev_do_close net/bluetooth/hci_core.c:510 [inline]
 hci_dev_close+0x102/0x1f0 net/bluetooth/hci_core.c:535
 sock_do_ioctl+0xd3/0x2f0 net/socket.c:1204
 sock_ioctl+0x4ed/0x6e0 net/socket.c:1321
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f326678e929
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f326768f038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f32669b5fa0 RCX: 00007f326678e929
RDX: 0000000000000000 RSI: 00000000400448ca RDI: 0000000000000009
RBP: 00007f3266810b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f32669b5fa0 R15: 00007ffc770de128
 </TASK>

Allocated by task 4667:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x8e/0xa0 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:936 [inline]
 __kmalloc+0xb0/0x240 mm/slab_common.c:949
 kmalloc include/linux/slab.h:568 [inline]
 sk_prot_alloc+0xe7/0x210 net/core/sock.c:2050
 sk_alloc+0x36/0x340 net/core/sock.c:2103
 bt_sock_alloc+0x36/0x130 net/bluetooth/af_bluetooth.c:148
 hci_sock_create+0x9f/0x180 net/bluetooth/hci_sock.c:2142
 bt_sock_create+0x155/0x220 net/bluetooth/af_bluetooth.c:132
 __sock_create+0x4a2/0x940 net/socket.c:1550
 sock_create net/socket.c:1606 [inline]
 __sys_socket_create net/socket.c:1643 [inline]
 __sys_socket+0xc4/0x190 net/socket.c:1671
 __do_sys_socket net/socket.c:1684 [inline]
 __se_sys_socket net/socket.c:1682 [inline]
 __x64_sys_socket+0x76/0x80 net/socket.c:1682
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 6074:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2d/0x50 mm/kasan/generic.c:516
 ____kasan_slab_free+0x126/0x1e0 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook+0x131/0x1a0 mm/slub.c:1750
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0xb6/0x1f0 mm/slub.c:3674
 sk_prot_free net/core/sock.c:2086 [inline]
 __sk_destruct+0x49c/0x630 net/core/sock.c:2172
 sock_put include/net/sock.h:2036 [inline]
 mgmt_pending_free net/bluetooth/mgmt_util.c:307 [inline]
 mgmt_pending_remove+0x13d/0x1a0 net/bluetooth/mgmt_util.c:315
 mgmt_pending_foreach+0xc1/0x110 net/bluetooth/mgmt_util.c:259
 mgmt_index_removed+0x155/0x350 net/bluetooth/mgmt.c:9450
 hci_sock_bind+0xae7/0xec0 net/bluetooth/hci_sock.c:1253
 __sys_bind+0x2f4/0x3f0 net/socket.c:1811
 __do_sys_bind net/socket.c:1822 [inline]
 __se_sys_bind net/socket.c:1820 [inline]
 __x64_sys_bind+0x76/0x80 net/socket.c:1820
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff888019e79000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1400 bytes inside of
 2048-byte region [ffff888019e79000, ffff888019e79800)

The buggy address belongs to the physical page:
page:ffffea0000679e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x19e78
head:ffffea0000679e00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea00016bda00 dead000000000002 ffff888017442000
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 2434713240, free_ts 0
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x173/0x1a0 mm/page_alloc.c:2532
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x1a26/0x1ac0 mm/page_alloc.c:4328
 __alloc_pages+0x1df/0x4e0 mm/page_alloc.c:5614
 alloc_page_interleave+0x24/0x1e0 mm/mempolicy.c:2115
 alloc_slab_page+0x5d/0x160 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x87/0x2c0 mm/slub.c:1992
 ___slab_alloc+0xbc6/0x1220 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x1a0/0x260 mm/slub.c:3437
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 dmi_id_init+0xb0/0x19f drivers/firmware/dmi-id.c:239
 do_one_initcall+0x214/0x7a0 init/main.c:1298
 do_initcall_level+0x137/0x1e4 init/main.c:1371
 do_initcalls+0x4b/0x8a init/main.c:1387
 kernel_init_freeable+0x3fa/0x5ac init/main.c:1626
 kernel_init+0x19/0x1b0 init/main.c:1514
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888019e79400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888019e79480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888019e79500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff888019e79580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888019e79600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/06/27 19:58 linux-6.1.y 7e69c33e4858 803ce19b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in hci_sock_get_cookie
* Struck through repros no longer work on HEAD.