syzbot


KASAN: use-after-free Read in hci_sock_get_cookie

Status: upstream: reported on 2024/12/18 01:01
Reported-by: syzbot+de7fdfcf96221b4150c4@syzkaller.appspotmail.com
First crash: 3d15h, last: 3d15h
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in hci_sock_get_cookie bluetooth 2 226d 234d 0/28 closed as invalid on 2024/06/04 19:11
upstream KASAN: slab-use-after-free Read in hci_sock_get_cookie (2) bluetooth 14 16d 184d 0/28 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:95
Read of size 4 at addr ffff888024bec580 by task syz.0.583/6525

CPU: 1 PID: 6525 Comm: syz.0.583 Not tainted 5.15.174-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/25/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 hci_sock_get_cookie+0x41/0x50 net/bluetooth/hci_sock.c:95
 mgmt_cmd_status+0x1b6/0x430 net/bluetooth/mgmt_util.c:116
 cmd_status_rsp net/bluetooth/mgmt.c:1298 [inline]
 cmd_complete_rsp+0xd4/0x160 net/bluetooth/mgmt.c:1313
 mgmt_pending_foreach+0xc9/0x120 net/bluetooth/mgmt_util.c:226
 __mgmt_power_off+0x183/0x410 net/bluetooth/mgmt.c:8638
 hci_dev_do_close+0x625/0x1070 net/bluetooth/hci_core.c:1791
 hci_dev_close+0xe5/0x190 net/bluetooth/hci_core.c:1877
 sock_do_ioctl+0x11d/0x5a0 net/socket.c:1140
 sock_ioctl+0x47f/0x770 net/socket.c:1257
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f512cd8bd29
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:00007f512abfc038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f512cf7bfa0 RCX: 00007f512cd8bd29
RDX: 0000000000000000 RSI: 00000000400448ca RDI: 0000000000000009
RBP: 00007f512ce07a20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f512cf7bfa0 R15: 00007ffcac6af038
 </TASK>

Allocated by task 6124:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 __kmalloc+0x168/0x300 mm/slub.c:4407
 kmalloc include/linux/slab.h:596 [inline]
 sk_prot_alloc+0xe0/0x200 net/core/sock.c:1863
 sk_alloc+0x35/0x310 net/core/sock.c:1916
 hci_sock_create+0x9f/0x220 net/bluetooth/hci_sock.c:2094
 bt_sock_create+0x159/0x220 net/bluetooth/af_bluetooth.c:130
 __sock_create+0x460/0x8f0 net/socket.c:1486
 sock_create net/socket.c:1542 [inline]
 __sys_socket+0x132/0x370 net/socket.c:1584
 __do_sys_socket net/socket.c:1593 [inline]
 __se_sys_socket net/socket.c:1591 [inline]
 __x64_sys_socket+0x76/0x80 net/socket.c:1591
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 6531:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xf1/0x270 mm/slub.c:4559
 sk_prot_free net/core/sock.c:1899 [inline]
 __sk_destruct+0x58e/0x840 net/core/sock.c:1985
 sock_put include/net/sock.h:1923 [inline]
 mgmt_pending_free net/bluetooth/mgmt_util.c:261 [inline]
 mgmt_pending_remove+0x13a/0x1a0 net/bluetooth/mgmt_util.c:269
 mgmt_pending_foreach+0xc9/0x120 net/bluetooth/mgmt_util.c:226
 mgmt_index_removed+0x158/0x3c0 net/bluetooth/mgmt.c:8546
 hci_sock_bind+0xc95/0x10c0 net/bluetooth/hci_sock.c:1246
 __sys_bind+0x388/0x400 net/socket.c:1720
 __do_sys_bind net/socket.c:1731 [inline]
 __se_sys_bind net/socket.c:1729 [inline]
 __x64_sys_bind+0x76/0x80 net/socket.c:1729
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:3007 [inline]
 call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3087
 qdisc_put net/sched/sch_generic.c:1044 [inline]
 shutdown_scheduler_queue net/sched/sch_generic.c:1097 [inline]
 netdev_for_each_tx_queue include/linux/netdevice.h:2379 [inline]
 dev_shutdown+0x18a/0x6d0 net/sched/sch_generic.c:1405
 unregister_netdevice_many+0xac3/0x18f0 net/core/dev.c:11095
 unregister_netdevice_queue+0x2e6/0x350 net/core/dev.c:11035
 unregister_netdevice include/linux/netdevice.h:3012 [inline]
 __tun_detach+0x6b6/0x1600 drivers/net/tun.c:686
 tun_detach drivers/net/tun.c:702 [inline]
 tun_chr_close+0x104/0x1b0 drivers/net/tun.c:3440
 __fput+0x3fe/0x8e0 fs/file_table.c:280
 task_work_run+0x129/0x1a0 kernel/task_work.c:188
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
 syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff888024bec000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1408 bytes inside of
 2048-byte region [ffff888024bec000, ffff888024bec800)
The buggy address belongs to the page:
page:ffffea000092fa00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x24be8
head:ffffea000092fa00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 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 4168, ts 61602277870, free_ts 61582939638
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5465
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc+0x1c9/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:596 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 __register_sysctl_table+0xdc/0x1220 fs/proc/proc_sysctl.c:1317
 __devinet_sysctl_register+0x1d3/0x2a0 net/ipv4/devinet.c:2603
 devinet_sysctl_register+0x13a/0x1a0 net/ipv4/devinet.c:2643
 inetdev_init+0x282/0x4a0 net/ipv4/devinet.c:277
 inetdev_event+0x29b/0x1490 net/ipv4/devinet.c:1543
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
 call_netdevice_notifiers_info net/core/dev.c:2018 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2030 [inline]
 call_netdevice_notifiers+0x145/0x1b0 net/core/dev.c:2044
 register_netdevice+0x12e8/0x1720 net/core/dev.c:10396
 register_netdev+0x37/0x50 net/core/dev.c:10489
 ip6_tnl_init_net+0x22c/0x2e0 net/ipv6/ip6_tunnel.c:2301
 ops_init+0x35d/0x610 net/core/net_namespace.c:138
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 free_slab mm/slub.c:2015 [inline]
 discard_slab mm/slub.c:2021 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
 put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc+0x120/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:596 [inline]
 tomoyo_add_entry security/tomoyo/common.c:2031 [inline]
 tomoyo_supervisor+0xe67/0x12c0 security/tomoyo/common.c:2103
 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
 tomoyo_path_permission+0x243/0x360 security/tomoyo/file.c:587
 tomoyo_check_open_permission+0x350/0x490 security/tomoyo/file.c:780
 security_file_open+0x5f/0xa0 security/security.c:1668
 do_dentry_open+0x315/0xfb0 fs/open.c:813
 do_open fs/namei.c:3608 [inline]
 path_openat+0x2705/0x2f20 fs/namei.c:3742

Memory state around the buggy address:
 ffff888024bec480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888024bec500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888024bec580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff888024bec600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888024bec680: 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
2024/12/18 01:01 linux-5.15.y 963e654022cc a0626d3a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in hci_sock_get_cookie
* Struck through repros no longer work on HEAD.