[v6.1] KASAN: use-after-free Read in sanity_check_extent_cache

4 views
Skip to first unread message

syzbot

unread,
Mar 28, 2025, 4:10:29 AM3/28/25
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 344a09659766 Linux 6.1.131
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1420b804580000
kernel config: https://syzkaller.appspot.com/x/.config?x=14d5dbae75afa499
dashboard link: https://syzkaller.appspot.com/bug?extid=ea091fe1a7b823bed2e7
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1620b804580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=102e9bb0580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8c94453bbad3/disk-344a0965.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/6bf26518c790/vmlinux-344a0965.xz
kernel image: https://storage.googleapis.com/syzbot-assets/424da9a470eb/Image-344a0965.gz.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/bbaa9879ae18/mount_0.gz
fsck result: failed (log: https://syzkaller.appspot.com/x/fsck.log?x=1020b804580000)

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+ea091f...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in sanity_check_extent_cache+0x22c/0x2c8 fs/f2fs/extent_cache.c:35
Read of size 4 at addr ffff0000e1a732d8 by task syz-executor828/4340

CPU: 0 PID: 4340 Comm: syz-executor828 Not tainted 6.1.131-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 ffff0000e1a73258
which belongs to the cache f2fs_extent_tree of size 136
The buggy address is located 128 bytes inside of
136-byte region [ffff0000e1a73258, ffff0000e1a732e0)

The buggy address belongs to the physical page:
page:0000000091c4d52f refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x121a73
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:
ffff0000e1a73180: fc fc fa fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000e1a73200: fb fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb
>ffff0000e1a73280: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
^
ffff0000e1a73300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff0000e1a73380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
F2FS-fs (loop4): sanity_check_extent_cache: inode (ino=8) extent info [5634, 0, 3] is incorrect, run fsck to fix


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages