syzbot


KASAN: use-after-free Read in sanity_check_extent_cache

Status: upstream: reported C repro on 2025/03/28 08:10
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+ea091fe1a7b823bed2e7@syzkaller.appspotmail.com
First crash: 29d, last: 6d09h
Bug presence (1)
Date Name Commit Repro Result
2025/03/30 upstream (ToT) 7f2ff7b62617 C [report] unregister_netdevice: waiting for DEV to become free
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in sanity_check_extent_cache f2fs C done 5 318d 361d 27/28 fixed on 2024/08/14 03:44

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in sanity_check_extent_cache+0x22c/0x2c8 fs/f2fs/extent_cache.c:35
Read of size 4 at addr ffff0000e2317080 by task syz-executor110/4313

CPU: 1 PID: 4313 Comm: syz-executor110 Not tainted 6.1.134-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x174/0x4c0 mm/kasan/report.c:427
 kasan_report+0xd4/0x130 mm/kasan/report.c:531
 __asan_report_load4_noabort+0x2c/0x38 mm/kasan/report_generic.c:350
 sanity_check_extent_cache+0x22c/0x2c8 fs/f2fs/extent_cache.c:35
 do_read_inode fs/f2fs/inode.c:454 [inline]
 f2fs_iget+0x2e78/0x4860 fs/f2fs/inode.c:505
 f2fs_nfs_get_inode+0x80/0x118 fs/f2fs/super.c:3151
 generic_fh_to_dentry+0x9c/0x104 fs/libfs.c:1072
 f2fs_fh_to_dentry+0x44/0x58 fs/f2fs/super.c:3165
 exportfs_decode_fh_raw+0x118/0x524 fs/exportfs/expfs.c:435
 exportfs_decode_fh+0x50/0x80 fs/exportfs/expfs.c:575
 do_handle_to_path fs/fhandle.c:152 [inline]
 handle_to_path fs/fhandle.c:207 [inline]
 do_handle_open+0x56c/0x998 fs/fhandle.c:223
 __do_sys_open_by_handle_at fs/fhandle.c:265 [inline]
 __se_sys_open_by_handle_at fs/fhandle.c:256 [inline]
 __arm64_sys_open_by_handle_at+0x80/0x94 fs/fhandle.c:256
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Allocated by task 4305:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
 kasan_save_alloc_info+0x24/0x30 mm/kasan/generic.c:505
 __kasan_slab_alloc+0x74/0x8c mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x74/0x458 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x230/0x37c mm/slub.c:3422
 f2fs_kmem_cache_alloc_nofail fs/f2fs/f2fs.h:2781 [inline]
 f2fs_kmem_cache_alloc fs/f2fs/f2fs.h:2791 [inline]
 __grab_extent_tree+0x168/0x3b4 fs/f2fs/extent_cache.c:384
 f2fs_init_read_extent_tree+0x2a0/0x878 fs/f2fs/extent_cache.c:455
 do_read_inode fs/f2fs/inode.c:452 [inline]
 f2fs_iget+0x2e70/0x4860 fs/f2fs/inode.c:505
 f2fs_nfs_get_inode+0x80/0x118 fs/f2fs/super.c:3151
 generic_fh_to_dentry+0x9c/0x104 fs/libfs.c:1072
 f2fs_fh_to_dentry+0x44/0x58 fs/f2fs/super.c:3165
 exportfs_decode_fh_raw+0x118/0x524 fs/exportfs/expfs.c:435
 exportfs_decode_fh+0x50/0x80 fs/exportfs/expfs.c:575
 do_handle_to_path fs/fhandle.c:152 [inline]
 handle_to_path fs/fhandle.c:207 [inline]
 do_handle_open+0x56c/0x998 fs/fhandle.c:223
 __do_sys_open_by_handle_at fs/fhandle.c:265 [inline]
 __se_sys_open_by_handle_at fs/fhandle.c:256 [inline]
 __arm64_sys_open_by_handle_at+0x80/0x94 fs/fhandle.c:256
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Freed by task 4305:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
 kasan_save_free_info+0x38/0x5c mm/kasan/generic.c:516
 ____kasan_slab_free+0x144/0x1c0 mm/kasan/common.c:236
 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:244
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 kmem_cache_free+0x2f0/0x588 mm/slub.c:3683
 __destroy_extent_tree fs/f2fs/extent_cache.c:1011 [inline]
 f2fs_destroy_extent_tree+0x2e0/0x758 fs/f2fs/extent_cache.c:1022
 f2fs_evict_inode+0x3e0/0x15b4 fs/f2fs/inode.c:770
 evict+0x418/0x894 fs/inode.c:705
 iput_final fs/inode.c:1834 [inline]
 iput+0x7c0/0x8a4 fs/inode.c:1860
 iget_failed+0x154/0x1a4 fs/bad_inode.c:250
 f2fs_iget+0x1cbc/0x4860 fs/f2fs/inode.c:558
 f2fs_nfs_get_inode+0x80/0x118 fs/f2fs/super.c:3151
 generic_fh_to_dentry+0x9c/0x104 fs/libfs.c:1072
 f2fs_fh_to_dentry+0x44/0x58 fs/f2fs/super.c:3165
 exportfs_decode_fh_raw+0x118/0x524 fs/exportfs/expfs.c:435
 exportfs_decode_fh+0x50/0x80 fs/exportfs/expfs.c:575
 do_handle_to_path fs/fhandle.c:152 [inline]
 handle_to_path fs/fhandle.c:207 [inline]
 do_handle_open+0x56c/0x998 fs/fhandle.c:223
 __do_sys_open_by_handle_at fs/fhandle.c:265 [inline]
 __se_sys_open_by_handle_at fs/fhandle.c:256 [inline]
 __arm64_sys_open_by_handle_at+0x80/0x94 fs/fhandle.c:256
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

The buggy address belongs to the object at ffff0000e2317000
 which belongs to the cache f2fs_extent_tree of size 136
The buggy address is located 128 bytes inside of
 136-byte region [ffff0000e2317000, ffff0000e2317088)

The buggy address belongs to the physical page:
page:00000000e4f9c5b8 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x122317
flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000200 0000000000000000 dead000000000122 ffff0000c6ef0900
raw: 0000000000000000 0000000080140014 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000e2316f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff0000e2317000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff0000e2317080: fb fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00
                   ^
 ffff0000e2317100: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc
 ffff0000e2317180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
F2FS-fs (loop3): sanity_check_extent_cache: inode (ino=8) extent info [5634, 0, 3] is incorrect, run fsck to fix

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/04/19 23:20 linux-6.1.y 420102835862 2a20f901 .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in sanity_check_extent_cache
2025/03/28 08:09 linux-6.1.y 344a09659766 6c09fb82 .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in sanity_check_extent_cache
* Struck through repros no longer work on HEAD.