syzbot


KASAN: use-after-free Read in mgmt_pending_remove

Status: upstream: reported on 2025/01/21 22:08
Reported-by: syzbot+bd4d351cd109e95351c9@syzkaller.appspotmail.com
First crash: 14d, last: 14d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in mgmt_pending_remove bluetooth C unreliable 9 883d 903d 22/28 fixed on 2023/02/24 14:17
upstream BUG: corrupted list in mgmt_pending_remove bluetooth C error 32 7d21h 157d 0/28 upstream: reported C repro on 2024/09/01 08:24

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __list_del_entry_valid+0x2b/0x120 lib/list_debug.c:46
Read of size 8 at addr ffff8881482cab88 by task syz.1.293/5802

CPU: 1 PID: 5802 Comm: syz.1.293 Not tainted 5.15.176-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/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
 __list_del_entry_valid+0x2b/0x120 lib/list_debug.c:46
 __list_del_entry include/linux/list.h:132 [inline]
 list_del include/linux/list.h:146 [inline]
 mgmt_pending_remove+0x22/0x1a0 net/bluetooth/mgmt_util.c:268
 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:0x7f052fb58d29
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:00007f052d9c9038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f052fd48fa0 RCX: 00007f052fb58d29
RDX: 0000000000000000 RSI: 00000000400448ca RDI: 0000000000000009
RBP: 00007f052fbd4b08 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f052fd48fa0 R15: 00007fff75b967f8
 </TASK>

Allocated by task 5510:
 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]
 kmem_cache_alloc_trace+0x143/0x290 mm/slub.c:3247
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 mgmt_pending_add+0x61/0x310 net/bluetooth/mgmt_util.c:236
 get_clock_info+0x3c1/0x770 net/bluetooth/mgmt.c:6641
 hci_mgmt_cmd+0x9c9/0xde0 net/bluetooth/hci_sock.c:1652
 hci_sock_sendmsg+0x3f6/0xe50 net/bluetooth/hci_sock.c:1787
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 sock_write_iter+0x39b/0x530 net/socket.c:1079
 call_write_iter include/linux/fs.h:2174 [inline]
 new_sync_write fs/read_write.c:507 [inline]
 vfs_write+0xacd/0xe50 fs/read_write.c:594
 ksys_write+0x1a2/0x2c0 fs/read_write.c:647
 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 5815:
 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
 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
 kvfree_call_rcu+0x118/0x8a0 kernel/rcu/tree.c:3596
 sctp_inetaddr_event+0x556/0x5f0 net/sctp/protocol.c:815
 notifier_call_chain kernel/notifier.c:83 [inline]
 blocking_notifier_call_chain+0x104/0x1b0 kernel/notifier.c:318
 __inet_del_ifa+0x87b/0x1020 net/ipv4/devinet.c:443
 inet_del_ifa net/ipv4/devinet.c:480 [inline]
 inetdev_destroy net/ipv4/devinet.c:320 [inline]
 inetdev_event+0x62b/0x1490 net/ipv4/devinet.c:1611
 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 net/core/dev.c:2044 [inline]
 unregister_netdevice_many+0xf1b/0x18f0 net/core/dev.c:11102
 default_device_exit_batch+0x390/0x3f0 net/core/dev.c:11635
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x763/0xb60 net/core/net_namespace.c:599
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

The buggy address belongs to the object at ffff8881482cab80
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 8 bytes inside of
 64-byte region [ffff8881482cab80, ffff8881482cabc0)
The buggy address belongs to the page:
page:ffffea000520b280 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1482ca
flags: 0x57ff00000000200(slab|node=1|zone=2|lastcpupid=0x7ff)
raw: 057ff00000000200 ffffea0000724200 0000000400000004 ffff888017441640
raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, ts 13249972841, free_ts 0
 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_page_interleave+0x22/0x1c0 mm/mempolicy.c:2031
 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]
 kmem_cache_alloc_trace+0x1a0/0x290 mm/slub.c:3245
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 kobject_create lib/kobject.c:792 [inline]
 kobject_create_and_add+0x57/0x230 lib/kobject.c:818
 module_create_drivers_dir drivers/base/module.c:29 [inline]
 module_add_driver+0x227/0x2c0 drivers/base/module.c:65
 bus_add_driver+0x398/0x600 drivers/base/bus.c:624
 driver_register+0x2bf/0x3a0 drivers/base/driver.c:240
 usb_register_driver+0x206/0x3d0 drivers/usb/core/driver.c:1061
 do_one_initcall+0x22b/0x7a0 init/main.c:1302
 do_initcall_level+0x157/0x210 init/main.c:1375
 do_initcalls+0x49/0x90 init/main.c:1391
 kernel_init_freeable+0x425/0x5c0 init/main.c:1615
 kernel_init+0x19/0x290 init/main.c:1506
page_owner free stack trace missing

Memory state around the buggy address:
 ffff8881482caa80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8881482cab00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8881482cab80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                      ^
 ffff8881482cac00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8881482cac80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/21 22:07 linux-5.15.y 4735586da88e da72ac06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in mgmt_pending_remove
* Struck through repros no longer work on HEAD.