================================================================== BUG: KASAN: use-after-free in ext4_insert_dentry+0x389/0x720 fs/ext4/namei.c:2155 Write of size 250 at addr ffff8881152dcf18 by task syz-executor167/298 CPU: 1 PID: 298 Comm: syz-executor167 Not tainted 6.1.115-syzkaller-00041-ga887a44ace2a #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:316 [inline] print_report+0x158/0x4e0 mm/kasan/report.c:427 kasan_report+0x13c/0x170 mm/kasan/report.c:531 kasan_check_range+0x294/0x2a0 mm/kasan/generic.c:189 memcpy+0x44/0x70 mm/kasan/shadow.c:66 ext4_insert_dentry+0x389/0x720 fs/ext4/namei.c:2155 add_dirent_to_buf+0x38c/0x780 fs/ext4/namei.c:2200 make_indexed_dir+0xf29/0x1590 fs/ext4/namei.c:2398 ext4_add_entry+0xbbf/0xed0 fs/ext4/namei.c:2504 ext4_mkdir+0x54f/0xce0 fs/ext4/namei.c:3081 vfs_mkdir+0x398/0x570 fs/namei.c:4105 do_mkdirat+0x1eb/0x450 fs/namei.c:4130 __do_sys_mkdirat fs/namei.c:4145 [inline] __se_sys_mkdirat fs/namei.c:4143 [inline] __x64_sys_mkdirat+0x89/0xa0 fs/namei.c:4143 x64_sys_call+0x6c6/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:259 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 RIP: 0033:0x7f8e8649a819 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 61 17 00 00 90 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:00007ffe77255668 EFLAGS: 00000246 ORIG_RAX: 0000000000000102 RAX: ffffffffffffffda RBX: 0030656c69662f2e RCX: 00007f8e8649a819 RDX: 0000000000000000 RSI: 00000000200005c0 RDI: 00000000ffffff9c RBP: 000000000000012b R08: 0000555500393932 R09: 0000555500393932 R10: 0000555500393932 R11: 0000000000000246 R12: 00007ffe77255770 R13: 00007ffe77255938 R14: 0000000000000001 R15: 0000000000000001 The buggy address belongs to the physical page: page:ffffea000454b700 refcount:3 mapcount:0 mapping:ffff88810054f650 index:0x3f pfn:0x1152dc memcg:ffff888100334000 aops:def_blk_aops ino:700000 flags: 0x420000000000204a(referenced|dirty|workingset|private|zone=1) raw: 420000000000204a 0000000000000000 dead000000000122 ffff88810054f650 raw: 000000000000003f ffff888123d6a498 00000003ffffffff ffff888100334000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Movable, gfp_mask 0x148c48(GFP_NOFS|__GFP_NOFAIL|__GFP_COMP|__GFP_HARDWALL|__GFP_MOVABLE), pid 298, tgid 298 (syz-executor167), ts 24597397389, free_ts 18917580587 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597 get_page_from_freelist+0x2980/0x2a10 mm/page_alloc.c:4439 __alloc_pages+0x234/0x610 mm/page_alloc.c:5728 __folio_alloc+0x15/0x40 mm/page_alloc.c:5760 __folio_alloc_node include/linux/gfp.h:245 [inline] folio_alloc include/linux/gfp.h:274 [inline] filemap_alloc_folio include/linux/pagemap.h:513 [inline] __filemap_get_folio+0x827/0xae0 mm/filemap.c:2017 pagecache_get_page+0x2f/0x110 mm/folio-compat.c:110 find_or_create_page include/linux/pagemap.h:654 [inline] grow_dev_page fs/buffer.c:989 [inline] grow_buffers fs/buffer.c:1054 [inline] __getblk_slow fs/buffer.c:1081 [inline] __getblk_gfp+0x205/0x7d0 fs/buffer.c:1376 sb_getblk include/linux/buffer_head.h:356 [inline] ext4_getblk+0x2a7/0x7b0 fs/ext4/inode.c:899 ext4_bread+0x2f/0x180 fs/ext4/inode.c:945 ext4_append+0x31f/0x5b0 fs/ext4/namei.c:83 make_indexed_dir+0x518/0x1590 fs/ext4/namei.c:2318 ext4_add_entry+0xbbf/0xed0 fs/ext4/namei.c:2504 ext4_mkdir+0x54f/0xce0 fs/ext4/namei.c:3081 vfs_mkdir+0x398/0x570 fs/namei.c:4105 do_mkdirat+0x1eb/0x450 fs/namei.c:4130 page last free stack trace: reset_page_owner include/linux/page_owner.h:26 [inline] free_pages_prepare mm/page_alloc.c:1498 [inline] free_pcp_prepare mm/page_alloc.c:1572 [inline] free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3511 free_unref_page_list+0xf1/0x7b0 mm/page_alloc.c:3659 release_pages+0xf7f/0xfe0 mm/swap.c:1063 free_pages_and_swap_cache+0x8a/0xa0 mm/swap_state.c:315 tlb_batch_pages_flush mm/mmu_gather.c:59 [inline] tlb_flush_mmu_free mm/mmu_gather.c:254 [inline] tlb_flush_mmu mm/mmu_gather.c:261 [inline] tlb_finish_mmu+0x1e0/0x3f0 mm/mmu_gather.c:361 exit_mmap+0x460/0xbe0 mm/mmap.c:3348 __mmput+0x95/0x310 kernel/fork.c:1298 mmput+0x56/0x170 kernel/fork.c:1321 exit_mm kernel/exit.c:568 [inline] do_exit+0xb29/0x2b80 kernel/exit.c:864 do_group_exit+0x21a/0x2d0 kernel/exit.c:1027 __do_sys_exit_group kernel/exit.c:1038 [inline] __se_sys_exit_group kernel/exit.c:1036 [inline] __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1036 x64_sys_call+0x610/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:232 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81 entry_SYSCALL_64_after_hwframe+0x68/0xd2 Memory state around the buggy address: ffff8881152dcf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8881152dcf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff8881152dd000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^