EXT4-fs error (device loop4): ext4_readdir:260: inode #2: block 48: comm syz-executor: path /4/file0: bad entry in directory: rec_len is smaller than minimal - offset=980, inode=0, rec_len=0, size=1024 fake=0
==================================================================
BUG: KASAN: use-after-free in ext4_read_inline_data fs/ext4/inline.c:209 [inline]
BUG: KASAN: use-after-free in ext4_read_inline_dir+0x48b/0xdf0 fs/ext4/inline.c:1483
Read of size 836 at addr ffff88805f331205 by task syz-executor/5221

CPU: 0 UID: 0 PID: 5221 Comm: syz-executor Not tainted 6.11.0-rc6-syzkaller-00048-gc7fb1692dc01 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:93 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189
 __asan_memcpy+0x29/0x70 mm/kasan/shadow.c:105
 ext4_read_inline_data fs/ext4/inline.c:209 [inline]
 ext4_read_inline_dir+0x48b/0xdf0 fs/ext4/inline.c:1483
 ext4_readdir+0x3bb/0x3500 fs/ext4/dir.c:158
 iterate_dir+0x57a/0x810 fs/readdir.c:108
 __do_sys_getdents64 fs/readdir.c:407 [inline]
 __se_sys_getdents64+0x20d/0x4f0 fs/readdir.c:392
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1e719af093
Code: c1 66 0f 1f 44 00 00 48 83 c4 08 48 89 ef 5b 5d e9 42 43 f8 ff 66 90 b8 ff ff ff 7f 48 39 c2 48 0f 47 d0 b8 d9 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 05 c3 0f 1f 40 00 48 c7 c2 a8 ff ff ff f7 d8
RSP: 002b:00007ffc76748868 EFLAGS: 00000293 ORIG_RAX: 00000000000000d9
RAX: ffffffffffffffda RBX: 000055557fd62640 RCX: 00007f1e719af093
RDX: 0000000000008000 RSI: 000055557fd62640 RDI: 0000000000000006
RBP: 000055557fd62614 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000001000 R11: 0000000000000293 R12: ffffffffffffffa8
R13: 0000000000000016 R14: 000055557fd62610 R15: 00007ffc7674bc00
 </TASK>

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:ffff88807c0d90b0 index:0xa34 pfn:0x5f331
memcg:ffff88802230c000
aops:shmem_aops ino:415 dentry name:"memfd:syzkaller"
flags: 0xfff0000004003c(referenced|uptodate|dirty|lru|swapbacked|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff0000004003c ffffea00017ccc08 ffffea00017ccc88 ffff88807c0d90b0
raw: 0000000000000a34 0000000000000000 00000001ffffffff ffff88802230c000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Movable, gfp_mask 0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), pid 5452, tgid 5451 (syz.2.25), ts 73770159319, free_ts 71160213453
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1500
 prep_new_page mm/page_alloc.c:1508 [inline]
 get_page_from_freelist+0x2e4c/0x2f10 mm/page_alloc.c:3446
 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4702
 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2263
 folio_alloc_mpol_noprof+0x36/0x50 mm/mempolicy.c:2281
 shmem_alloc_folio mm/shmem.c:1722 [inline]
 shmem_alloc_and_add_folio+0x2cf/0x14f0 mm/shmem.c:1782
 shmem_get_folio_gfp+0x8dc/0x2370 mm/shmem.c:2188
 shmem_get_folio mm/shmem.c:2293 [inline]
 shmem_write_begin+0x170/0x4d0 mm/shmem.c:2898
 generic_perform_write+0x399/0x840 mm/filemap.c:4019
 shmem_file_write_iter+0xfc/0x120 mm/shmem.c:3074
 new_sync_write fs/read_write.c:497 [inline]
 vfs_write+0xa72/0xc90 fs/read_write.c:590
 ksys_write+0x1a0/0x2c0 fs/read_write.c:643
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 5218 tgid 5218 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1101 [inline]
 free_unref_folios+0x100f/0x1ac0 mm/page_alloc.c:2667
 folios_put_refs+0x76e/0x860 mm/swap.c:1039
 folio_batch_release include/linux/pagevec.h:101 [inline]
 shmem_undo_range+0x6de/0x1df0 mm/shmem.c:1023
 shmem_truncate_range mm/shmem.c:1132 [inline]
 shmem_evict_inode+0x29b/0xa80 mm/shmem.c:1260
 evict+0x532/0x950 fs/inode.c:704
 __dentry_kill+0x20d/0x630 fs/dcache.c:615
 dput+0x19f/0x2b0 fs/dcache.c:857
 __fput+0x5f8/0x8a0 fs/file_table.c:430
 task_work_run+0x24f/0x310 kernel/task_work.c:228
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218
 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff88805f331100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88805f331180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88805f331200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                   ^
 ffff88805f331280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88805f331300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================