syzbot


KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync

Status: upstream: reported on 2024/07/24 08:59
Subsystems: bluetooth
[Documentation on labels]
Reported-by: syzbot+479aff51bb361ef5aa18@syzkaller.appspotmail.com
First crash: 124d, last: 2d08h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [bluetooth?] KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync 0 (1) 2024/07/24 08:59

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in mgmt_remove_adv_monitor_sync+0xe2/0xf0 net/bluetooth/mgmt.c:5468
Read of size 8 at addr ffff88802ab0f418 by task kworker/u33:0/11206

CPU: 1 UID: 0 PID: 11206 Comm: kworker/u33:0 Not tainted 6.11.0-rc7-syzkaller-00021-g7c6a3a65ace7 #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: hci0 hci_cmd_sync_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:93 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:119
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:488
 kasan_report+0xd9/0x110 mm/kasan/report.c:601
 mgmt_remove_adv_monitor_sync+0xe2/0xf0 net/bluetooth/mgmt.c:5468
 hci_cmd_sync_work+0x1a4/0x410 net/bluetooth/hci_sync.c:328
 process_one_work+0x9c5/0x1b40 kernel/workqueue.c:3231
 process_scheduled_works kernel/workqueue.c:3312 [inline]
 worker_thread+0x6c8/0xed0 kernel/workqueue.c:3389
 kthread+0x2c1/0x3a0 kernel/kthread.c:389
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>

Allocated by task 18278:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:387
 kmalloc_noprof include/linux/slab.h:681 [inline]
 kzalloc_noprof include/linux/slab.h:807 [inline]
 mgmt_pending_new+0x5b/0x290 net/bluetooth/mgmt_util.c:269
 mgmt_pending_add+0x36/0x160 net/bluetooth/mgmt_util.c:296
 remove_adv_monitor+0x124/0x1b0 net/bluetooth/mgmt.c:5493
 hci_mgmt_cmd net/bluetooth/hci_sock.c:1712 [inline]
 hci_sock_sendmsg+0x1528/0x25e0 net/bluetooth/hci_sock.c:1832
 sock_sendmsg_nosec net/socket.c:730 [inline]
 __sock_sendmsg net/socket.c:745 [inline]
 sock_write_iter+0x50a/0x5c0 net/socket.c:1160
 new_sync_write fs/read_write.c:497 [inline]
 vfs_write+0x6b6/0x1140 fs/read_write.c:590
 ksys_write+0x1f8/0x260 fs/read_write.c:643
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 18972:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579
 poison_slab_object+0xf7/0x160 mm/kasan/common.c:240
 __kasan_slab_free+0x32/0x50 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2256 [inline]
 slab_free mm/slub.c:4477 [inline]
 kfree+0x12a/0x3b0 mm/slub.c:4598
 cmd_status_rsp net/bluetooth/mgmt.c:1451 [inline]
 cmd_complete_rsp+0x119/0x160 net/bluetooth/mgmt.c:1465
 mgmt_pending_foreach+0xdf/0x140 net/bluetooth/mgmt_util.c:259
 __mgmt_power_off+0x12f/0x2c0 net/bluetooth/mgmt.c:9469
 hci_dev_close_sync+0xc33/0x1110 net/bluetooth/hci_sync.c:5191
 hci_dev_do_close+0x2e/0x90 net/bluetooth/hci_core.c:483
 hci_dev_close+0x183/0x1e0 net/bluetooth/hci_core.c:508
 hci_sock_ioctl+0x28c/0x880 net/bluetooth/hci_sock.c:1128
 sock_do_ioctl+0x116/0x280 net/socket.c:1222
 sock_ioctl+0x22e/0x6c0 net/socket.c:1341
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:907 [inline]
 __se_sys_ioctl fs/ioctl.c:893 [inline]
 __x64_sys_ioctl+0x193/0x220 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88802ab0f400
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 24 bytes inside of
 freed 96-byte region [ffff88802ab0f400, ffff88802ab0f460)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88802ab0f300 pfn:0x2ab0f
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xfdffffff(slab)
raw: 00fff00000000000 ffff88801ac42280 ffffea00012fb540 dead000000000004
raw: ffff88802ab0f300 0000000000200009 00000001fdffffff 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 0x152820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_HARDWALL), pid 1165, tgid 1165 (kworker/u32:9), ts 71974063550, free_ts 70470028792
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1500
 prep_new_page mm/page_alloc.c:1508 [inline]
 get_page_from_freelist+0x1351/0x2e50 mm/page_alloc.c:3446
 __alloc_pages_noprof+0x22b/0x2460 mm/page_alloc.c:4702
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x4e/0xf0 mm/slub.c:2325
 allocate_slab mm/slub.c:2488 [inline]
 new_slab+0x84/0x260 mm/slub.c:2541
 ___slab_alloc+0xdac/0x1870 mm/slub.c:3727
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3817
 __slab_alloc_node mm/slub.c:3870 [inline]
 slab_alloc_node mm/slub.c:4029 [inline]
 __kmalloc_cache_noprof+0x2b4/0x300 mm/slub.c:4188
 kmalloc_noprof include/linux/slab.h:681 [inline]
 dst_cow_metrics_generic+0x4c/0x1e0 net/core/dst.c:178
 dst_metrics_write_ptr include/net/dst.h:133 [inline]
 dst_metric_set include/net/dst.h:194 [inline]
 icmp6_dst_alloc+0x370/0x490 net/ipv6/route.c:3288
 ndisc_send_skb+0x1279/0x1c30 net/ipv6/ndisc.c:491
 ndisc_send_rs+0x129/0x670 net/ipv6/ndisc.c:721
 addrconf_dad_completed+0x4a1/0x1060 net/ipv6/addrconf.c:4360
 addrconf_dad_work+0x7fb/0x14d0 net/ipv6/addrconf.c:4268
 process_one_work+0x9c5/0x1b40 kernel/workqueue.c:3231
 process_scheduled_works kernel/workqueue.c:3312 [inline]
 worker_thread+0x6c8/0xed0 kernel/workqueue.c:3389
page last free pid 5402 tgid 5402 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1101 [inline]
 free_unref_page+0x64a/0xe40 mm/page_alloc.c:2619
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x4e/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x192/0x1e0 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:322
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3992 [inline]
 slab_alloc_node mm/slub.c:4041 [inline]
 kmem_cache_alloc_noprof+0x121/0x2f0 mm/slub.c:4048
 mt_alloc_one lib/maple_tree.c:162 [inline]
 mas_alloc_nodes+0x176/0x860 lib/maple_tree.c:1242
 mas_node_count_gfp+0x105/0x130 lib/maple_tree.c:1322
 mas_preallocate+0x3bb/0x1020 lib/maple_tree.c:5553
 vma_iter_prealloc mm/internal.h:1414 [inline]
 __split_vma+0x474/0x11c0 mm/mmap.c:2478
 do_vmi_align_munmap+0x362/0x19c0 mm/mmap.c:2676
 do_vmi_munmap+0x231/0x410 mm/mmap.c:2830
 mmap_region+0x17f/0x2760 mm/mmap.c:2881
 do_mmap+0xbfb/0xfb0 mm/mmap.c:1468
 vm_mmap_pgoff+0x1ba/0x360 mm/util.c:588
 ksys_mmap_pgoff+0x332/0x5d0 mm/mmap.c:1514
 __do_sys_mmap arch/x86/kernel/sys_x86_64.c:86 [inline]
 __se_sys_mmap arch/x86/kernel/sys_x86_64.c:79 [inline]
 __x64_sys_mmap+0x125/0x190 arch/x86/kernel/sys_x86_64.c:79

Memory state around the buggy address:
 ffff88802ab0f300: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88802ab0f380: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff88802ab0f400: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                            ^
 ffff88802ab0f480: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff88802ab0f500: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Crashes (18):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/12 08:51 upstream 7c6a3a65ace7 d94c83d8 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/10/04 07:01 upstream 3840cbe24cf0 d7906eff .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/09/01 04:54 net fe1910f9337b 1eda0d14 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/08/30 00:29 net febccb39255f 54fe8471 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/08/27 18:16 net bc21000e99f9 6c853ff9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/08/04 14:15 net 14ab4792ee12 1786a2a8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/10/02 22:29 net-next 44badc908f2c a4c7fd36 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/09/28 04:14 net-next c824deb1a897 440b26ec .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/09/25 09:11 net-next 151ac45348af 349a68c4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/09/06 20:44 net-next 52fc70a32573 ce70880a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/09/06 20:39 net-next 52fc70a32573 ce70880a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/08/30 10:56 net-next 670726a8262e 54fe8471 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/07/24 08:58 net-next d7e78951a8b8 57b2edb1 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/07/22 23:09 net-next d7e78951a8b8 f063dfd9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/07/11 12:19 net-next ce2f84ebcd85 c699c2eb .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/06/05 08:26 net-next 2b438c5774cc e1e2c66e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/10/05 06:24 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 3eddb108abe3 d7906eff .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
2024/06/12 12:16 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 8867bbd4a056 4d75f4f7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in mgmt_remove_adv_monitor_sync
* Struck through repros no longer work on HEAD.