================================================================== BUG: KASAN: slab-use-after-free in mgmt_remove_adv_monitor_sync+0xe2/0xf0 net/bluetooth/mgmt.c:5473 Read of size 8 at addr ffff888026cc7818 by task kworker/u33:5/5957 CPU: 0 UID: 0 PID: 5957 Comm: kworker/u33:5 Not tainted 6.12.0-rc5-syzkaller-00181-g6c52d4da1c74 #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: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 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:5473 hci_cmd_sync_work+0x1a4/0x410 net/bluetooth/hci_sync.c:332 process_one_work+0x958/0x1b30 kernel/workqueue.c:3229 process_scheduled_works kernel/workqueue.c:3310 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391 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 Allocated by task 7130: 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:377 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:394 kmalloc_noprof include/linux/slab.h:878 [inline] kzalloc_noprof include/linux/slab.h:1014 [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:5498 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:729 [inline] __sock_sendmsg net/socket.c:744 [inline] sock_write_iter+0x4fe/0x5b0 net/socket.c:1165 new_sync_write fs/read_write.c:590 [inline] vfs_write+0x5ae/0x1150 fs/read_write.c:683 ksys_write+0x1fa/0x260 fs/read_write.c:736 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Freed by task 6820: 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 mm/kasan/common.c:247 [inline] __kasan_slab_free+0x51/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:230 [inline] slab_free_hook mm/slub.c:2342 [inline] slab_free mm/slub.c:4579 [inline] kfree+0x14f/0x4b0 mm/slub.c:4727 cmd_status_rsp net/bluetooth/mgmt.c:1451 [inline] cmd_complete_rsp+0x16d/0x1e0 net/bluetooth/mgmt.c:1470 mgmt_pending_foreach+0xdf/0x140 net/bluetooth/mgmt_util.c:259 __mgmt_power_off+0x12f/0x2c0 net/bluetooth/mgmt.c:9474 hci_dev_close_sync+0xd37/0x1260 net/bluetooth/hci_sync.c:5201 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 hci_sock_compat_ioctl+0x43/0x80 net/bluetooth/hci_sock.c:1174 compat_sock_ioctl+0x17b/0x7e0 net/socket.c:3544 __do_compat_sys_ioctl+0x259/0x2b0 fs/ioctl.c:1007 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e The buggy address belongs to the object at ffff888026cc7800 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 24 bytes inside of freed 96-byte region [ffff888026cc7800, ffff888026cc7860) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x26cc7 ksm flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000000 ffff88801ac42280 ffffea0000024c00 dead000000000003 raw: 0000000000000000 0000000000200020 00000001f5000000 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 0x52c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 5368, tgid 5368 (udevd), ts 17978790556, free_ts 16718076825 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1537 prep_new_page mm/page_alloc.c:1545 [inline] get_page_from_freelist+0x101e/0x3070 mm/page_alloc.c:3457 __alloc_pages_noprof+0x223/0x25a0 mm/page_alloc.c:4733 alloc_pages_mpol_noprof+0x2c9/0x610 mm/mempolicy.c:2265 alloc_slab_page mm/slub.c:2412 [inline] allocate_slab mm/slub.c:2578 [inline] new_slab+0x2ba/0x3f0 mm/slub.c:2631 ___slab_alloc+0xd1d/0x16f0 mm/slub.c:3818 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3908 __slab_alloc_node mm/slub.c:3961 [inline] slab_alloc_node mm/slub.c:4122 [inline] __do_kmalloc_node mm/slub.c:4263 [inline] __kmalloc_noprof+0x379/0x410 mm/slub.c:4276 kmalloc_noprof include/linux/slab.h:882 [inline] kzalloc_noprof include/linux/slab.h:1014 [inline] tomoyo_encode2+0x100/0x3e0 security/tomoyo/realpath.c:45 tomoyo_encode security/tomoyo/realpath.c:80 [inline] tomoyo_realpath_from_path+0x1a7/0x710 security/tomoyo/realpath.c:283 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_check_open_permission+0x2a7/0x3b0 security/tomoyo/file.c:771 tomoyo_file_open+0x6b/0x90 security/tomoyo/tomoyo.c:334 security_file_open+0x64c/0x9d0 security/security.c:3109 do_dentry_open+0x57c/0x1530 fs/open.c:945 vfs_open+0x82/0x3f0 fs/open.c:1088 do_open fs/namei.c:3774 [inline] path_openat+0x1e6a/0x2d60 fs/namei.c:3933 page last free pid 5369 tgid 5369 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1108 [inline] free_unref_page+0x5f4/0xdc0 mm/page_alloc.c:2638 __put_partials+0x14c/0x170 mm/slub.c:3145 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x4e/0x120 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x192/0x1e0 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:329 kasan_slab_alloc include/linux/kasan.h:247 [inline] slab_post_alloc_hook mm/slub.c:4085 [inline] slab_alloc_node mm/slub.c:4134 [inline] kmem_cache_alloc_lru_noprof+0x121/0x2f0 mm/slub.c:4153 __d_alloc+0x35/0x8c0 fs/dcache.c:1636 d_alloc+0x4a/0x1e0 fs/dcache.c:1716 d_alloc_parallel+0xe9/0x12b0 fs/dcache.c:2478 __lookup_slow+0x194/0x460 fs/namei.c:1717 lookup_slow fs/namei.c:1749 [inline] walk_component+0x350/0x5b0 fs/namei.c:2053 lookup_last fs/namei.c:2556 [inline] path_lookupat+0x17f/0x770 fs/namei.c:2580 filename_lookup+0x1e5/0x5b0 fs/namei.c:2609 do_readlinkat+0xcf/0x390 fs/stat.c:537 __do_sys_readlink fs/stat.c:574 [inline] __se_sys_readlink fs/stat.c:571 [inline] __x64_sys_readlink+0x78/0xc0 fs/stat.c:571 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 Memory state around the buggy address: ffff888026cc7700: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc ffff888026cc7780: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc >ffff888026cc7800: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff888026cc7880: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc ffff888026cc7900: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc ==================================================================