syzbot


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

Status: fixed on 2020/02/18 14:31
Subsystems: mm
[Documentation on labels]
Reported-by: syzbot+e64a13c5369a194d67df@syzkaller.appspotmail.com
Fix commit: c7a91bc7c2e1 mm/mempolicy.c: fix out of bounds write in mpol_parse_str()
First crash: 1538d, last: 1538d
Cause bisection: introduced by (bisect log) :
commit 626c3920aeb4575f53c96b0d4ad4e651a21cbb66
Author: Al Viro <viro@zeniv.linux.org.uk>
Date: Mon Sep 9 00:28:06 2019 +0000

  shmem_parse_one(): switch to use of fs_parse()

Crash: KASAN: slab-out-of-bounds Write in mpol_parse_str (log)
Repro: C syz .config
  
Discussions (10)
Title Replies (including bot) Last reply
[PATCH 3.16 00/99] 3.16.84-rc1 review 112 (112) 2020/05/22 00:00
[PATCH 5.5 00/23] 5.5.2-stable review 31 (31) 2020/02/08 16:13
[PATCH 4.4 00/53] 4.4.213-stable review 63 (63) 2020/02/05 22:37
[PATCH 5.4 00/90] 5.4.18-stable review 107 (107) 2020/02/05 21:21
[PATCH 4.19 00/70] 4.19.102-stable review 77 (77) 2020/02/05 14:42
[PATCH 4.14 00/89] 4.14.170-stable review 93 (93) 2020/02/04 17:19
[PATCH 4.9 00/68] 4.9.213-stable review 72 (72) 2020/02/04 17:18
[patch 003/118] mm/mempolicy.c: fix out of bounds write in mpol_parse_str() 1 (1) 2020/01/31 06:11
[PATCH] mm/mempolicy.c: Fix out of bounds write in mpol_parse_str() 12 (12) 2020/01/16 14:05
KASAN: slab-out-of-bounds Write in mpol_parse_str 0 (1) 2020/01/15 02:24

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in mpol_parse_str+0x87b/0xa50 mm/mempolicy.c:2922
Write of size 1 at addr ffff8880a4513abf by task syz-executor950/9591

CPU: 0 PID: 9591 Comm: syz-executor950 Not tainted 5.5.0-rc5-syzkaller #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+0x197/0x210 lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd4/0x30b mm/kasan/report.c:374
 __kasan_report.cold+0x1b/0x41 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:639
 __asan_report_store1_noabort+0x17/0x20 mm/kasan/generic_report.c:137
 mpol_parse_str+0x87b/0xa50 mm/mempolicy.c:2922
 shmem_parse_one+0x71e/0xa40 mm/shmem.c:3472
 vfs_parse_fs_param+0x2ca/0x540 fs/fs_context.c:145
 vfs_parse_fs_string+0x105/0x170 fs/fs_context.c:188
 shmem_parse_options+0x168/0x250 mm/shmem.c:3522
 parse_monolithic_mount_data+0x69/0x90 fs/fs_context.c:704
 do_new_mount fs/namespace.c:2818 [inline]
 do_mount+0x1310/0x1b50 fs/namespace.c:3142
 __do_sys_mount fs/namespace.c:3351 [inline]
 __se_sys_mount fs/namespace.c:3328 [inline]
 __x64_sys_mount+0x192/0x230 fs/namespace.c:3328
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x446a9a
Code: b8 08 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 7d ae fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 5a ae fb ff c3 66 0f 1f 84 00 00 00 00 00
RSP: 002b:00007fffb59b03c8 EFLAGS: 00000297 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fffb59b03d0 RCX: 0000000000446a9a
RDX: 00007fffb59b03d0 RSI: 00000000200000c0 RDI: 00007fffb59b03f0
RBP: 0000000000000003 R08: 00007fffb59b0430 R09: 000000000000000a
R10: 0000000000000000 R11: 0000000000000297 R12: 00007fffb59b0430
R13: 0000000000000004 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 9564:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:513 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:486
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:527
 __do_kmalloc mm/slab.c:3656 [inline]
 __kmalloc+0x163/0x770 mm/slab.c:3665
 kmalloc include/linux/slab.h:561 [inline]
 tomoyo_add_entry security/tomoyo/common.c:2031 [inline]
 tomoyo_supervisor+0xd3e/0xef0 security/tomoyo/common.c:2103
 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
 tomoyo_path_permission security/tomoyo/file.c:587 [inline]
 tomoyo_path_permission+0x263/0x360 security/tomoyo/file.c:573
 tomoyo_path_perm+0x318/0x430 security/tomoyo/file.c:838
 tomoyo_inode_getattr+0x1d/0x30 security/tomoyo/tomoyo.c:129
 security_inode_getattr+0xf2/0x150 security/security.c:1222
 vfs_getattr+0x25/0x70 fs/stat.c:115
 vfs_statx_fd+0x71/0xc0 fs/stat.c:145
 vfs_fstat include/linux/fs.h:3265 [inline]
 __do_sys_newfstat+0x9b/0x120 fs/stat.c:378
 __se_sys_newfstat fs/stat.c:375 [inline]
 __x64_sys_newfstat+0x54/0x80 fs/stat.c:375
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 9564:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 kasan_set_free_info mm/kasan/common.c:335 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:474
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:483
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x10a/0x2c0 mm/slab.c:3757
 tomoyo_add_entry security/tomoyo/common.c:2045 [inline]
 tomoyo_supervisor+0xc2c/0xef0 security/tomoyo/common.c:2103
 tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
 tomoyo_path_permission security/tomoyo/file.c:587 [inline]
 tomoyo_path_permission+0x263/0x360 security/tomoyo/file.c:573
 tomoyo_path_perm+0x318/0x430 security/tomoyo/file.c:838
 tomoyo_inode_getattr+0x1d/0x30 security/tomoyo/tomoyo.c:129
 security_inode_getattr+0xf2/0x150 security/security.c:1222
 vfs_getattr+0x25/0x70 fs/stat.c:115
 vfs_statx_fd+0x71/0xc0 fs/stat.c:145
 vfs_fstat include/linux/fs.h:3265 [inline]
 __do_sys_newfstat+0x9b/0x120 fs/stat.c:378
 __se_sys_newfstat fs/stat.c:375 [inline]
 __x64_sys_newfstat+0x54/0x80 fs/stat.c:375
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a4513a80
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 31 bytes to the right of
 32-byte region [ffff8880a4513a80, ffff8880a4513aa0)
The buggy address belongs to the page:
page:ffffea00029144c0 refcount:1 mapcount:0 mapping:ffff8880aa4001c0 index:0xffff8880a4513fc1
raw: 00fffe0000000200 ffffea0002a2e388 ffffea0002581cc8 ffff8880aa4001c0
raw: ffff8880a4513fc1 ffff8880a4513000 0000000100000028 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a4513980: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
 ffff8880a4513a00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
>ffff8880a4513a80: fb fb fb fb fc fc fc fc 00 05 fc fc fc fc fc fc
                                        ^
 ffff8880a4513b00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
 ffff8880a4513b80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/01/11 08:07 upstream e69ec487b2c7 4de4e9f0 .config console log report syz C ci-upstream-kasan-gce-root
2020/01/11 02:42 upstream e69ec487b2c7 4de4e9f0 .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/01/11 02:21 upstream e69ec487b2c7 4de4e9f0 .config console log report ci-upstream-kasan-gce-selinux-root
* Struck through repros no longer work on HEAD.