syzbot


KASAN: slab-out-of-bounds Write in legacy_parse_param

Status: fixed on 2022/01/27 16:02
Reported-by: syzbot+06938f44e92a5cc9d5b7@syzkaller.appspotmail.com
Fix commit: eadde287a62e vfs: fs_context: fix up param length parsing in legacy_parse_param
First crash: 274d, last: 274d

Cause bisection: failed (bisect log)
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream general protection fault in legacy_parse_param C done 20 194d 456d 23/24 upstream: reported C repro on 2021/07/03 05:41
android-54 KASAN: slab-out-of-bounds Write in legacy_parse_param C 2 274d 274d 0/2 upstream: reported C repro on 2022/01/01 00:53

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in legacy_parse_param+0x5b0/0x830 fs/fs_context.c:548
Write of size 92 at addr ffff888108197000 by task syz-executor313/406

CPU: 1 PID: 406 Comm: syz-executor313 Not tainted 5.10.89-syzkaller-00788-g9b28b48fb343 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233
 __kasan_report+0x142/0x220 mm/kasan/report.c:419
 kasan_report+0x51/0x70 mm/kasan/report.c:436
 check_region_inline mm/kasan/generic.c:135 [inline]
 kasan_check_range+0x2b6/0x2f0 mm/kasan/generic.c:186
 memcpy+0x44/0x70 mm/kasan/shadow.c:66
 legacy_parse_param+0x5b0/0x830 fs/fs_context.c:548
 vfs_parse_fs_param+0x218/0x4d0 fs/fs_context.c:117
 vfs_fsconfig_locked fs/fsopen.c:265 [inline]
 __do_sys_fsconfig fs/fsopen.c:439 [inline]
 __se_sys_fsconfig+0xba3/0xff0 fs/fsopen.c:314
 __x64_sys_fsconfig+0xbf/0xd0 fs/fsopen.c:314
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f84c8542a29
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f84c84f4308 EFLAGS: 00000246 ORIG_RAX: 00000000000001af
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f84c8542a29
RDX: 0000000020000280 RSI: 0000000000000001 RDI: 0000000000000003
RBP: 00007f84c85ca3e8 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000200000c0 R11: 0000000000000246 R12: 00007f84c85ca3e0
R13: 0073666775626564 R14: 00007f84c84f4400 R15: 0000000000022000

Allocated by task 406:
 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:428 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516
 kasan_kmalloc include/linux/kasan.h:269 [inline]
 kmem_cache_alloc_trace+0x210/0x3a0 mm/slub.c:2975
 kmalloc include/linux/slab.h:552 [inline]
 legacy_parse_param+0x504/0x830 fs/fs_context.c:541
 vfs_parse_fs_param+0x218/0x4d0 fs/fs_context.c:117
 vfs_fsconfig_locked fs/fsopen.c:265 [inline]
 __do_sys_fsconfig fs/fsopen.c:439 [inline]
 __se_sys_fsconfig+0xba3/0xff0 fs/fsopen.c:314
 __x64_sys_fsconfig+0xbf/0xd0 fs/fsopen.c:314
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff888108196000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 0 bytes to the right of
 4096-byte region [ffff888108196000, ffff888108197000)
The buggy address belongs to the page:
page:ffffea0004206400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x108190
head:ffffea0004206400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff888100042c00
raw: 0000000000000000 0000000080040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, ts 962746206, free_ts 0
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0xa74/0xa90 mm/page_alloc.c:4063
 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5106
 alloc_slab_page mm/slub.c:1807 [inline]
 allocate_slab+0x6b/0x350 mm/slub.c:1809
 new_slab mm/slub.c:1870 [inline]
 new_slab_objects mm/slub.c:2629 [inline]
 ___slab_alloc+0x143/0x2f0 mm/slub.c:2792
 __slab_alloc mm/slub.c:2832 [inline]
 slab_alloc_node mm/slub.c:2914 [inline]
 slab_alloc mm/slub.c:2956 [inline]
 kmem_cache_alloc_trace+0x278/0x3a0 mm/slub.c:2973
 kmalloc include/linux/slab.h:552 [inline]
 kzalloc include/linux/slab.h:664 [inline]
 kobject_uevent_env+0x282/0x1400 lib/kobject_uevent.c:524
 kobject_uevent+0x1f/0x30 lib/kobject_uevent.c:642
 device_add+0xfd4/0x1590 drivers/base/core.c:3222
 device_register+0x1d/0x20 drivers/base/core.c:3314
 register_memory drivers/base/memory.c:556 [inline]
 init_memory_block+0x225/0x380 drivers/base/memory.c:588
 add_memory_block drivers/base/memory.c:605 [inline]
 memory_dev_init+0x234/0x2f8 drivers/base/memory.c:741
 driver_init+0x3b/0x42 drivers/base/init.c:36
 do_basic_setup+0x18/0x81 init/main.c:1314
 kernel_init_freeable+0x2ba/0x3f4 init/main.c:1520
 kernel_init+0x11/0x290 init/main.c:1407
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888108196f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888108196f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888108197000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                   ^
 ffff888108197080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888108197100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-android-5-10 2022/01/01 01:35 android12-5.10-lts 9b28b48fb343 36bd2e48 .config log report syz C KASAN: slab-out-of-bounds Write in legacy_parse_param
* Struck through repros no longer work on HEAD.