syzbot


KASAN: use-after-free Read in sanity_check_extent_cache

Status: upstream: reported C repro on 2025/06/17 23:46
Bug presence: origin:lts
[Documentation on labels]
Reported-by: syzbot+92290a02305440f45ddf@syzkaller.appspotmail.com
First crash: 19d, last: 5d10h
Bug presence (2)
Date Name Commit Repro Result
2025/06/20 lts (merge base) 02b72ccb5f9d C [report] KASAN: use-after-free Read in sanity_check_extent_cache
2025/06/20 upstream (ToT) 75f5f23f8787 C Didn't crash
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in sanity_check_extent_cache origin:upstream missing-backport C error 2 18h09m 101d 0/3 upstream: reported C repro on 2025/03/28 08:10
upstream KASAN: slab-use-after-free Read in sanity_check_extent_cache f2fs C done 5 391d 434d 27/29 fixed on 2024/08/14 03:44
Last patch testing requests (2)
Created Duration User Patch Repo Result
2025/07/02 09:37 44m retest repro android14-6.1 report log
2025/07/02 09:37 12m retest repro android14-6.1 report log

Sample crash report:
 </TASK>
==================================================================
BUG: KASAN: use-after-free in sanity_check_extent_cache+0x3cc/0x480 fs/f2fs/extent_cache.c:47
Read of size 4 at addr ffff888107ec5b88 by task syz-executor213/336

CPU: 1 PID: 336 Comm: syz-executor213 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:
 <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
 __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:0x7f70b9100b89
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 18 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f70b909c218 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007f70b91996b8 RCX: 00007f70b9100b89
RDX: 0000000000101000 RSI: 0000200000000080 RDI: 00000000ffffff9c
RBP: 00007f70b91996b0 R08: 00007fff3bc01ee7 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000246 R12: 0000200000000080
R13: 0000200000000280 R14: 0032656c69662f2e R15: 0033656c69662f2e
 </TASK>

Allocated by task 303:
 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 303:
 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 ffff888107ec5b40
 which belongs to the cache f2fs_extent_tree of size 88
The buggy address is located 72 bytes inside of
 88-byte region [ffff888107ec5b40, ffff888107ec5b98)

The buggy address belongs to the physical page:
page:ffffea00041fb140 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x107ec5
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 0000000000000000 dead000000000122 ffff888112423800
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 0x12c50(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_RECLAIMABLE), pid 297, tgid 296 (syz-executor213), ts 36043269780, free_ts 0
 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_owner free stack trace missing

Memory state around the buggy address:
 ffff888107ec5a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888107ec5b00: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff888107ec5b80: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc
                      ^
 ffff888107ec5c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888107ec5c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
F2FS-fs (loop1): sanity_check_extent_cache: inode (ino=8) extent info [14338, 0, 2147549187] is incorrect, run fsck to fix

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/06/17 23:50 android14-6.1 ba4506940166 e77fae15 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-android-6-1 KASAN: use-after-free Read in sanity_check_extent_cache
2025/06/17 23:39 android14-6.1 ba4506940166 e77fae15 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-android-6-1 KASAN: use-after-free Read in sanity_check_extent_cache
2025/06/17 23:07 android14-6.1 ba4506940166 e77fae15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in sanity_check_extent_cache
* Struck through repros no longer work on HEAD.