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

6 views
Skip to first unread message

syzbot

unread,
Apr 13, 2023, 3:02:47 PM4/13/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 4fdad925aa1a Linux 5.15.107
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=120626f3c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=d9bc1b227ee6c412
dashboard link: https://syzkaller.appspot.com/bug?extid=148f4a3e4d77faf4c927
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/6a7f3b0f6a27/disk-4fdad925.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/db34418039b7/vmlinux-4fdad925.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4e96525a950a/bzImage-4fdad925.xz

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

loop1: detected capacity change from 0 to 40427
==================================================================
BUG: KASAN: use-after-free in d_inode include/linux/dcache.h:526 [inline]
BUG: KASAN: use-after-free in relay_switch_subbuf+0x285/0x6e0 kernel/relay.c:676
Read of size 8 at addr ffff8880771e2f18 by task syz-executor.1/32479

CPU: 0 PID: 32479 Comm: syz-executor.1 Not tainted 5.15.107-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/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
d_inode include/linux/dcache.h:526 [inline]
relay_switch_subbuf+0x285/0x6e0 kernel/relay.c:676
relay_reserve include/linux/relay.h:248 [inline]
trace_note+0x553/0x6f0 kernel/trace/blktrace.c:95
trace_note_tsk+0xa9/0x140 kernel/trace/blktrace.c:126
__blk_add_trace+0x9f5/0xd70 kernel/trace/blktrace.c:267
blk_add_trace_bio+0x280/0x2d0 kernel/trace/blktrace.c:905
trace_block_bio_queue include/trace/events/block.h:332 [inline]
submit_bio_checks+0x182c/0x1920 block/blk-core.c:893
__submit_bio+0x5a1/0x850 block/blk-core.c:917
__submit_bio_noacct_mq block/blk-core.c:1003 [inline]
submit_bio_noacct+0x955/0xb30 block/blk-core.c:1033
submit_bio+0x2dd/0x560 block/blk-core.c:1095
submit_bh fs/buffer.c:3062 [inline]
__bread_slow fs/buffer.c:1180 [inline]
__bread_gfp+0x1c2/0x390 fs/buffer.c:1384
sb_bread include/linux/buffer_head.h:337 [inline]
read_raw_super_block fs/f2fs/super.c:3730 [inline]
f2fs_fill_super+0x474/0x8350 fs/f2fs/super.c:3993
mount_bdev+0x26d/0x3a0 fs/super.c:1378
legacy_get_tree+0xeb/0x180 fs/fs_context.c:610
vfs_get_tree+0x88/0x270 fs/super.c:1508
do_new_mount+0x28b/0xad0 fs/namespace.c:2994
do_mount fs/namespace.c:3337 [inline]
__do_sys_mount fs/namespace.c:3545 [inline]
__se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3522
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:0x7f65a67d969a
Code: 48 c7 c2 b8 ff ff ff f7 d8 64 89 02 b8 ff ff ff ff eb d2 e8 b8 04 00 00 0f 1f 84 00 00 00 00 00 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f65a4d49f88 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00000000000054e6 RCX: 00007f65a67d969a
RDX: 0000000020000040 RSI: 0000000020000080 RDI: 00007f65a4d49fe0
RBP: 00007f65a4d4a020 R08: 00007f65a4d4a020 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 0000000020000040
R13: 0000000020000080 R14: 00007f65a4d49fe0 R15: 0000000020000000
</TASK>

Allocated by task 32306:
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
__d_alloc+0x2a/0x700 fs/dcache.c:1744
d_alloc+0x48/0x1d0 fs/dcache.c:1823
__lookup_hash+0xca/0x240 fs/namei.c:1556
filename_create+0x28d/0x530 fs/namei.c:3766
do_symlinkat+0xf6/0x600 fs/namei.c:4377
__do_sys_symlinkat fs/namei.c:4404 [inline]
__se_sys_symlinkat fs/namei.c:4401 [inline]
__x64_sys_symlinkat+0x95/0xa0 fs/namei.c:4401
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

Freed by task 32454:
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
rcu_do_batch kernel/rcu/tree.c:2509 [inline]
rcu_core+0xa15/0x1650 kernel/rcu/tree.c:2749
__do_softirq+0x3b3/0x93a kernel/softirq.c:558

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:2993 [inline]
call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3073
__dentry_kill+0x4f4/0x650 fs/dcache.c:596
shrink_dentry_list+0x398/0x6a0 fs/dcache.c:1176
shrink_dcache_parent+0xc9/0x480
vfs_rmdir+0x34e/0x460 fs/namei.c:4082
do_rmdir+0x362/0x670 fs/namei.c:4139
__do_sys_unlinkat fs/namei.c:4319 [inline]
__se_sys_unlinkat fs/namei.c:4313 [inline]
__x64_sys_unlinkat+0xdc/0xf0 fs/namei.c:4313
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

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:2993 [inline]
call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3073
__dentry_kill+0x4f4/0x650 fs/dcache.c:596
shrink_dentry_list+0x398/0x6a0 fs/dcache.c:1176
shrink_dcache_parent+0xc9/0x480
vfs_rmdir+0x34e/0x460 fs/namei.c:4082
do_rmdir+0x362/0x670 fs/namei.c:4139
__do_sys_unlinkat fs/namei.c:4319 [inline]
__se_sys_unlinkat fs/namei.c:4313 [inline]
__x64_sys_unlinkat+0xdc/0xf0 fs/namei.c:4313
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 ffff8880771e2eb0
which belongs to the cache dentry of size 312
The buggy address is located 104 bytes inside of
312-byte region [ffff8880771e2eb0, ffff8880771e2fe8)
The buggy address belongs to the page:
page:ffffea0001dc7880 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880771e2758 pfn:0x771e2
head:ffffea0001dc7880 order:1 compound_mapcount:0
memcg:ffff888052589301
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea000060e108 ffffea00013cac88 ffff888011dc6640
raw: ffff8880771e2758 000000000015000f 00000001ffffffff ffff888052589301
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Reclaimable, gfp_mask 0xd20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_RECLAIMABLE), pid 2972, ts 14810431321, free_ts 11248807290
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
__d_alloc+0x2a/0x700 fs/dcache.c:1744
d_alloc fs/dcache.c:1823 [inline]
d_alloc_parallel+0xca/0x1390 fs/dcache.c:2575
__lookup_slow+0x111/0x3d0 fs/namei.c:1644
lookup_slow+0x53/0x70 fs/namei.c:1676
walk_component+0x48c/0x610 fs/namei.c:1972
link_path_walk+0x642/0xd90
path_lookupat+0xa9/0x450 fs/namei.c:2450
filename_lookup+0x230/0x5c0 fs/namei.c:2480
user_path_at_empty+0x40/0x180 fs/namei.c:2853
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
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_contig_range+0x95/0xf0 mm/page_alloc.c:9321
destroy_args+0xfe/0x97f mm/debug_vm_pgtable.c:1018
debug_vm_pgtable+0x40d/0x462 mm/debug_vm_pgtable.c:1331
do_one_initcall+0x22b/0x7a0 init/main.c:1306
do_initcall_level+0x157/0x207 init/main.c:1379
do_initcalls+0x49/0x86 init/main.c:1395
kernel_init_freeable+0x43c/0x5c5 init/main.c:1619
kernel_init+0x19/0x290 init/main.c:1510
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Memory state around the buggy address:
ffff8880771e2e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc
ffff8880771e2e80: fc fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb
>ffff8880771e2f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880771e2f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
ffff8880771e3000: fc fc fc fc fc 00 00 00 00 00 00 00 00 00 00 00
==================================================================


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

unread,
Aug 23, 2023, 5:04:54 AM8/23/23
to syzkaller...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages