EXT4-fs error (device loop0): ext4_xattr_inode_iget:409: comm syz.0.16: error while reading EA inode 1 err=-117
EXT4-fs (loop0): 1 orphan inode deleted
EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue. Quota mode: none.
==================================================================
BUG: KASAN: use-after-free in ext4_insert_dentry+0x366/0x6c0 fs/ext4/namei.c:2155
Write of size 250 at addr ffff88806a2f6f18 by task syz.0.16/4991

CPU: 1 PID: 4991 Comm: syz.0.16 Not tainted 5.15.173-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
 memcpy+0x3c/0x60 mm/kasan/shadow.c:66
 ext4_insert_dentry+0x366/0x6c0 fs/ext4/namei.c:2155
 add_dirent_to_buf+0x384/0x7d0 fs/ext4/namei.c:2200
 make_indexed_dir+0xf34/0x15a0 fs/ext4/namei.c:2398
 ext4_add_entry+0xde2/0x12b0 fs/ext4/namei.c:2504
 ext4_mkdir+0x54f/0xce0 fs/ext4/namei.c:3081
 vfs_mkdir+0x3b6/0x590 fs/namei.c:4065
 do_mkdirat+0x260/0x520 fs/namei.c:4090
 __do_sys_mkdirat fs/namei.c:4105 [inline]
 __se_sys_mkdirat fs/namei.c:4103 [inline]
 __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4103
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f6e7caea809
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6e7bd68058 EFLAGS: 00000246 ORIG_RAX: 0000000000000102
RAX: ffffffffffffffda RBX: 00007f6e7ccaffa0 RCX: 00007f6e7caea809
RDX: 5be60480b9579340 RSI: 0000000020000940 RDI: ffffffffffffff9c
RBP: 00007f6e7cb5d93e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f6e7ccaffa0 R15: 00007ffc15bacd18
 </TASK>

The buggy address belongs to the page:
page:ffffea0001a8bd80 refcount:3 mapcount:0 mapping:ffff888140895af0 index:0x3f pfn:0x6a2f6
memcg:ffff888077470000
aops:def_blk_aops ino:700000
flags: 0xfff0000000202a(referenced|dirty|active|private|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff0000000202a 0000000000000000 dead000000000122 ffff888140895af0
raw: 000000000000003f ffff88801cdf1658 00000003ffffffff ffff888077470000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x108c48(GFP_NOFS|__GFP_NOFAIL|__GFP_HARDWALL|__GFP_MOVABLE), pid 4991, ts 117038896146, free_ts 117038035356
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5464
 __page_cache_alloc+0xd4/0x4a0 mm/filemap.c:1022
 pagecache_get_page+0xa91/0x1010 mm/filemap.c:1940
 find_or_create_page include/linux/pagemap.h:420 [inline]
 grow_dev_page fs/buffer.c:949 [inline]
 grow_buffers fs/buffer.c:1014 [inline]
 __getblk_slow fs/buffer.c:1041 [inline]
 __getblk_gfp+0x22a/0xaf0 fs/buffer.c:1336
 sb_getblk include/linux/buffer_head.h:361 [inline]
 ext4_getblk+0x259/0x710 fs/ext4/inode.c:876
 ext4_bread+0x2a/0x170 fs/ext4/inode.c:922
 ext4_append+0x31f/0x5c0 fs/ext4/namei.c:83
 make_indexed_dir+0x515/0x15a0 fs/ext4/namei.c:2318
 ext4_add_entry+0xde2/0x12b0 fs/ext4/namei.c:2504
 ext4_mkdir+0x54f/0xce0 fs/ext4/namei.c:3081
 vfs_mkdir+0x3b6/0x590 fs/namei.c:4065
 do_mkdirat+0x260/0x520 fs/namei.c:4090
 __do_sys_mkdirat fs/namei.c:4105 [inline]
 __se_sys_mkdirat fs/namei.c:4103 [inline]
 __x64_sys_mkdirat+0x85/0x90 fs/namei.c:4103
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page_list+0x1f7/0x8e0 mm/page_alloc.c:3433
 release_pages+0x1bb9/0x1f40 mm/swap.c:963
 __pagevec_release+0x80/0xf0 mm/swap.c:983
 pagevec_release include/linux/pagevec.h:81 [inline]
 shmem_undo_range+0x67a/0x1b50 mm/shmem.c:964
 shmem_truncate_range mm/shmem.c:1063 [inline]
 shmem_evict_inode+0x21b/0xa00 mm/shmem.c:1147
 evict+0x529/0x930 fs/inode.c:622
 __dentry_kill+0x436/0x650 fs/dcache.c:586
 dentry_kill+0xbb/0x290
 dput+0xd8/0x1a0 fs/dcache.c:893
 do_renameat2+0xe1c/0x1700 fs/namei.c:4987
 __do_sys_rename fs/namei.c:5031 [inline]
 __se_sys_rename fs/namei.c:5029 [inline]
 __x64_sys_rename+0x82/0x90 fs/namei.c:5029
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
 ffff88806a2f6f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88806a2f6f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88806a2f7000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                   ^
 ffff88806a2f7080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88806a2f7100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================