syzbot


KASAN: use-after-free Read in get_mem_cgroup_from_mm

Status: fixed on 2019/11/30 01:15
Reported-by: syzbot+7cf9cf7ef553661317ee@syzkaller.appspotmail.com
Fix commit: ab69a2304210 Revert "tipc: fix modprobe tipc failed after switch order of device registration"
First crash: 1837d, last: 1823d
Fix bisection: fixed by (bisect log) :
commit ab69a230421065b48ef93d3e6daf332e71c931dc
Author: David S. Miller <davem@davemloft.net>
Date: Fri May 17 19:15:05 2019 +0000

  Revert "tipc: fix modprobe tipc failed after switch order of device registration"

  
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in get_mem_cgroup_from_mm mm cgroups C done 375 1823d 1997d 12/26 fixed on 2019/06/14 18:22

Sample crash report:
IPVS: ftp: loaded support on port[0] = 21
IPVS: ftp: loaded support on port[0] = 21
IPVS: ftp: loaded support on port[0] = 21
cgroup: fork rejected by pids controller in /syz0
==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:190 [inline]
BUG: KASAN: use-after-free in task_css include/linux/cgroup.h:478 [inline]
BUG: KASAN: use-after-free in mem_cgroup_from_task mm/memcontrol.c:821 [inline]
BUG: KASAN: use-after-free in get_mem_cgroup_from_mm mm/memcontrol.c:850 [inline]
BUG: KASAN: use-after-free in get_mem_cgroup_from_mm+0x28f/0x2b0 mm/memcontrol.c:833
Read of size 8 at addr ffff888098c13788 by task syz-executor671/7933

CPU: 0 PID: 7933 Comm: syz-executor671 Not tainted 4.19.34 #2
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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 __read_once_size include/linux/compiler.h:190 [inline]
 task_css include/linux/cgroup.h:478 [inline]
 mem_cgroup_from_task mm/memcontrol.c:821 [inline]
 get_mem_cgroup_from_mm mm/memcontrol.c:850 [inline]
 get_mem_cgroup_from_mm+0x28f/0x2b0 mm/memcontrol.c:833
 mem_cgroup_try_charge+0x238/0x5e0 mm/memcontrol.c:5935
 mcopy_atomic_pte mm/userfaultfd.c:71 [inline]
 mfill_atomic_pte mm/userfaultfd.c:418 [inline]
 __mcopy_atomic mm/userfaultfd.c:559 [inline]
 mcopy_atomic+0x893/0x2600 mm/userfaultfd.c:609
 userfaultfd_copy fs/userfaultfd.c:1714 [inline]
 userfaultfd_ioctl+0x4dd/0x39e0 fs/userfaultfd.c:1860
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0xd6e/0x1390 fs/ioctl.c:688
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:705
 __do_sys_ioctl fs/ioctl.c:712 [inline]
 __se_sys_ioctl fs/ioctl.c:710 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:710
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4471a9
Code: e8 4c bb 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 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 5b 07 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fcfa1242db8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000006dcc38 RCX: 00000000004471a9
RDX: 0000000020000100 RSI: 00000000c028aa03 RDI: 0000000000000004
RBP: 00000000006dcc30 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dcc3c
R13: 00007ffd131302ff R14: 00007fcfa12439c0 R15: 0000000000000001

Allocated by task 7932:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:490
 kmem_cache_alloc_node+0x144/0x710 mm/slab.c:3649
 alloc_task_struct_node kernel/fork.c:157 [inline]
 dup_task_struct kernel/fork.c:802 [inline]
 copy_process.part.0+0x1cd5/0x7970 kernel/fork.c:1707
 copy_process kernel/fork.c:1664 [inline]
 _do_fork+0x257/0xfe0 kernel/fork.c:2175
 __do_sys_clone kernel/fork.c:2282 [inline]
 __se_sys_clone kernel/fork.c:2276 [inline]
 __x64_sys_clone+0xbf/0x150 kernel/fork.c:2276
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 7932:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3503 [inline]
 kmem_cache_free+0x86/0x260 mm/slab.c:3765
 free_task_struct kernel/fork.c:162 [inline]
 free_task+0xdd/0x120 kernel/fork.c:416
 copy_process.part.0+0x1a07/0x7970 kernel/fork.c:2107
 copy_process kernel/fork.c:1664 [inline]
 _do_fork+0x257/0xfe0 kernel/fork.c:2175
 __do_sys_clone kernel/fork.c:2282 [inline]
 __se_sys_clone kernel/fork.c:2276 [inline]
 __x64_sys_clone+0xbf/0x150 kernel/fork.c:2276
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888098c126c0
 which belongs to the cache task_struct(17:syz0) of size 6080
The buggy address is located 4296 bytes inside of
 6080-byte region [ffff888098c126c0, ffff888098c13e80)
The buggy address belongs to the page:
page:ffffea0002630480 count:1 mapcount:0 mapping:ffff88809b659900 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000008100(slab|head)
raw: 01fffc0000008100 ffffea0002630408 ffffea0002738c88 ffff88809b659900
raw: 0000000000000000 ffff888098c126c0 0000000100000001 ffff88809639acc0
page dumped because: kasan: bad access detected
page->mem_cgroup:ffff88809639acc0

Memory state around the buggy address:
 ffff888098c13680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888098c13700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888098c13780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff888098c13800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888098c13880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/04/16 05:09 linux-4.19.y 4d552acf3370 505ab413 .config console log report syz C ci2-linux-4-19
2019/04/29 17:58 linux-4.19.y 19bb613acb9a b617407b .config console log report ci2-linux-4-19
2019/04/25 20:00 linux-4.19.y c98875d930e9 f46aabc8 .config console log report ci2-linux-4-19
2019/04/24 11:36 linux-4.19.y c98875d930e9 8e3c52b1 .config console log report ci2-linux-4-19
2019/04/18 06:14 linux-4.19.y 4b0e041c9dad b0e8efcb .config console log report ci2-linux-4-19
2019/04/16 01:35 linux-4.19.y 4d552acf3370 505ab413 .config console log report ci2-linux-4-19
* Struck through repros no longer work on HEAD.