==================================================================
BUG: KASAN: use-after-free in ext4_insert_dentry+0x388/0x710 fs/ext4/namei.c:2155
Write of size 251 at addr ffff888124209f14 by task syz-executor376/289

CPU: 1 PID: 289 Comm: syz-executor376 Not tainted 6.1.134-syzkaller-00016-ga0fa2316cce1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/19/2025
Call Trace:
 <TASK>
 __dump_stack+0x21/0x24 lib/dump_stack.c:88
 dump_stack_lvl+0xee/0x150 lib/dump_stack.c:106
 print_address_description+0x71/0x210 mm/kasan/report.c:316
 print_report+0x4a/0x60 mm/kasan/report.c:427
 kasan_report+0x122/0x150 mm/kasan/report.c:531
 check_region_inline mm/kasan/generic.c:-1 [inline]
 kasan_check_range+0x280/0x290 mm/kasan/generic.c:189
 memcpy+0x44/0x70 mm/kasan/shadow.c:66
 ext4_insert_dentry+0x388/0x710 fs/ext4/namei.c:2155
 add_dirent_to_buf+0x2ac/0x670 fs/ext4/namei.c:2200
 make_indexed_dir+0xe55/0x14a0 fs/ext4/namei.c:2398
 ext4_add_entry+0xb45/0xd70 fs/ext4/namei.c:2504
 ext4_add_nondir+0x97/0x270 fs/ext4/namei.c:2845
 ext4_symlink+0x842/0x9b0 fs/ext4/namei.c:3482
 vfs_symlink+0x261/0x3f0 fs/namei.c:4470
 do_symlinkat+0x124/0x5a0 fs/namei.c:4499
 __do_sys_symlink fs/namei.c:4521 [inline]
 __se_sys_symlink fs/namei.c:4519 [inline]
 __x64_sys_symlink+0x7e/0x90 fs/namei.c:4519
 x64_sys_call+0x369/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:89
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f343f279cd9
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:00007ffd7dbd7918 EFLAGS: 00000246 ORIG_RAX: 0000000000000058
RAX: ffffffffffffffda RBX: 0000200000000000 RCX: 00007f343f279cd9
RDX: 00007f343f279cd9 RSI: 0000200000000cc0 RDI: 0000200000000dc0
RBP: 0030656c69662f2e R08: 6c616b7a79732f2e R09: 6c616b7a79732f2e
R10: 6c616b7a79732f2e R11: 0000000000000246 R12: 0000200000000180
R13: 00007ffd7dbd7b08 R14: 0000000000000001 R15: 0000000000000001
 </TASK>

The buggy address belongs to the physical page:
page:ffffea0004908240 refcount:3 mapcount:0 mapping:ffff88810054d850 index:0x3f pfn:0x124209
memcg:ffff888100336000
aops:def_blk_aops ino:700000
flags: 0x420000000000204a(referenced|dirty|workingset|private|zone=1)
raw: 420000000000204a 0000000000000000 dead000000000122 ffff88810054d850
raw: 000000000000003f ffff888122609b28 00000003ffffffff ffff888100336000
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 289, tgid 289 (syz-executor376), ts 29071114979, free_ts 28877052334
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1f5/0x210 mm/page_alloc.c:2637
 prep_new_page+0x1c/0x110 mm/page_alloc.c:2644
 get_page_from_freelist+0x2c6e/0x2ce0 mm/page_alloc.c:4539
 __alloc_pages+0x19e/0x3a0 mm/page_alloc.c:5838
 __folio_alloc+0x12/0x40 mm/page_alloc.c:5870
 __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+0x6ec/0x980 mm/filemap.c:2018
 pagecache_get_page+0x2b/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+0x217/0x7d0 fs/buffer.c:1376
 sb_getblk include/linux/buffer_head.h:356 [inline]
 ext4_getblk+0x26c/0x6d0 fs/ext4/inode.c:899
 ext4_bread+0x2b/0x170 fs/ext4/inode.c:945
 ext4_append+0x2c3/0x560 fs/ext4/namei.c:83
 make_indexed_dir+0x55d/0x14a0 fs/ext4/namei.c:2318
 ext4_add_entry+0xb45/0xd70 fs/ext4/namei.c:2504
 ext4_add_nondir+0x97/0x270 fs/ext4/namei.c:2845
 ext4_symlink+0x842/0x9b0 fs/ext4/namei.c:3482
 vfs_symlink+0x261/0x3f0 fs/namei.c:4470
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1545 [inline]
 free_pcp_prepare mm/page_alloc.c:1619 [inline]
 free_unref_page_prepare+0x742/0x750 mm/page_alloc.c:3581
 free_unref_page_list+0xba/0x7c0 mm/page_alloc.c:3729
 release_pages+0xad1/0xb20 mm/swap.c:1043
 free_pages_and_swap_cache+0x86/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+0x1aa/0x370 mm/mmu_gather.c:361
 unmap_region+0x28d/0x2e0 mm/mmap.c:2402
 do_mas_align_munmap+0xb94/0x11b0 mm/mmap.c:2668
 do_mas_munmap+0x241/0x2b0 mm/mmap.c:2726
 __vm_munmap+0x19f/0x2f0 mm/mmap.c:3025
 __do_sys_munmap mm/mmap.c:3051 [inline]
 __se_sys_munmap mm/mmap.c:3047 [inline]
 __x64_sys_munmap+0x6b/0x80 mm/mmap.c:3047
 x64_sys_call+0x8a/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:12
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Memory state around the buggy address:
 ffff888124209f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888124209f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88812420a000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                   ^
 ffff88812420a080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88812420a100: ff ff ff ff ff ff ff ff ff ff ff ff