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

0 views
Skip to first unread message

syzbot

unread,
Jan 30, 2024, 10:06:29 PMJan 30
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6139f2a02fe0 Linux 5.15.148
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12702997e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=3292eb21c4b0adb2
dashboard link: https://syzkaller.appspot.com/bug?extid=caaaafd8611645a190df
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/8d3c4f91e092/disk-6139f2a0.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/34bd8a404e99/vmlinux-6139f2a0.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f1cd1a0b0f50/bzImage-6139f2a0.xz

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

loop0: detected capacity change from 0 to 512
==================================================================
BUG: KASAN: use-after-free in __ext4_iget+0x2ee/0x3f00 fs/ext4/inode.c:4641
Read of size 8 at addr ffff88808671efb0 by task syz-executor.0/19262

CPU: 0 PID: 19262 Comm: syz-executor.0 Not tainted 5.15.148-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb 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
__ext4_iget+0x2ee/0x3f00 fs/ext4/inode.c:4641
ext4_quota_enable fs/ext4/super.c:6367 [inline]
ext4_enable_quotas+0x54f/0xd40 fs/ext4/super.c:6403
ext4_fill_super+0x9598/0xa110 fs/ext4/super.c:4951
mount_bdev+0x2c9/0x3f0 fs/super.c:1387
legacy_get_tree+0xeb/0x180 fs/fs_context.c:611
vfs_get_tree+0x88/0x270 fs/super.c:1517
do_new_mount+0x2ba/0xb40 fs/namespace.c:3005
do_mount fs/namespace.c:3348 [inline]
__do_sys_mount fs/namespace.c:3556 [inline]
__se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3533
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7ff89d0d94aa
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 09 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 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:00007ff89b657ef8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ff89b657f80 RCX: 00007ff89d0d94aa
RDX: 0000000020000080 RSI: 0000000020000500 RDI: 00007ff89b657f40
RBP: 0000000020000080 R08: 00007ff89b657f80 R09: 0000000000004500
R10: 0000000000004500 R11: 0000000000000202 R12: 0000000020000500
R13: 00007ff89b657f40 R14: 00000000000004b4 R15: 000000000000002c
</TASK>

Allocated by task 18656:
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 fs/f2fs/f2fs.h:2644 [inline]
f2fs_alloc_inode+0x15d/0x5b0 fs/f2fs/super.c:1383
alloc_inode fs/inode.c:236 [inline]
iget_locked+0x194/0x7f0 fs/inode.c:1244
f2fs_iget+0x52/0x49c0 fs/f2fs/inode.c:489
f2fs_fill_super+0x6484/0x8350 fs/f2fs/super.c:4255
mount_bdev+0x2c9/0x3f0 fs/super.c:1387
legacy_get_tree+0xeb/0x180 fs/fs_context.c:611
vfs_get_tree+0x88/0x270 fs/super.c:1517
do_new_mount+0x2ba/0xb40 fs/namespace.c:3005
do_mount fs/namespace.c:3348 [inline]
__do_sys_mount fs/namespace.c:3556 [inline]
__se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3533
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

Last potentially related work creation:
kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
__call_rcu kernel/rcu/tree.c:3007 [inline]
call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3087
f2fs_put_super+0x726/0xd10 fs/f2fs/super.c:1618
generic_shutdown_super+0x136/0x2c0 fs/super.c:475
kill_block_super+0x7a/0xe0 fs/super.c:1414
kill_f2fs_super+0x2ff/0x3c0 fs/f2fs/super.c:4534
deactivate_locked_super+0xa0/0x110 fs/super.c:335
cleanup_mnt+0x44e/0x500 fs/namespace.c:1143
task_work_run+0x129/0x1a0 kernel/task_work.c:164
tracehook_notify_resume include/linux/tracehook.h:189 [inline]
exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:175
exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:208
__syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
syscall_exit_to_user_mode+0x5d/0x250 kernel/entry/common.c:301
do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x61/0xcb

Second to last potentially related work creation:
kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
__call_rcu kernel/rcu/tree.c:3007 [inline]
call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3087
f2fs_fill_super+0x6907/0x8350 fs/f2fs/super.c:4438
mount_bdev+0x2c9/0x3f0 fs/super.c:1387
legacy_get_tree+0xeb/0x180 fs/fs_context.c:611
vfs_get_tree+0x88/0x270 fs/super.c:1517
do_new_mount+0x2ba/0xb40 fs/namespace.c:3005
do_mount fs/namespace.c:3348 [inline]
__do_sys_mount fs/namespace.c:3556 [inline]
__se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3533
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff88808671e880
which belongs to the cache f2fs_inode_cache of size 2304
The buggy address is located 1840 bytes inside of
2304-byte region [ffff88808671e880, ffff88808671f180)
The buggy address belongs to the page:
page:ffffea000219c600 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88808671e880 pfn:0x86718
head:ffffea000219c600 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff88803fbacb01
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888146aba280
raw: ffff88808671e880 00000000800d0004 00000001ffffffff ffff88803fbacb01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Reclaimable, gfp_mask 0x1d2050(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_RECLAIMABLE), pid 16268, ts 465093170734, free_ts 454303551256
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:5421
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 fs/f2fs/f2fs.h:2644 [inline]
f2fs_alloc_inode+0x15d/0x5b0 fs/f2fs/super.c:1383
alloc_inode fs/inode.c:236 [inline]
new_inode_pseudo+0x60/0x210 fs/inode.c:937
new_inode+0x25/0x1d0 fs/inode.c:966
f2fs_new_inode+0x117/0x1150 fs/f2fs/namei.c:35
f2fs_create+0x161/0x14a0 fs/f2fs/namei.c:357
lookup_open fs/namei.c:3468 [inline]
open_last_lookups fs/namei.c:3538 [inline]
path_openat+0x12f6/0x2f20 fs/namei.c:3745
do_filp_open+0x21c/0x460 fs/namei.c:3775
do_sys_openat2+0x13b/0x500 fs/open.c:1211
do_sys_open fs/open.c:1227 [inline]
__do_sys_open fs/open.c:1235 [inline]
__se_sys_open fs/open.c:1231 [inline]
__x64_sys_open+0x221/0x270 fs/open.c:1231
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
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
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
getname_flags+0xb8/0x4e0 fs/namei.c:138
user_path_at_empty+0x2a/0x180 fs/namei.c:2882
user_path_at include/linux/namei.h:57 [inline]
vfs_statx+0x106/0x3b0 fs/stat.c:221
vfs_fstatat fs/stat.c:243 [inline]
__do_sys_newfstatat fs/stat.c:411 [inline]
__se_sys_newfstatat fs/stat.c:405 [inline]
__x64_sys_newfstatat+0x12c/0x1b0 fs/stat.c:405
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
ffff88808671ee80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808671ef00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88808671ef80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88808671f000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808671f080: 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.

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