[v5.15] KASAN: use-after-free Read in f2fs_destroy_extent_tree

0 views
Skip to first unread message

syzbot

unread,
Sep 30, 2024, 2:40:27 AMSep 30
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3a5928702e71 Linux 5.15.167
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=126dfd9f980000
kernel config: https://syzkaller.appspot.com/x/.config?x=4d3fd5cca89ae935
dashboard link: https://syzkaller.appspot.com/bug?extid=8aedc9aed9921d711a8e
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ef5025f3d708/disk-3a592870.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/776fbdad3aa8/vmlinux-3a592870.xz
kernel image: https://storage.googleapis.com/syzbot-assets/79541db5bd16/bzImage-3a592870.xz

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

==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in f2fs_destroy_extent_node fs/f2fs/extent_cache.c:789 [inline]
BUG: KASAN: use-after-free in f2fs_destroy_extent_tree+0x151/0x670 fs/f2fs/extent_cache.c:839
Read of size 4 at addr ffff888063568080 by task syz.3.890/8005

CPU: 1 PID: 8005 Comm: syz.3.890 Not tainted 5.15.167-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
print_address_description+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
instrument_atomic_read include/linux/instrumented.h:71 [inline]
atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
f2fs_destroy_extent_node fs/f2fs/extent_cache.c:789 [inline]
f2fs_destroy_extent_tree+0x151/0x670 fs/f2fs/extent_cache.c:839
f2fs_evict_inode+0x3b1/0x1510 fs/f2fs/inode.c:767
evict+0x529/0x930 fs/inode.c:622
f2fs_iget+0x1ca5/0x4b90 fs/f2fs/inode.c:566
f2fs_nfs_get_inode+0x70/0x100 fs/f2fs/super.c:3089
generic_fh_to_dentry+0x94/0xe0 fs/libfs.c:1044
exportfs_decode_fh_raw+0x140/0x590 fs/exportfs/expfs.c:436
exportfs_decode_fh+0x38/0x70 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+0x44c/0x960 fs/fhandle.c:223
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f4db6e97ff9
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:00007f4db52ef038 EFLAGS: 00000246 ORIG_RAX: 0000000000000130
RAX: ffffffffffffffda RBX: 00007f4db7050058 RCX: 00007f4db6e97ff9
RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000006
RBP: 00007f4db6f0a296 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f4db7050058 R15: 00007fff9cb024e8
</TASK>

Allocated by task 8004:
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+0x8e/0xc0 mm/kasan/common.c:467
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
f2fs_kmem_cache_alloc_nofail fs/f2fs/f2fs.h:2623 [inline]
f2fs_kmem_cache_alloc fs/f2fs/f2fs.h:2633 [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+0x58d/0xc50 fs/f2fs/extent_cache.c:404
do_read_inode fs/f2fs/inode.c:392 [inline]
f2fs_iget+0xfb0/0x4b90 fs/f2fs/inode.c:514
f2fs_nfs_get_inode+0x70/0x100 fs/f2fs/super.c:3089
generic_fh_to_dentry+0x94/0xe0 fs/libfs.c:1044
exportfs_decode_fh_raw+0x140/0x590 fs/exportfs/expfs.c:436
exportfs_decode_fh+0x38/0x70 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+0x44c/0x960 fs/fhandle.c:223
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 8004:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kmem_cache_free+0x91/0x1f0 mm/slub.c:3515
f2fs_destroy_extent_tree+0x382/0x670 fs/f2fs/extent_cache.c:845
f2fs_evict_inode+0x3b1/0x1510 fs/f2fs/inode.c:767
evict+0x529/0x930 fs/inode.c:622
f2fs_iget+0x1ca5/0x4b90 fs/f2fs/inode.c:566
f2fs_nfs_get_inode+0x70/0x100 fs/f2fs/super.c:3089
generic_fh_to_dentry+0x94/0xe0 fs/libfs.c:1044
exportfs_decode_fh_raw+0x140/0x590 fs/exportfs/expfs.c:436
exportfs_decode_fh+0x38/0x70 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+0x44c/0x960 fs/fhandle.c:223
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff888063568000
which belongs to the cache f2fs_extent_tree of size 136
The buggy address is located 128 bytes inside of
136-byte region [ffff888063568000, ffff888063568088)
The buggy address belongs to the page:
page:ffffea00018d5a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x63568
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff888146c798c0
raw: 0000000000000000 0000000080140014 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 8004, ts 365631850088, free_ts 320892407219
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
__alloc_pages+0x272/0x700 mm/page_alloc.c:5423
alloc_slab_page mm/slub.c:1775 [inline]
allocate_slab mm/slub.c:1912 [inline]
new_slab+0xbb/0x4b0 mm/slub.c:1975
___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
__slab_alloc mm/slub.c:3095 [inline]
slab_alloc_node mm/slub.c:3186 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0x18e/0x280 mm/slub.c:3233
f2fs_kmem_cache_alloc_nofail fs/f2fs/f2fs.h:2623 [inline]
f2fs_kmem_cache_alloc fs/f2fs/f2fs.h:2633 [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+0x58d/0xc50 fs/f2fs/extent_cache.c:404
do_read_inode fs/f2fs/inode.c:392 [inline]
f2fs_iget+0xfb0/0x4b90 fs/f2fs/inode.c:514
f2fs_nfs_get_inode+0x70/0x100 fs/f2fs/super.c:3089
generic_fh_to_dentry+0x94/0xe0 fs/libfs.c:1044
exportfs_decode_fh_raw+0x140/0x590 fs/exportfs/expfs.c:436
exportfs_decode_fh+0x38/0x70 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+0x44c/0x960 fs/fhandle.c:223
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1340 [inline]
free_pcp_prepare mm/page_alloc.c:1391 [inline]
free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
free_slab mm/slub.c:2015 [inline]
discard_slab mm/slub.c:2021 [inline]
__unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
do_slab_free mm/slub.c:3487 [inline]
___cache_free+0xe3/0x100 mm/slub.c:3506
qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
__kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
ptlock_alloc mm/memory.c:5526 [inline]
ptlock_init include/linux/mm.h:2230 [inline]
pmd_ptlock_init include/linux/mm.h:2316 [inline]
pgtable_pmd_page_ctor include/linux/mm.h:2352 [inline]
pmd_alloc_one include/asm-generic/pgalloc.h:129 [inline]
__pmd_alloc+0x136/0x850 mm/memory.c:4928
pmd_alloc include/linux/mm.h:2180 [inline]
__handle_mm_fault mm/memory.c:4717 [inline]
handle_mm_fault+0xf62/0x5960 mm/memory.c:4853
do_user_addr_fault arch/x86/mm/fault.c:1357 [inline]
handle_page_fault arch/x86/mm/fault.c:1445 [inline]
exc_page_fault+0x271/0x700 arch/x86/mm/fault.c:1501
asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568

Memory state around the buggy address:
ffff888063567f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888063568000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888063568080: fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffff888063568100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888063568180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


---
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 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

syzbot

unread,
Sep 30, 2024, 3:44:24 AMSep 30
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 3a5928702e71 Linux 5.15.167
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16534ea9980000
kernel config: https://syzkaller.appspot.com/x/.config?x=4d3fd5cca89ae935
dashboard link: https://syzkaller.appspot.com/bug?extid=8aedc9aed9921d711a8e
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10281d07980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14abfd9f980000
mounted in repro: https://storage.googleapis.com/syzbot-assets/ae6a8bcc8f29/mount_0.gz

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

F2FS-fs (loop1): sanity_check_inode: inode (ino=8) has corrupted i_xattr_nid: 218103808, run fsck to fix.
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in f2fs_destroy_extent_node fs/f2fs/extent_cache.c:789 [inline]
BUG: KASAN: use-after-free in f2fs_destroy_extent_tree+0x151/0x670 fs/f2fs/extent_cache.c:839
Read of size 4 at addr ffff88806e5ef080 by task syz-executor738/3604

CPU: 1 PID: 3604 Comm: syz-executor738 Not tainted 5.15.167-syzkaller #0
RIP: 0033:0x7fc2e8d66a39
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 81 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:00007fc2e8d02168 EFLAGS: 00000246 ORIG_RAX: 0000000000000130
RAX: ffffffffffffffda RBX: 00007fc2e8df2618 RCX: 00007fc2e8d66a39
RDX: 0000000000000000 RSI: 0000000020000000 RDI: 0000000000000004
RBP: 00007fc2e8df2610 R08: 00007ffc73ab54b7 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fc2e8df261c
R13: 000000000000006e R14: 00007ffc73ab53d0 R15: 00007ffc73ab54b8
</TASK>

Allocated by task 3576:
Freed by task 3576:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kmem_cache_free+0x91/0x1f0 mm/slub.c:3515
f2fs_destroy_extent_tree+0x382/0x670 fs/f2fs/extent_cache.c:845
f2fs_evict_inode+0x3b1/0x1510 fs/f2fs/inode.c:767
evict+0x529/0x930 fs/inode.c:622
f2fs_iget+0x1ca5/0x4b90 fs/f2fs/inode.c:566
f2fs_nfs_get_inode+0x70/0x100 fs/f2fs/super.c:3089
generic_fh_to_dentry+0x94/0xe0 fs/libfs.c:1044
exportfs_decode_fh_raw+0x140/0x590 fs/exportfs/expfs.c:436
exportfs_decode_fh+0x38/0x70 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+0x44c/0x960 fs/fhandle.c:223
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff88806e5ef000
which belongs to the cache f2fs_extent_tree of size 136
The buggy address is located 128 bytes inside of
136-byte region [ffff88806e5ef000, ffff88806e5ef088)
The buggy address belongs to the page:
page:ffffea0001b97bc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x6e5ef
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff88801e7963c0
raw: 0000000000000000 0000000080140014 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 3576, ts 55965798973, free_ts 15761265160
free_contig_range+0x95/0xf0 mm/page_alloc.c:9342
destroy_args+0xfe/0x980 mm/debug_vm_pgtable.c:1018
debug_vm_pgtable+0x40d/0x470 mm/debug_vm_pgtable.c:1331
do_one_initcall+0x22b/0x7a0 init/main.c:1302
do_initcall_level+0x157/0x210 init/main.c:1375
do_initcalls+0x49/0x90 init/main.c:1391
kernel_init_freeable+0x425/0x5c0 init/main.c:1615
kernel_init+0x19/0x290 init/main.c:1506
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Memory state around the buggy address:
ffff88806e5eef80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88806e5ef000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88806e5ef080: fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb
^
ffff88806e5ef100: fb fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc
ffff88806e5ef180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


---
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.
Reply all
Reply to author
Forward
0 new messages