[f2fs?] KASAN: use-after-free Read in flush_nat_entries

4 views
Skip to first unread message

syzbot

unread,
Feb 12, 2023, 12:18:54 AM2/12/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: a8ad60f2af58 Linux 4.14.305
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16a9a593480000
kernel config: https://syzkaller.appspot.com/x/.config?x=2f23dc9802022031
dashboard link: https://syzkaller.appspot.com/bug?extid=042d27b5c9f7eb3bd228
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10a5d6c0c80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10a94a0b480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c38348fd389d/disk-a8ad60f2.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/3a775d221689/vmlinux-a8ad60f2.xz
kernel image: https://storage.googleapis.com/syzbot-assets/32e71e04d2b4/bzImage-a8ad60f2.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/fb7bf00fc01e/mount_0.gz

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

F2FS-fs (loop0): Can't find valid F2FS filesystem in 1th superblock
F2FS-fs (loop0): invalid crc value
F2FS-fs (loop0): Found nat_bits in checkpoint
F2FS-fs (loop0): Mounted with checkpoint version = 753bd00b
==================================================================
BUG: KASAN: use-after-free in f2fs_test_bit fs/f2fs/f2fs.h:1928 [inline]
BUG: KASAN: use-after-free in current_nat_addr fs/f2fs/node.h:215 [inline]
BUG: KASAN: use-after-free in get_next_nat_page fs/f2fs/node.c:133 [inline]
BUG: KASAN: use-after-free in __flush_nat_entry_set fs/f2fs/node.c:2480 [inline]
BUG: KASAN: use-after-free in flush_nat_entries+0x2190/0x25e0 fs/f2fs/node.c:2571
Read of size 1 at addr ffff8880aacb1610 by task syz-executor477/7971

CPU: 1 PID: 7971 Comm: syz-executor477 Not tainted 4.14.305-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:251
kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:350
kasan_report mm/kasan/report.c:408 [inline]
__asan_report_load1_noabort+0x68/0x70 mm/kasan/report.c:426
f2fs_test_bit fs/f2fs/f2fs.h:1928 [inline]
current_nat_addr fs/f2fs/node.h:215 [inline]
get_next_nat_page fs/f2fs/node.c:133 [inline]
__flush_nat_entry_set fs/f2fs/node.c:2480 [inline]
flush_nat_entries+0x2190/0x25e0 fs/f2fs/node.c:2571
write_checkpoint+0x311/0x45f0 fs/f2fs/checkpoint.c:1411
f2fs_sync_fs+0x178/0x3f0 fs/f2fs/super.c:873
__sync_filesystem fs/sync.c:39 [inline]
sync_filesystem fs/sync.c:67 [inline]
sync_filesystem+0x185/0x230 fs/sync.c:48
generic_shutdown_super+0x70/0x370 fs/super.c:432
kill_block_super+0x95/0xe0 fs/super.c:1161
deactivate_locked_super+0x6c/0xd0 fs/super.c:319
deactivate_super+0x7f/0xa0 fs/super.c:350
cleanup_mnt+0x186/0x2c0 fs/namespace.c:1183
task_work_run+0x11f/0x190 kernel/task_work.c:113
exit_task_work include/linux/task_work.h:22 [inline]
do_exit+0xa44/0x2850 kernel/exit.c:915
do_group_exit+0x100/0x2e0 kernel/exit.c:1037
SYSC_exit_group kernel/exit.c:1048 [inline]
SyS_exit_group+0x19/0x20 kernel/exit.c:1046
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3
RIP: 0033:0x7f3ee670e9d9
RSP: 002b:00007ffd3cd3efa8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007f3ee678b330 RCX: 00007f3ee670e9d9
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000001
RBP: 0000000000000001 R08: ffffffffffffffc0 R09: 00007f3ee6785e40
R10: 00007ffd3cd3eec0 R11: 0000000000000246 R12: 00007f3ee678b330
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001

Allocated by task 7931:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
kmem_cache_alloc+0x124/0x3c0 mm/slab.c:3552
getname_flags+0xc8/0x550 fs/namei.c:138
user_path_at_empty+0x2a/0x50 fs/namei.c:2631
user_path_at include/linux/namei.h:57 [inline]
user_statfs+0x78/0x110 fs/statfs.c:87
SYSC_statfs fs/statfs.c:179 [inline]
SyS_statfs+0x65/0xb0 fs/statfs.c:176
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

Freed by task 7931:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kmem_cache_free+0x7c/0x2b0 mm/slab.c:3758
putname+0xcd/0x110 fs/namei.c:259
filename_lookup+0x37b/0x510 fs/namei.c:2386
user_path_at include/linux/namei.h:57 [inline]
user_statfs+0x78/0x110 fs/statfs.c:87
SYSC_statfs fs/statfs.c:179 [inline]
SyS_statfs+0x65/0xb0 fs/statfs.c:176
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

The buggy address belongs to the object at ffff8880aacb0b00
which belongs to the cache names_cache of size 4096
The buggy address is located 2832 bytes inside of
4096-byte region [ffff8880aacb0b00, ffff8880aacb1b00)
The buggy address belongs to the page:
page:ffffea0002ab2c00 count:1 mapcount:0 mapping:ffff8880aacb0b00 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffff8880aacb0b00 0000000000000000 0000000100000001
raw: ffffea0002ab2ca0 ffffea00024eeca0 ffff88823f8c1200 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880aacb1500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880aacb1580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880aacb1600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880aacb1680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880aacb1700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages