syzbot


KASAN: use-after-free Read in mgmt_pending_remove

Status: upstream: reported on 2025/10/31 16:52
Reported-by: syzbot+e5949265939109216ac1@syzkaller.appspotmail.com
First crash: 50d, last: 50d
Similar bugs (4)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in mgmt_pending_remove 19 1 333d 333d 0/3 auto-obsoleted due to no activity on 2025/05/01 22:08
upstream KASAN: use-after-free Read in mgmt_pending_remove bluetooth 19 C unreliable 9 1201d 1221d 22/29 fixed on 2023/02/24 14:17
upstream KASAN: slab-use-after-free Read in mgmt_pending_remove bluetooth 19 syz 2 38d 34d 28/29 upstream: reported syz repro on 2025/11/16 06:34
upstream BUG: corrupted list in mgmt_pending_remove bluetooth 19 C error 44 204d 475d 29/29 fixed on 2025/08/06 17:37

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 ffff888078e4dd08 by task syz.4.16/4446

CPU: 1 PID: 4446 Comm: syz.4.16 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/02/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/0x210 mm/kasan/report.c:420
 kasan_report+0x10b/0x140 mm/kasan/report.c:524
 __list_del_entry_valid+0x2b/0x120 lib/list_debug.c:46
 __list_del_entry include/linux/list.h:134 [inline]
 list_del include/linux/list.h:148 [inline]
 mgmt_pending_remove+0x24/0x1a0 net/bluetooth/mgmt_util.c:314
 mgmt_pending_foreach+0xc1/0x110 net/bluetooth/mgmt_util.c:259
 __mgmt_power_off+0x15c/0x330 net/bluetooth/mgmt.c:9548
 hci_dev_close_sync+0x57c/0xf40 net/bluetooth/hci_sync.c:5237
 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:0x7fa13338efc9
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:00007fa13424a038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fa1335e6090 RCX: 00007fa13338efc9
RDX: 0000000000000000 RSI: 00000000400448ca RDI: 0000000000000005
RBP: 00007fa133411f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fa1335e6128 R14: 00007fa1335e6090 R15: 00007ffd15248528
 </TASK>

Allocated by task 4434:
 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
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 mgmt_pending_new+0x61/0x230 net/bluetooth/mgmt_util.c:269
 mgmt_pending_add+0x30/0x120 net/bluetooth/mgmt_util.c:296
 set_link_security+0x552/0x710 net/bluetooth/mgmt.c:1908
 hci_mgmt_cmd+0x9c9/0xed0 net/bluetooth/hci_sock.c:1652
 hci_sock_sendmsg+0x6b8/0xe70 net/bluetooth/hci_sock.c:1772
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg net/socket.c:730 [inline]
 sock_write_iter+0x2b5/0x3a0 net/socket.c:1143
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x44c/0x960 fs/read_write.c:584
 ksys_write+0x143/0x240 fs/read_write.c:637
 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 4434:
 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:1729 [inline]
 slab_free_freelist_hook+0x131/0x1a0 mm/slub.c:1755
 slab_free mm/slub.c:3687 [inline]
 __kmem_cache_free+0xb6/0x1f0 mm/slub.c:3700
 mgmt_pending_foreach+0xc1/0x110 net/bluetooth/mgmt_util.c:259
 mgmt_index_removed+0x155/0x350 net/bluetooth/mgmt.c:9474
 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 ffff888078e4dd00
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 8 bytes inside of
 96-byte region [ffff888078e4dd00, ffff888078e4dd60)

The buggy address belongs to the physical page:
page:ffffea0001e39340 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x78e4d
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff888017441780
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 0x112a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 0, tgid 0 (swapper/1), ts 67453456690, free_ts 65429559072
 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_slab_page+0x5d/0x160 mm/slub.c:1799
 allocate_slab mm/slub.c:1944 [inline]
 new_slab+0x87/0x2c0 mm/slub.c:1997
 ___slab_alloc+0xbc6/0x1230 mm/slub.c:3154
 __slab_alloc mm/slub.c:3240 [inline]
 slab_alloc_node mm/slub.c:3325 [inline]
 __kmem_cache_alloc_node+0x1a0/0x260 mm/slub.c:3398
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026
 kmalloc include/linux/slab.h:563 [inline]
 dst_cow_metrics_generic+0x52/0x1b0 net/core/dst.c:202
 dst_metrics_write_ptr include/net/dst.h:119 [inline]
 dst_metric_set include/net/dst.h:180 [inline]
 icmp6_dst_alloc+0x2d8/0x460 net/ipv6/route.c:3321
 ndisc_send_skb+0x3ff/0x1510 net/ipv6/ndisc.c:493
 addrconf_rs_timer+0x2b8/0x600 net/ipv6/addrconf.c:3979
 call_timer_fn+0x1a0/0x670 kernel/time/timer.c:1700
 expire_timers kernel/time/timer.c:1751 [inline]
 __run_timers+0x529/0x7d0 kernel/time/timer.c:2022
 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:2035
 handle_softirqs+0x2a1/0x920 kernel/softirq.c:596
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare mm/page_alloc.c:1509 [inline]
 free_unref_page_prepare+0x8b4/0x9a0 mm/page_alloc.c:3384
 free_unref_page_list+0xbb/0x8e0 mm/page_alloc.c:3525
 release_pages+0x1f92/0x2200 mm/swap.c:1035
 tlb_batch_pages_flush mm/mmu_gather.c:59 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:254 [inline]
 tlb_flush_mmu+0xff/0x210 mm/mmu_gather.c:261
 tlb_finish_mmu+0xbd/0x1c0 mm/mmu_gather.c:361
 exit_mmap+0x343/0x8e0 mm/mmap.c:3262
 __mmput+0x118/0x3c0 kernel/fork.c:1200
 exit_mm+0x1e6/0x2c0 kernel/exit.c:565
 do_exit+0x8c1/0x2400 kernel/exit.c:867
 do_group_exit+0x217/0x2d0 kernel/exit.c:1022
 __do_sys_exit_group kernel/exit.c:1033 [inline]
 __se_sys_exit_group kernel/exit.c:1031 [inline]
 __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1031
 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

Memory state around the buggy address:
 ffff888078e4dc00: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
 ffff888078e4dc80: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
>ffff888078e4dd00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                      ^
 ffff888078e4dd80: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
 ffff888078e4de00: 00 00 00 00 00 00 00 00 00 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/10/31 16:51 linux-6.1.y f6e38ae624cf 2c50b6a9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in mgmt_pending_remove
* Struck through repros no longer work on HEAD.