syzbot


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

Status: fixed on 2019/07/10 21:40
Subsystems: cgroups
[Documentation on labels]
Reported-by: syzbot+9343b7623bc03dc680c1@syzkaller.appspotmail.com
Fix commit: c596687a008b cgroup: Fix css_task_iter_advance_css_set() cset skip condition
First crash: 1785d, last: 1779d
Cause bisection: introduced by (bisect log) :
commit b636fd38dc40113f853337a7d2a6885ad23b8811
Author: Tejun Heo <tj@kernel.org>
Date: Fri May 31 17:38:58 2019 +0000

  cgroup: Implement css_task_iter_skip()

Crash: KASAN: use-after-free Read in css_task_iter_next (log)
Repro: C syz .config
  
Discussions (1)
Title Replies (including bot) Last reply
KASAN: slab-out-of-bounds Read in css_task_iter_advance 0 (3) 2019/06/05 06:47

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in css_task_iter_advance+0x50e/0x540 kernel/cgroup/cgroup.c:4503
Read of size 8 at addr ffff8880860c9208 by task syz-executor906/8694

CPU: 1 PID: 8694 Comm: syz-executor906 Not tainted 5.2.0-rc3-next-20190607 #11
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+0xd4/0x306 mm/kasan/report.c:351
 __kasan_report.cold+0x1b/0x36 mm/kasan/report.c:482
 kasan_report+0x12/0x20 mm/kasan/common.c:614
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/generic_report.c:132
 css_task_iter_advance+0x50e/0x540 kernel/cgroup/cgroup.c:4503
 css_task_iter_start+0x18b/0x230 kernel/cgroup/cgroup.c:4543
 __cgroup_procs_start.isra.0+0x32f/0x400 kernel/cgroup/cgroup.c:4638
 cgroup_procs_start kernel/cgroup/cgroup.c:4660 [inline]
 cgroup_procs_start+0x1e7/0x260 kernel/cgroup/cgroup.c:4647
 cgroup_seqfile_start+0xa4/0xd0 kernel/cgroup/cgroup.c:3752
 kernfs_seq_start+0xdc/0x190 fs/kernfs/file.c:118
 seq_read+0x2a7/0x1110 fs/seq_file.c:224
 kernfs_fop_read+0xed/0x560 fs/kernfs/file.c:252
 do_loop_readv_writev fs/read_write.c:714 [inline]
 do_loop_readv_writev fs/read_write.c:701 [inline]
 do_iter_read+0x4a4/0x660 fs/read_write.c:935
 vfs_readv+0xf0/0x160 fs/read_write.c:997
 kernel_readv fs/splice.c:359 [inline]
 default_file_splice_read+0x475/0x890 fs/splice.c:414
 do_splice_to+0x127/0x180 fs/splice.c:877
 splice_direct_to_actor+0x2d2/0x970 fs/splice.c:954
 do_splice_direct+0x1da/0x2a0 fs/splice.c:1063
 do_sendfile+0x597/0xd00 fs/read_write.c:1464
 __do_sys_sendfile64 fs/read_write.c:1525 [inline]
 __se_sys_sendfile64 fs/read_write.c:1511 [inline]
 __x64_sys_sendfile64+0x1dd/0x220 fs/read_write.c:1511
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x442409
Code: e8 8c b2 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 eb 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffd293a8008 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000442409
RDX: 0000000000000000 RSI: 0000000000000009 RDI: 0000000000000008
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 000000000000001c
R13: 0000000000403210 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 8692:
 save_stack+0x23/0x90 mm/kasan/common.c:71
 set_track mm/kasan/common.c:79 [inline]
 __kasan_kmalloc mm/kasan/common.c:489 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:462
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:503
 kmem_cache_alloc_trace+0x151/0x750 mm/slab.c:3549
 kmalloc include/linux/slab.h:547 [inline]
 kzalloc include/linux/slab.h:742 [inline]
 find_css_set+0x742/0x18b0 kernel/cgroup/cgroup.c:1203
 cgroup_migrate_prepare_dst+0x104/0x780 kernel/cgroup/cgroup.c:2662
 cgroup_update_dfl_csses+0x331/0x5a0 kernel/cgroup/cgroup.c:2911
 cgroup_apply_control kernel/cgroup/cgroup.c:3165 [inline]
 cgroup_apply_control+0x3e/0x50 kernel/cgroup/cgroup.c:3150
 cgroup_subtree_control_write+0x7f5/0xbd0 kernel/cgroup/cgroup.c:3314
 cgroup_file_write+0x241/0x790 kernel/cgroup/cgroup.c:3711
 kernfs_fop_write+0x2b8/0x480 fs/kernfs/file.c:316
 __vfs_write+0x8a/0x110 fs/read_write.c:494
 vfs_write+0x268/0x5d0 fs/read_write.c:558
 ksys_write+0x14f/0x290 fs/read_write.c:611
 __do_sys_write fs/read_write.c:623 [inline]
 __se_sys_write fs/read_write.c:620 [inline]
 __x64_sys_write+0x73/0xb0 fs/read_write.c:620
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8201:
 save_stack+0x23/0x90 mm/kasan/common.c:71
 set_track mm/kasan/common.c:79 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:451
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:459
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x106/0x2a0 mm/slab.c:3753
 tomoyo_supervisor+0x360/0xef0 security/tomoyo/common.c:2147
 tomoyo_audit_env_log security/tomoyo/environ.c:36 [inline]
 tomoyo_env_perm+0x18e/0x210 security/tomoyo/environ.c:63
 tomoyo_environ security/tomoyo/domain.c:670 [inline]
 tomoyo_find_next_domain+0x1354/0x1f6c security/tomoyo/domain.c:876
 tomoyo_bprm_check_security security/tomoyo/tomoyo.c:107 [inline]
 tomoyo_bprm_check_security+0x124/0x1b0 security/tomoyo/tomoyo.c:97
 security_bprm_check+0x63/0xb0 security/security.c:747
 search_binary_handler+0x71/0x570 fs/exec.c:1645
 exec_binprm fs/exec.c:1701 [inline]
 __do_execve_file.isra.0+0x1310/0x22f0 fs/exec.c:1821
 do_execveat_common fs/exec.c:1868 [inline]
 do_execve fs/exec.c:1885 [inline]
 __do_sys_execve fs/exec.c:1961 [inline]
 __se_sys_execve fs/exec.c:1956 [inline]
 __x64_sys_execve+0x8f/0xc0 fs/exec.c:1956
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880860c8dc0
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 72 bytes to the right of
 1024-byte region [ffff8880860c8dc0, ffff8880860c91c0)
The buggy address belongs to the page:
page:ffffea0002183200 refcount:1 mapcount:0 mapping:ffff8880aa400ac0 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000010200(slab|head)
raw: 01fffc0000010200 ffffea0002869d08 ffffea00022ed608 ffff8880aa400ac0
raw: 0000000000000000 ffff8880860c8040 0000000100000007 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880860c9100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880860c9180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880860c9200: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
                      ^
 ffff8880860c9280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880860c9300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (19):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/06/10 22:32 linux-next 3f310e51ceb1 0159583c .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/06/04 22:11 linux-next 56b697c6c13b e41a20c5 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/06/10 17:00 linux-next 3f310e51ceb1 0159583c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/10 08:03 linux-next 3f310e51ceb1 0159583c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/10 07:49 linux-next 3f310e51ceb1 0159583c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/10 05:01 linux-next 3f310e51ceb1 0159583c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/10 02:03 linux-next 3f310e51ceb1 0159583c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/09 15:34 linux-next 3f310e51ceb1 0159583c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/09 10:42 linux-next 3f310e51ceb1 0159583c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/08 14:34 linux-next 3f310e51ceb1 0159583c .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/08 02:43 linux-next 3f310e51ceb1 cf9c3a50 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/07 21:49 linux-next 3f310e51ceb1 ce9107d0 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/07 14:21 linux-next 3f310e51ceb1 ce9107d0 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/07 14:10 linux-next 3f310e51ceb1 ce9107d0 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/06 05:55 linux-next b2924447b98a a547defc .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/06 03:11 linux-next b2924447b98a a547defc .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/05 07:14 linux-next b2924447b98a bfb4a51e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/05 02:36 linux-next 56b697c6c13b bfb4a51e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 11:58 linux-next 56b697c6c13b e41a20c5 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.