================================================================== BUG: KASAN: use-after-free in d_inode include/linux/dcache.h:515 [inline] BUG: KASAN: use-after-free in relay_switch_subbuf+0x298/0x6b0 kernel/relay.c:676 Read of size 8 at addr ffff88807621a4d0 by task udevd/32632 CPU: 1 PID: 32632 Comm: udevd Not tainted 6.0.0-rc7-syzkaller-00068-g49c13ed0316d #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106 print_address_description+0x65/0x4b0 mm/kasan/report.c:317 print_report+0x108/0x220 mm/kasan/report.c:433 kasan_report+0xfb/0x130 mm/kasan/report.c:495 d_inode include/linux/dcache.h:515 [inline] relay_switch_subbuf+0x298/0x6b0 kernel/relay.c:676 relay_reserve include/linux/relay.h:248 [inline] trace_note+0x54b/0x6f0 kernel/trace/blktrace.c:95 trace_note_tsk+0xb9/0x150 kernel/trace/blktrace.c:126 __blk_add_trace+0x9ef/0xd60 kernel/trace/blktrace.c:268 blk_add_trace_plug+0xe3/0x1c0 kernel/trace/blktrace.c:952 trace_block_plug+0x213/0x260 include/trace/events/block.h:379 blk_add_rq_to_plug+0x19e/0x460 blk_mq_submit_bio+0x12e9/0x1f40 block/blk-mq.c:2837 __submit_bio block/blk-core.c:595 [inline] __submit_bio_noacct_mq block/blk-core.c:672 [inline] submit_bio_noacct_nocheck+0xdcd/0x1040 block/blk-core.c:689 submit_bio+0x23c/0x3a0 block/blk-core.c:848 mpage_bio_submit fs/mpage.c:64 [inline] mpage_readahead+0x304/0x390 fs/mpage.c:364 read_pages+0x13f/0x880 mm/readahead.c:158 page_cache_ra_unbounded+0x535/0x640 mm/readahead.c:263 do_page_cache_ra mm/readahead.c:293 [inline] force_page_cache_ra+0x2d6/0x340 mm/readahead.c:324 page_cache_sync_readahead include/linux/pagemap.h:1215 [inline] filemap_get_pages+0x483/0x1190 mm/filemap.c:2566 filemap_read+0x3ce/0xeb0 mm/filemap.c:2660 blkdev_read_iter+0x3de/0x520 block/fops.c:598 call_read_iter include/linux/fs.h:2181 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x7cf/0xbc0 fs/read_write.c:470 ksys_read+0x19b/0x2c0 fs/read_write.c:607 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fe4f6b258fe Code: c0 e9 e6 fe ff ff 50 48 8d 3d 0e c7 09 00 e8 c9 cf 01 00 66 0f 1f 84 00 00 00 00 00 64 8b 04 25 18 00 00 00 85 c0 75 14 0f 05 <48> 3d 00 f0 ff ff 77 5a c3 66 0f 1f 84 00 00 00 00 00 48 83 ec 28 RSP: 002b:00007fffaf9d7d68 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000000000ff0000 RCX: 00007fe4f6b258fe RDX: 0000000000000040 RSI: 000055cb18332768 RDI: 0000000000000009 RBP: 0000000000000040 R08: 000055cb18332740 R09: 000055cb1831e010 R10: 00007fe4f6bf5a00 R11: 0000000000000246 R12: 000055cb18332740 R13: 000055cb18332758 R14: 000055cb18344f20 R15: 000055cb18344ed0 Allocated by task 6327: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:437 [inline] __kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:470 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:727 [inline] slab_alloc_node mm/slub.c:3248 [inline] slab_alloc mm/slub.c:3256 [inline] __kmem_cache_alloc_lru mm/slub.c:3263 [inline] kmem_cache_alloc_lru+0x175/0x2d0 mm/slub.c:3280 __d_alloc+0x31/0x700 fs/dcache.c:1769 d_alloc fs/dcache.c:1849 [inline] d_alloc_parallel+0xcb/0x12c0 fs/dcache.c:2647 __lookup_slow+0x112/0x3e0 fs/namei.c:1670 lookup_one_len+0x430/0x690 fs/namei.c:2711 start_creating+0x183/0x330 fs/debugfs/inode.c:352 __debugfs_create_file+0x74/0x500 fs/debugfs/inode.c:397 relay_create_buf_file kernel/relay.c:363 [inline] relay_open_buf+0x5c8/0xd00 kernel/relay.c:392 relay_open+0x4a1/0xa80 kernel/relay.c:520 do_blk_trace_setup+0x523/0x980 kernel/trace/blktrace.c:560 __blk_trace_setup kernel/trace/blktrace.c:600 [inline] blk_trace_ioctl+0x341/0x8f0 kernel/trace/blktrace.c:741 blkdev_ioctl+0x1b7/0x760 block/ioctl.c:603 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 3638: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4c/0x70 mm/kasan/common.c:45 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:370 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:367 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1759 [inline] slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1785 slab_free mm/slub.c:3539 [inline] kmem_cache_free+0x95/0x1d0 mm/slub.c:3556 rcu_do_batch kernel/rcu/tree.c:2245 [inline] rcu_core+0xa61/0x1710 kernel/rcu/tree.c:2505 __do_softirq+0x382/0x793 kernel/softirq.c:571 Last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38 __kasan_record_aux_stack+0xaf/0xc0 mm/kasan/generic.c:348 call_rcu+0x163/0x9c0 kernel/rcu/tree.c:2793 __dentry_kill+0x46b/0x5b0 fs/dcache.c:621 dentry_kill+0xbb/0x290 dput+0x1f3/0x410 fs/dcache.c:913 find_next_child fs/libfs.c:264 [inline] simple_recursive_removal+0x2bf/0x860 fs/libfs.c:279 debugfs_remove+0x45/0x60 fs/debugfs/inode.c:742 blk_unregister_queue+0x199/0x1d0 block/blk-sysfs.c:932 del_gendisk+0x447/0x9c0 block/genhd.c:616 loop_remove drivers/block/loop.c:2064 [inline] loop_control_remove drivers/block/loop.c:2119 [inline] loop_control_ioctl+0x5b9/0x770 drivers/block/loop.c:2157 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Second to last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38 __kasan_record_aux_stack+0xaf/0xc0 mm/kasan/generic.c:348 call_rcu+0x163/0x9c0 kernel/rcu/tree.c:2793 __dentry_kill+0x46b/0x5b0 fs/dcache.c:621 shrink_dentry_list+0x386/0x6c0 fs/dcache.c:1201 shrink_dcache_parent+0xcd/0x450 vfs_rmdir+0x38d/0x4b0 fs/namei.c:4102 do_rmdir+0x372/0x680 fs/namei.c:4159 __do_sys_unlinkat fs/namei.c:4339 [inline] __se_sys_unlinkat fs/namei.c:4333 [inline] __x64_sys_unlinkat+0xdc/0xf0 fs/namei.c:4333 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff88807621a468 which belongs to the cache dentry of size 312 The buggy address is located 104 bytes inside of 312-byte region [ffff88807621a468, ffff88807621a5a0) The buggy address belongs to the physical page: page:ffffea0001d88680 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807621b780 pfn:0x7621a head:ffffea0001d88680 order:1 compound_mapcount:0 compound_pincount:0 memcg:ffff88807fa34b01 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea0001cffc88 ffffea0000a70f88 ffff8880121db780 raw: ffff88807621b780 0000000000150010 00000001ffffffff ffff88807fa34b01 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Reclaimable, gfp_mask 0xd20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_RECLAIMABLE), pid 2977, tgid 2977 (udevd), ts 24846671494, free_ts 13342514243 prep_new_page mm/page_alloc.c:2532 [inline] get_page_from_freelist+0x72b/0x7a0 mm/page_alloc.c:4283 __alloc_pages+0x259/0x560 mm/page_alloc.c:5549 alloc_slab_page+0x70/0xf0 mm/slub.c:1829 allocate_slab+0x5e/0x520 mm/slub.c:1974 new_slab mm/slub.c:2034 [inline] ___slab_alloc+0x42e/0xce0 mm/slub.c:3036 __slab_alloc mm/slub.c:3123 [inline] slab_alloc_node mm/slub.c:3214 [inline] slab_alloc mm/slub.c:3256 [inline] __kmem_cache_alloc_lru mm/slub.c:3263 [inline] kmem_cache_alloc_lru+0x225/0x2d0 mm/slub.c:3280 __d_alloc+0x31/0x700 fs/dcache.c:1769 d_alloc fs/dcache.c:1849 [inline] d_alloc_parallel+0xcb/0x12c0 fs/dcache.c:2647 lookup_open fs/namei.c:3338 [inline] open_last_lookups fs/namei.c:3481 [inline] path_openat+0x90d/0x2e00 fs/namei.c:3688 do_filp_open+0x275/0x500 fs/namei.c:3718 do_sys_openat2+0x13b/0x500 fs/open.c:1313 do_sys_open fs/open.c:1329 [inline] __do_sys_openat fs/open.c:1345 [inline] __se_sys_openat fs/open.c:1340 [inline] __x64_sys_openat+0x243/0x290 fs/open.c:1340 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1449 [inline] free_pcp_prepare+0x812/0x900 mm/page_alloc.c:1499 free_unref_page_prepare mm/page_alloc.c:3380 [inline] free_unref_page+0x7d/0x630 mm/page_alloc.c:3476 free_contig_range+0xa3/0x160 mm/page_alloc.c:9453 destroy_args+0xfe/0x971 mm/debug_vm_pgtable.c:1031 debug_vm_pgtable+0x454/0x4ad mm/debug_vm_pgtable.c:1354 do_one_initcall+0xbd/0x2b0 init/main.c:1296 do_initcall_level+0x168/0x218 init/main.c:1369 do_initcalls+0x4b/0x8c init/main.c:1385 kernel_init_freeable+0x43a/0x5c3 init/main.c:1623 kernel_init+0x19/0x2b0 init/main.c:1512 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 Memory state around the buggy address: ffff88807621a380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88807621a400: 00 00 00 00 00 fc fc fc fc fc fc fc fc fa fb fb >ffff88807621a480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807621a500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807621a580: fb fb fb fb fc fc fc fc fc fc fc fc 00 00 00 00 ==================================================================