syzbot


KASAN: slab-out-of-bounds Read in cgroup_file_notify

Status: fixed on 2020/05/10 10:42
Subsystems: cgroups
[Documentation on labels]
Reported-by: syzbot+cac0c4e204952cf449b1@syzkaller.appspotmail.com
Fix commit: 726b7bbeafd4 hugetlb_cgroup: fix illegal access to memory
First crash: 1673d, last: 1673d
Cause bisection: introduced by (bisect log) :
commit 6863de00e5400b534cd4e3869ffbc8f94da41dfc
Author: Mina Almasry <almasrymina@google.com>
Date: Thu Feb 20 03:55:30 2020 +0000

  hugetlb_cgroup: add accounting for shared mappings

Crash: KASAN: slab-out-of-bounds Read in cgroup_file_notify (log)
Repro: C syz .config
  
Discussions (3)
Title Replies (including bot) Last reply
[patch 3/5] hugetlb_cgroup: fix illegal access to memory 1 (1) 2020/03/29 02:17
[PATCH -next] hugetlb_cgroup: fix illegal access to memory 5 (5) 2020/03/24 18:24
KASAN: slab-out-of-bounds Read in cgroup_file_notify 3 (4) 2020/03/13 22:43

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in cgroup_file_notify+0x16a/0x1b0 kernel/cgroup/cgroup.c:4084
Read of size 8 at addr ffff88821b77c4c8 by task syz-executor540/9589

CPU: 0 PID: 9589 Comm: syz-executor540 Not tainted 5.6.0-rc3-next-20200225-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/0x32 mm/kasan/report.c:506
 kasan_report+0x12/0x20 mm/kasan/common.c:641
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:135
 cgroup_file_notify+0x16a/0x1b0 kernel/cgroup/cgroup.c:4084
 hugetlb_event mm/hugetlb_cgroup.c:224 [inline]
 __hugetlb_cgroup_charge_cgroup+0x88c/0xf10 mm/hugetlb_cgroup.c:262
 hugetlb_cgroup_charge_cgroup_rsvd+0x2b/0x40 mm/hugetlb_cgroup.c:286
 hugetlb_reserve_pages+0x2c2/0xce0 mm/hugetlb.c:4891
 hugetlb_file_setup+0x26a/0x671 fs/hugetlbfs/inode.c:1423
 newseg+0x4a3/0xf40 ipc/shm.c:652
 ipcget_new ipc/util.c:344 [inline]
 ipcget+0x105/0xd40 ipc/util.c:643
 ksys_shmget ipc/shm.c:742 [inline]
 __do_sys_shmget ipc/shm.c:747 [inline]
 __se_sys_shmget ipc/shm.c:745 [inline]
 __x64_sys_shmget+0x146/0x1d0 ipc/shm.c:745
 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440119
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 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 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffd5e1db3e8 EFLAGS: 00000246 ORIG_RAX: 000000000000001d
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440119
RDX: 0000000000004800 RSI: fffffffffeffffff RDI: 0000000000000000
RBP: 00000000006ca018 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000020ffc000 R11: 0000000000000246 R12: 00000000004019a0
R13: 0000000000401a30 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 0:
 save_stack+0x23/0x90 mm/kasan/common.c:72
 set_track mm/kasan/common.c:80 [inline]
 __kasan_kmalloc mm/kasan/common.c:515 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:488
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:529
 kmem_cache_alloc_trace+0x158/0x790 mm/slab.c:3551
 kmalloc include/linux/slab.h:555 [inline]
 kzalloc include/linux/slab.h:669 [inline]
 hugetlb_cgroup_css_alloc+0x4f/0x320 mm/hugetlb_cgroup.c:138
 cgroup_init_subsys+0x1d9/0x4a7 kernel/cgroup/cgroup.c:5582
 cgroup_init+0x34a/0xa4c kernel/cgroup/cgroup.c:5708
 start_kernel+0xe2d/0xe8f init/main.c:987
 x86_64_start_reservations+0x29/0x2b arch/x86/kernel/head64.c:490
 x86_64_start_kernel+0x77/0x7b arch/x86/kernel/head64.c:471
 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:242

Freed by task 0:
(stack is not available)

The buggy address belongs to the object at ffff88821b77c000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1224 bytes inside of
 2048-byte region [ffff88821b77c000, ffff88821b77c800)
The buggy address belongs to the page:
page:ffffea00086ddf00 refcount:1 mapcount:0 mapping:000000005a8512d0 index:0x0
flags: 0x57ffe0000000200(slab)
raw: 057ffe0000000200 ffffea00086dde48 ffffea00086ddf88 ffff8880aa400e00
raw: 0000000000000000 ffff88821b77c000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88821b77c380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88821b77c400: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc
>ffff88821b77c480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                                              ^
 ffff88821b77c500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88821b77c580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/03/06 15:45 linux-next c99b17ac0399 c88c7b75 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.