RDX: 0000000000101000 RSI: 0000200000000080 RDI: ffffffffffffff9c RBP: 00007f0cd9c10b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000001 R14: 00007f0cd9db6080 R15: 00007fff44016d48 ================================================================== BUG: KASAN: use-after-free in sanity_check_extent_cache+0x3cc/0x480 fs/f2fs/extent_cache.c:47 Read of size 4 at addr ffff888104537fc0 by task syz.4.397/1369 CPU: 1 PID: 1369 Comm: syz.4.397 Not tainted 6.1.138-syzkaller-00010-gba4506940166 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: __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 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:350 sanity_check_extent_cache+0x3cc/0x480 fs/f2fs/extent_cache.c:47 do_read_inode fs/f2fs/inode.c:457 [inline] f2fs_iget+0x3312/0x4cb0 fs/f2fs/inode.c:508 f2fs_lookup+0x366/0xab0 fs/f2fs/namei.c:484 lookup_open fs/namei.c:3459 [inline] open_last_lookups fs/namei.c:3549 [inline] path_openat+0xff3/0x2f50 fs/namei.c:3779 do_filp_open+0x1c1/0x3c0 fs/namei.c:3809 do_sys_openat2+0x185/0x7e0 fs/open.c:1341 do_sys_open fs/open.c:1357 [inline] __do_sys_openat fs/open.c:1373 [inline] __se_sys_openat fs/open.c:1368 [inline] __x64_sys_openat+0x136/0x160 fs/open.c:1368 x64_sys_call+0x783/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:258 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:0x7f0cd9b8e929 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:00007f0cdaa00038 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 00007f0cd9db6080 RCX: 00007f0cd9b8e929 RDX: 0000000000101000 RSI: 0000200000000080 RDI: ffffffffffffff9c RBP: 00007f0cd9c10b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000001 R14: 00007f0cd9db6080 R15: 00007fff44016d48 Allocated by task 1323: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_alloc_info+0x25/0x30 mm/kasan/generic.c:505 __kasan_slab_alloc+0x72/0x80 mm/kasan/common.c:333 kasan_slab_alloc include/linux/kasan.h:202 [inline] slab_post_alloc_hook+0x4f/0x2d0 mm/slab.h:768 slab_alloc_node mm/slub.c:3421 [inline] slab_alloc mm/slub.c:3431 [inline] __kmem_cache_alloc_lru mm/slub.c:3438 [inline] kmem_cache_alloc+0x16e/0x330 mm/slub.c:3447 f2fs_kmem_cache_alloc fs/f2fs/f2fs.h:-1 [inline] __grab_extent_tree+0x19d/0x430 fs/f2fs/extent_cache.c:335 f2fs_init_read_extent_tree+0x3d4/0x7e0 fs/f2fs/extent_cache.c:406 do_read_inode fs/f2fs/inode.c:454 [inline] f2fs_iget+0x3302/0x4cb0 fs/f2fs/inode.c:508 f2fs_lookup+0x366/0xab0 fs/f2fs/namei.c:484 __lookup_slow+0x2c7/0x3f0 fs/namei.c:1689 lookup_slow+0x57/0x70 fs/namei.c:1706 walk_component+0x2f4/0x420 fs/namei.c:1997 lookup_last fs/namei.c:2454 [inline] path_lookupat+0x180/0x490 fs/namei.c:2478 filename_lookup+0x1f0/0x500 fs/namei.c:2507 user_path_at_empty+0x47/0x1c0 fs/namei.c:2904 user_path_at include/linux/namei.h:57 [inline] do_sys_truncate+0xa3/0x190 fs/open.c:133 __do_sys_truncate fs/open.c:147 [inline] __se_sys_truncate fs/open.c:145 [inline] __x64_sys_truncate+0x5b/0x70 fs/open.c:145 x64_sys_call+0x679/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:77 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 Freed by task 1323: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x31/0x50 mm/kasan/generic.c:516 ____kasan_slab_free+0x132/0x180 mm/kasan/common.c:241 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249 kasan_slab_free include/linux/kasan.h:178 [inline] slab_free_hook mm/slub.c:1745 [inline] slab_free_freelist_hook+0xc2/0x190 mm/slub.c:1771 slab_free mm/slub.c:3686 [inline] kmem_cache_free+0x12d/0x300 mm/slub.c:3711 __destroy_extent_tree+0x305/0x500 fs/f2fs/extent_cache.c:1135 f2fs_destroy_extent_tree+0x17/0x30 fs/f2fs/extent_cache.c:1146 f2fs_evict_inode+0x4eb/0x14f0 fs/f2fs/inode.c:778 evict+0x493/0x890 fs/inode.c:705 iput_final fs/inode.c:1834 [inline] iput+0x620/0x670 fs/inode.c:1860 iget_failed+0x17a/0x1c0 fs/bad_inode.c:250 f2fs_iget+0x218c/0x4cb0 fs/f2fs/inode.c:561 f2fs_lookup+0x366/0xab0 fs/f2fs/namei.c:484 __lookup_slow+0x2c7/0x3f0 fs/namei.c:1689 lookup_slow+0x57/0x70 fs/namei.c:1706 walk_component+0x2f4/0x420 fs/namei.c:1997 lookup_last fs/namei.c:2454 [inline] path_lookupat+0x180/0x490 fs/namei.c:2478 filename_lookup+0x1f0/0x500 fs/namei.c:2507 user_path_at_empty+0x47/0x1c0 fs/namei.c:2904 user_path_at include/linux/namei.h:57 [inline] do_sys_truncate+0xa3/0x190 fs/open.c:133 __do_sys_truncate fs/open.c:147 [inline] __se_sys_truncate fs/open.c:145 [inline] __x64_sys_truncate+0x5b/0x70 fs/open.c:145 x64_sys_call+0x679/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:77 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 The buggy address belongs to the object at ffff888104537f78 which belongs to the cache f2fs_extent_tree of size 88 The buggy address is located 72 bytes inside of 88-byte region [ffff888104537f78, ffff888104537fd0) The buggy address belongs to the physical page: page:ffffea0004114dc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x104537 flags: 0x4000000000000200(slab|zone=1) raw: 4000000000000200 0000000000000000 dead000000000122 ffff88811163d200 raw: 0000000000000000 0000000080220022 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Reclaimable, gfp_mask 0x112c50(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 1323, tgid 1322 (syz.4.397), ts 54783626124, free_ts 54613749878 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+0x2c7b/0x2cf0 mm/page_alloc.c:4539 __alloc_pages+0x19e/0x3a0 mm/page_alloc.c:5842 alloc_slab_page+0x6e/0xf0 include/linux/gfp.h:-1 allocate_slab mm/slub.c:1962 [inline] new_slab+0x98/0x3d0 mm/slub.c:2015 ___slab_alloc+0x6f6/0xb50 mm/slub.c:3203 __slab_alloc+0x5e/0xa0 mm/slub.c:3302 slab_alloc_node mm/slub.c:3387 [inline] slab_alloc mm/slub.c:3431 [inline] __kmem_cache_alloc_lru mm/slub.c:3438 [inline] kmem_cache_alloc+0x1b0/0x330 mm/slub.c:3447 f2fs_kmem_cache_alloc fs/f2fs/f2fs.h:-1 [inline] __grab_extent_tree+0x19d/0x430 fs/f2fs/extent_cache.c:335 f2fs_init_read_extent_tree+0x3d4/0x7e0 fs/f2fs/extent_cache.c:406 do_read_inode fs/f2fs/inode.c:454 [inline] f2fs_iget+0x3302/0x4cb0 fs/f2fs/inode.c:508 f2fs_lookup+0x366/0xab0 fs/f2fs/namei.c:484 __lookup_slow+0x2c7/0x3f0 fs/namei.c:1689 lookup_slow+0x57/0x70 fs/namei.c:1706 walk_component+0x2f4/0x420 fs/namei.c:1997 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+0x8f/0x530 mm/page_alloc.c:3677 free_the_page mm/page_alloc.c:830 [inline] __free_pages+0x67/0x100 mm/page_alloc.c:5931 __free_slab+0xca/0x1a0 mm/slub.c:2039 free_slab mm/slub.c:2054 [inline] discard_slab+0x29/0x40 mm/slub.c:2060 __slab_free+0x201/0x280 mm/slub.c:3599 do_slab_free mm/slub.c:3640 [inline] ___cache_free+0xbf/0xd0 mm/slub.c:3696 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0xc6/0x140 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x14a/0x170 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x24/0x80 mm/kasan/common.c:310 kasan_slab_alloc include/linux/kasan.h:202 [inline] slab_post_alloc_hook+0x4f/0x2d0 mm/slab.h:768 slab_alloc_node mm/slub.c:3421 [inline] __kmem_cache_alloc_node+0x192/0x2c0 mm/slub.c:3462 kmalloc_trace+0x29/0xb0 mm/slab_common.c:1028 kmalloc include/linux/slab.h:563 [inline] kzalloc include/linux/slab.h:699 [inline] kobject_uevent_env+0x287/0x730 lib/kobject_uevent.c:539 disk_event_uevent block/disk-events.c:181 [inline] disk_force_media_change+0x192/0x2b0 block/disk-events.c:305 __loop_clr_fd+0x3ab/0x690 drivers/block/loop.c:1170 Memory state around the buggy address: ffff888104537e80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888104537f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fa >ffff888104537f80: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc ^ ffff888104538000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff888104538080: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc ================================================================== F2FS-fs (loop4): sanity_check_extent_cache: inode (ino=8) extent info [14338, 0, 2147549187] is incorrect, run fsck to fix