syzbot


KASAN: use-after-free Read in f2fs_iget

Status: upstream: reported C repro on 2024/05/05 12:48
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+0b1e85354f790743db08@syzkaller.appspotmail.com
First crash: 376d, last: 13d
Fix bisection: failed (error log, bisect log)
  
Bug presence (3)
Date Name Commit Repro Result
2024/08/04 linux-5.15.y (ToT) 7e89efd3ae1c C [report] KASAN: use-after-free Read in f2fs_iget
2024/05/05 upstream (ToT) 7367539ad4b0 C [report] KASAN: slab-use-after-free Read in sanity_check_extent_cache
2024/08/04 upstream (ToT) a5dbd76a8942 C Didn't crash
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 UBSAN: array-index-out-of-bounds in f2fs_iget origin:upstream C done 1 635d 635d 3/3 fixed on 2023/10/10 21:47
upstream UBSAN: array-index-out-of-bounds in f2fs_iget f2fs C done 6 622d 667d 23/28 fixed on 2023/10/12 12:48
Last patch testing requests (3)
Created Duration User Patch Repo Result
2025/03/14 05:04 10m retest repro linux-5.15.y report log
2024/12/31 22:09 10m retest repro linux-5.15.y report log
2024/10/14 23:49 0m retest repro linux-5.15.y error
Fix bisection attempts (8)
Created Duration User Patch Repo Result
2025/03/01 09:50 2m fix candidate upstream error job log
2024/12/09 17:49 14m fix candidate upstream error job log
2024/09/15 19:22 1m fix candidate upstream error job log
2024/08/06 03:11 1m fix candidate upstream error job log
2024/06/13 07:46 16m bisect fix linux-5.15.y error job log
2024/06/12 20:08 1m bisect fix linux-5.15.y error job log
2024/06/12 17:40 1m bisect fix linux-5.15.y error job log
2024/06/05 19:37 10m bisect fix linux-5.15.y error job log
marked invalid by web-security-scanner@google.com

Sample crash report:
 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584
==================================================================
BUG: KASAN: use-after-free in sanity_check_inode fs/f2fs/inode.c:275 [inline]
BUG: KASAN: use-after-free in do_read_inode fs/f2fs/inode.c:415 [inline]
BUG: KASAN: use-after-free in f2fs_iget+0x4188/0x5170 fs/f2fs/inode.c:514
Read of size 4 at addr ffff0000de7e5028 by task syz-executor966/4047

CPU: 1 PID: 4047 Comm: syz-executor966 Not tainted 5.15.181-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/19/2025
Call trace:
 dump_backtrace+0x0/0x43c arch/arm64/kernel/stacktrace.c:152
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
 __dump_stack+0x30/0x40 lib/dump_stack.c:88
 dump_stack_lvl+0xf8/0x160 lib/dump_stack.c:106
 print_address_description+0x78/0x30c mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0xec/0x15c mm/kasan/report.c:451
 __asan_report_load4_noabort+0x44/0x50 mm/kasan/report_generic.c:308
 sanity_check_inode fs/f2fs/inode.c:275 [inline]
 do_read_inode fs/f2fs/inode.c:415 [inline]
 f2fs_iget+0x4188/0x5170 fs/f2fs/inode.c:514
 f2fs_nfs_get_inode+0x80/0x118 fs/f2fs/super.c:3102
 generic_fh_to_dentry+0x9c/0x104 fs/libfs.c:1044
 f2fs_fh_to_dentry+0x44/0x58 fs/f2fs/super.c:3116
 exportfs_decode_fh_raw+0x10c/0x49c fs/exportfs/expfs.c:436
 exportfs_decode_fh+0x50/0x80 fs/exportfs/expfs.c:576
 do_handle_to_path fs/fhandle.c:152 [inline]
 handle_to_path fs/fhandle.c:207 [inline]
 do_handle_open+0x514/0x8e8 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/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Allocated by task 4029:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x8c/0xcc mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x74/0x408 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x1e0/0x3e4 mm/slub.c:3233
 f2fs_kmem_cache_alloc_nofail fs/f2fs/f2fs.h:2625 [inline]
 f2fs_kmem_cache_alloc fs/f2fs/f2fs.h:2635 [inline]
 __grab_extent_tree fs/f2fs/extent_cache.c:295 [inline]
 __f2fs_init_extent_tree fs/f2fs/extent_cache.c:381 [inline]
 f2fs_init_extent_tree+0x43c/0xaac fs/f2fs/extent_cache.c:404
 do_read_inode fs/f2fs/inode.c:392 [inline]
 f2fs_iget+0x10c4/0x5170 fs/f2fs/inode.c:514
 f2fs_nfs_get_inode+0x80/0x118 fs/f2fs/super.c:3102
 generic_fh_to_dentry+0x9c/0x104 fs/libfs.c:1044
 f2fs_fh_to_dentry+0x44/0x58 fs/f2fs/super.c:3116
 exportfs_decode_fh_raw+0x10c/0x49c fs/exportfs/expfs.c:436
 exportfs_decode_fh+0x50/0x80 fs/exportfs/expfs.c:576
 do_handle_to_path fs/fhandle.c:152 [inline]
 handle_to_path fs/fhandle.c:207 [inline]
 do_handle_open+0x514/0x8e8 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/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Freed by task 4029:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x84 mm/kasan/common.c:46
 kasan_set_free_info+0x28/0x4c mm/kasan/generic.c:360
 ____kasan_slab_free+0x118/0x164 mm/kasan/common.c:366
 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0x128/0x1e8 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kmem_cache_free+0xdc/0x3b4 mm/slub.c:3515
 f2fs_destroy_extent_tree+0x2d0/0x688 fs/f2fs/extent_cache.c:845
 f2fs_evict_inode+0x32c/0x1520 fs/f2fs/inode.c:769
 evict+0x3c8/0x810 fs/inode.c:647
 iput_final fs/inode.c:1769 [inline]
 iput+0x6c4/0x77c fs/inode.c:1795
 iget_failed+0x148/0x194 fs/bad_inode.c:250
 f2fs_iget+0x58c/0x5170 fs/f2fs/inode.c:566
 f2fs_nfs_get_inode+0x80/0x118 fs/f2fs/super.c:3102
 generic_fh_to_dentry+0x9c/0x104 fs/libfs.c:1044
 f2fs_fh_to_dentry+0x44/0x58 fs/f2fs/super.c:3116
 exportfs_decode_fh_raw+0x10c/0x49c fs/exportfs/expfs.c:436
 exportfs_decode_fh+0x50/0x80 fs/exportfs/expfs.c:576
 do_handle_to_path fs/fhandle.c:152 [inline]
 handle_to_path fs/fhandle.c:207 [inline]
 do_handle_open+0x514/0x8e8 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/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

The buggy address belongs to the object at ffff0000de7e5000
 which belongs to the cache f2fs_extent_tree of size 136
The buggy address is located 40 bytes inside of
 136-byte region [ffff0000de7e5000, ffff0000de7e5088)
The buggy address belongs to the page:
page:000000005ed5591e refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11e7e5
flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000200 0000000000000000 dead000000000122 ffff0000c6983c80
raw: 0000000000000000 0000000080140014 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000de7e4f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff0000de7e4f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff0000de7e5000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
 ffff0000de7e5080: fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb
 ffff0000de7e5100: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc
==================================================================
F2FS-fs (loop1): sanity_check_inode: inode (ino=8) extent info [5634, 0, 3] is incorrect, run fsck to fix
==================================================================
BUG: KASAN: double-free or invalid-free in slab_free mm/slub.c:3499 [inline]
BUG: KASAN: double-free or invalid-free in kmem_cache_free+0xdc/0x3b4 mm/slub.c:3515

CPU: 1 PID: 4047 Comm: syz-executor966 Tainted: G    B             5.15.181-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/19/2025
Call trace:
 dump_backtrace+0x0/0x43c arch/arm64/kernel/stacktrace.c:152
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
 __dump_stack+0x30/0x40 lib/dump_stack.c:88
 dump_stack_lvl+0xf8/0x160 lib/dump_stack.c:106
 print_address_description+0x78/0x30c mm/kasan/report.c:248
 kasan_report_invalid_free+0x4c/0x7c mm/kasan/report.c:373
 ____kasan_slab_free+0x134/0x164 mm/kasan/common.c:-1
 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0x128/0x1e8 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kmem_cache_free+0xdc/0x3b4 mm/slub.c:3515
 f2fs_destroy_extent_tree+0x2d0/0x688 fs/f2fs/extent_cache.c:845
 f2fs_evict_inode+0x32c/0x1520 fs/f2fs/inode.c:769
 evict+0x3c8/0x810 fs/inode.c:647
 iput_final fs/inode.c:1769 [inline]
 iput+0x6c4/0x77c fs/inode.c:1795
 iget_failed+0x148/0x194 fs/bad_inode.c:250
 f2fs_iget+0x58c/0x5170 fs/f2fs/inode.c:566
 f2fs_nfs_get_inode+0x80/0x118 fs/f2fs/super.c:3102
 generic_fh_to_dentry+0x9c/0x104 fs/libfs.c:1044
 f2fs_fh_to_dentry+0x44/0x58 fs/f2fs/super.c:3116
 exportfs_decode_fh_raw+0x10c/0x49c fs/exportfs/expfs.c:436
 exportfs_decode_fh+0x50/0x80 fs/exportfs/expfs.c:576
 do_handle_to_path fs/fhandle.c:152 [inline]
 handle_to_path fs/fhandle.c:207 [inline]
 do_handle_open+0x514/0x8e8 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/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Allocated by task 4029:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x8c/0xcc mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x74/0x408 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x1e0/0x3e4 mm/slub.c:3233
 f2fs_kmem_cache_alloc_nofail fs/f2fs/f2fs.h:2625 [inline]
 f2fs_kmem_cache_alloc fs/f2fs/f2fs.h:2635 [inline]
 __grab_extent_tree fs/f2fs/extent_cache.c:295 [inline]
 __f2fs_init_extent_tree fs/f2fs/extent_cache.c:381 [inline]
 f2fs_init_extent_tree+0x43c/0xaac fs/f2fs/extent_cache.c:404
 do_read_inode fs/f2fs/inode.c:392 [inline]
 f2fs_iget+0x10c4/0x5170 fs/f2fs/inode.c:514
 f2fs_nfs_get_inode+0x80/0x118 fs/f2fs/super.c:3102
 generic_fh_to_dentry+0x9c/0x104 fs/libfs.c:1044
 f2fs_fh_to_dentry+0x44/0x58 fs/f2fs/super.c:3116
 exportfs_decode_fh_raw+0x10c/0x49c fs/exportfs/expfs.c:436
 exportfs_decode_fh+0x50/0x80 fs/exportfs/expfs.c:576
 do_handle_to_path fs/fhandle.c:152 [inline]
 handle_to_path fs/fhandle.c:207 [inline]
 do_handle_open+0x514/0x8e8 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/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Freed by task 4029:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x84 mm/kasan/common.c:46
 kasan_set_free_info+0x28/0x4c mm/kasan/generic.c:360
 ____kasan_slab_free+0x118/0x164 mm/kasan/common.c:366
 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0x128/0x1e8 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kmem_cache_free+0xdc/0x3b4 mm/slub.c:3515
 f2fs_destroy_extent_tree+0x2d0/0x688 fs/f2fs/extent_cache.c:845
 f2fs_evict_inode+0x32c/0x1520 fs/f2fs/inode.c:769
 evict+0x3c8/0x810 fs/inode.c:647
 iput_final fs/inode.c:1769 [inline]
 iput+0x6c4/0x77c fs/inode.c:1795
 iget_failed+0x148/0x194 fs/bad_inode.c:250
 f2fs_iget+0x58c/0x5170 fs/f2fs/inode.c:566
 f2fs_nfs_get_inode+0x80/0x118 fs/f2fs/super.c:3102
 generic_fh_to_dentry+0x9c/0x104 fs/libfs.c:1044
 f2fs_fh_to_dentry+0x44/0x58 fs/f2fs/super.c:3116
 exportfs_decode_fh_raw+0x10c/0x49c fs/exportfs/expfs.c:436
 exportfs_decode_fh+0x50/0x80 fs/exportfs/expfs.c:576
 do_handle_to_path fs/fhandle.c:152 [inline]
 handle_to_path fs/fhandle.c:207 [inline]
 do_handle_open+0x514/0x8e8 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/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x78/0x1e0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0xcc/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

The buggy address belongs to the object at ffff0000de7e5000
 which belongs to the cache f2fs_extent_tree of size 136
The buggy address is located 0 bytes inside of
 136-byte region [ffff0000de7e5000, ffff0000de7e5088)
The buggy address belongs to the page:
page:000000005ed5591e refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11e7e5
flags: 0x5ffc00000000200(slab|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000000200 0000000000000000 dead000000000122 ffff0000c6983c80
raw: 0000000000000000 0000000080140014 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000de7e4f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff0000de7e4f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff0000de7e5000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff0000de7e5080: fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb
 ffff0000de7e5100: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/05/03 17:45 linux-5.15.y 16fdf2c7111b b0714e37 .config console log report syz / log C [disk image] [vmlinux] [kernel image] [mounted in repro (corrupt fs)] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in f2fs_iget
2024/05/05 13:43 linux-5.15.y 284087d4f7d5 610f2a54 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in f2fs_iget
2024/05/05 12:48 linux-5.15.y 284087d4f7d5 610f2a54 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in f2fs_iget
* Struck through repros no longer work on HEAD.