================================================================== BUG: KASAN: use-after-free in d_inode include/linux/dcache.h:516 [inline] BUG: KASAN: use-after-free in relay_switch_subbuf+0x837/0x900 kernel/relay.c:676 Read of size 8 at addr ffff888072dba7c0 by task syz-executor.4/3775 CPU: 1 PID: 3775 Comm: syz-executor.4 Not tainted 5.19.0-syzkaller-02858-ge2b542100719 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313 print_report mm/kasan/report.c:429 [inline] kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491 d_inode include/linux/dcache.h:516 [inline] relay_switch_subbuf+0x837/0x900 kernel/relay.c:676 relay_reserve include/linux/relay.h:248 [inline] trace_note+0x5af/0x720 kernel/trace/blktrace.c:95 trace_note_tsk kernel/trace/blktrace.c:126 [inline] __blk_add_trace+0xbf8/0xde0 kernel/trace/blktrace.c:268 blk_add_trace_plug+0xc0/0x240 kernel/trace/blktrace.c:952 trace_block_plug include/trace/events/block.h:379 [inline] blk_add_rq_to_plug+0x69f/0xa00 block/blk-mq.c:1181 blk_mq_submit_bio+0xa85/0x1d50 block/blk-mq.c:2856 __submit_bio+0x2b7/0x340 block/blk-core.c:602 __submit_bio_noacct_mq block/blk-core.c:679 [inline] submit_bio_noacct_nocheck block/blk-core.c:696 [inline] submit_bio_noacct_nocheck+0x6c9/0x8a0 block/blk-core.c:685 submit_bio_noacct+0xa5d/0x1d50 block/blk-core.c:803 submit_bio block/blk-core.c:855 [inline] submit_bio+0xd7/0x300 block/blk-core.c:827 __blkdev_direct_IO+0x5fd/0xca0 block/fops.c:243 blkdev_direct_IO block/fops.c:371 [inline] blkdev_direct_IO block/fops.c:358 [inline] blkdev_read_iter+0x676/0x750 block/fops.c:588 call_read_iter include/linux/fs.h:2183 [inline] aio_read+0x2a4/0x450 fs/aio.c:1563 __io_submit_one fs/aio.c:1973 [inline] io_submit_one+0xfbe/0x1c70 fs/aio.c:2022 __do_sys_io_submit fs/aio.c:2081 [inline] __se_sys_io_submit fs/aio.c:2051 [inline] __x64_sys_io_submit+0x18c/0x330 fs/aio.c:2051 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fb655e89209 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb656fdf168 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1 RAX: ffffffffffffffda RBX: 00007fb655f9bf60 RCX: 00007fb655e89209 RDX: 00000000200000c0 RSI: 0000000000000008 RDI: 00007fb656fbe000 RBP: 00007fb655ee3161 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffe9610754f R14: 00007fb656fdf300 R15: 0000000000022000 Allocated by task 19227: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:437 [inline] __kasan_slab_alloc+0x90/0xc0 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:3243 [inline] slab_alloc mm/slub.c:3251 [inline] __kmem_cache_alloc_lru mm/slub.c:3258 [inline] kmem_cache_alloc_lru+0x31f/0x730 mm/slub.c:3275 __d_alloc+0x32/0x960 fs/dcache.c:1769 d_alloc+0x4a/0x230 fs/dcache.c:1849 d_alloc_parallel+0xe7/0x1af0 fs/dcache.c:2601 __lookup_slow+0x193/0x480 fs/namei.c:1686 lookup_one_len+0x16a/0x1a0 fs/namei.c:2730 start_creating.part.0+0x13a/0x290 fs/debugfs/inode.c:352 start_creating fs/debugfs/inode.c:325 [inline] __debugfs_create_file+0xa9/0x540 fs/debugfs/inode.c:397 relay_create_buf_file+0xf0/0x170 kernel/relay.c:363 relay_open_buf.part.0+0x7bb/0xc00 kernel/relay.c:392 relay_open_buf kernel/relay.c:384 [inline] relay_open kernel/relay.c:520 [inline] relay_open+0x4fb/0xa00 kernel/relay.c:477 do_blk_trace_setup+0x4bc/0xb60 kernel/trace/blktrace.c:560 __blk_trace_setup+0xca/0x180 kernel/trace/blktrace.c:600 blk_trace_ioctl+0x147/0x290 kernel/trace/blktrace.c:741 blkdev_ioctl+0x181/0x800 block/ioctl.c:603 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 3693: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:367 [inline] ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:329 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1754 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1780 slab_free mm/slub.c:3534 [inline] kmem_cache_free+0xed/0x5b0 mm/slub.c:3551 rcu_do_batch kernel/rcu/tree.c:2245 [inline] rcu_core+0x7b5/0x18a0 kernel/rcu/tree.c:2505 __do_softirq+0x29b/0x9c2 kernel/softirq.c:571 Last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 call_rcu+0x99/0x790 kernel/rcu/tree.c:2793 dentry_free+0xc3/0x160 fs/dcache.c:377 __dentry_kill+0x4cb/0x640 fs/dcache.c:621 dentry_kill fs/dcache.c:745 [inline] dput+0x64d/0xdb0 fs/dcache.c:913 find_next_child fs/libfs.c:264 [inline] simple_recursive_removal+0x136/0x830 fs/libfs.c:279 debugfs_remove fs/debugfs/inode.c:742 [inline] debugfs_remove+0x59/0x80 fs/debugfs/inode.c:736 blk_unregister_queue+0x1a6/0x2a0 block/blk-sysfs.c:934 del_gendisk+0x380/0xa30 block/genhd.c:617 loop_remove drivers/block/loop.c:2059 [inline] loop_control_remove drivers/block/loop.c:2114 [inline] loop_control_ioctl+0x44d/0x620 drivers/block/loop.c:2152 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Second to last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 call_rcu+0x99/0x790 kernel/rcu/tree.c:2793 dentry_free+0xc3/0x160 fs/dcache.c:377 __dentry_kill+0x4cb/0x640 fs/dcache.c:621 shrink_dentry_list+0x23c/0x800 fs/dcache.c:1201 shrink_dcache_parent+0x1fe/0x3c0 fs/dcache.c:1628 vfs_rmdir.part.0+0x272/0x5a0 fs/namei.c:4065 vfs_rmdir fs/namei.c:4046 [inline] do_rmdir+0x3a6/0x430 fs/namei.c:4122 __do_sys_unlinkat fs/namei.c:4302 [inline] __se_sys_unlinkat fs/namei.c:4296 [inline] __x64_sys_unlinkat+0xeb/0x130 fs/namei.c:4296 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888072dba758 which belongs to the cache dentry of size 312 The buggy address is located 104 bytes inside of 312-byte region [ffff888072dba758, ffff888072dba890) The buggy address belongs to the physical page: page:ffffea0001cb6e80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x72dba head:ffffea0001cb6e80 order:1 compound_mapcount:0 compound_pincount:0 memcg:ffff888074b6c601 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea000077fe00 dead000000000005 ffff888140007640 raw: 0000000000000000 0000000000150015 00000001ffffffff ffff888074b6c601 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Reclaimable, gfp_mask 0x1d20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 3631, tgid 3631 (syz-executor.3), ts 292435626344, free_ts 213696291047 prep_new_page mm/page_alloc.c:2457 [inline] get_page_from_freelist+0x1298/0x3b80 mm/page_alloc.c:4203 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5431 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272 alloc_slab_page mm/slub.c:1824 [inline] allocate_slab+0x26c/0x3c0 mm/slub.c:1969 new_slab mm/slub.c:2029 [inline] ___slab_alloc+0x99f/0xe10 mm/slub.c:3031 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3118 slab_alloc_node mm/slub.c:3209 [inline] slab_alloc mm/slub.c:3251 [inline] __kmem_cache_alloc_lru mm/slub.c:3258 [inline] kmem_cache_alloc_lru+0x513/0x730 mm/slub.c:3275 __d_alloc+0x32/0x960 fs/dcache.c:1769 d_alloc_pseudo+0x19/0x70 fs/dcache.c:1899 alloc_file_pseudo+0xc6/0x250 fs/file_table.c:262 sock_alloc_file+0x4f/0x190 net/socket.c:463 sock_map_fd net/socket.c:487 [inline] __sys_socket+0x1a4/0x240 net/socket.c:1644 __do_sys_socket net/socket.c:1649 [inline] __se_sys_socket net/socket.c:1647 [inline] __x64_sys_socket+0x6f/0xb0 net/socket.c:1647 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 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:1371 [inline] free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1421 free_unref_page_prepare mm/page_alloc.c:3344 [inline] free_unref_page+0x19/0x6a0 mm/page_alloc.c:3439 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2548 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:447 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:727 [inline] slab_alloc_node mm/slub.c:3243 [inline] slab_alloc mm/slub.c:3251 [inline] __kmem_cache_alloc_lru mm/slub.c:3258 [inline] kmem_cache_alloc+0x280/0x4d0 mm/slub.c:3268 kmem_cache_zalloc include/linux/slab.h:723 [inline] lsm_inode_alloc security/security.c:594 [inline] security_inode_alloc+0x34/0x160 security/security.c:1024 inode_init_always+0x5d8/0xf00 fs/inode.c:195 alloc_inode+0x82/0x230 fs/inode.c:267 new_inode_pseudo+0x14/0xe0 fs/inode.c:1018 sock_alloc+0x3c/0x260 net/socket.c:627 __sock_create+0xb9/0x790 net/socket.c:1479 sock_create net/socket.c:1566 [inline] __sys_socketpair+0x1be/0x570 net/socket.c:1698 __do_sys_socketpair net/socket.c:1751 [inline] __se_sys_socketpair net/socket.c:1748 [inline] __x64_sys_socketpair+0x93/0xf0 net/socket.c:1748 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 Memory state around the buggy address: ffff888072dba680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888072dba700: 00 00 00 fc fc fc fc fc fc fc fc fa fb fb fb fb >ffff888072dba780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888072dba800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888072dba880: fb fb fc fc fc fc fc fc fc fc 00 00 00 00 00 00 ==================================================================