syzbot


KASAN: use-after-free Read in do_shrink_slab

Status: fixed on 2018/08/28 17:48
Reported-by: syzbot+d5f648a1bfe15678786b@syzkaller.appspotmail.com
Fix commit: 8df4a44cc46b mm: check shrinker is memcg-aware in register_shrinker_prepared()
First crash: 1502d, last: 1498d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in do_shrink_slab+0xafb/0xba0 mm/vmscan.c:456
Read of size 8 at addr ffff8801b9465d18 by task syz-executor7/4522

CPU: 0 PID: 4522 Comm: syz-executor7 Not tainted 4.18.0+ #202
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+0x1c9/0x2b4 lib/dump_stack.c:113
 print_address_description+0x6c/0x20b mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.7+0x242/0x30d mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 do_shrink_slab+0xafb/0xba0 mm/vmscan.c:456
 shrink_slab_memcg mm/vmscan.c:600 [inline]
 shrink_slab+0x7b7/0x990 mm/vmscan.c:673
 shrink_node+0x429/0x16a0 mm/vmscan.c:2734
 shrink_zones mm/vmscan.c:2963 [inline]
 do_try_to_free_pages+0x3e7/0x1290 mm/vmscan.c:3025
 try_to_free_mem_cgroup_pages+0x49d/0xb70 mm/vmscan.c:3323
 reclaim_high.constprop.71+0x137/0x1e0 mm/memcontrol.c:2061
 mem_cgroup_handle_over_high+0x8d/0x130 mm/memcontrol.c:2086
 tracehook_notify_resume include/linux/tracehook.h:195 [inline]
 exit_to_usermode_loop+0x287/0x380 arch/x86/entry/common.c:166
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x459a97
Code: 44 00 00 b8 08 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 dd 8a fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 b8 a6 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 bd 8a fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffca08e14d8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a6
RAX: fffffffffffffffe RBX: 0000000000000000 RCX: 0000000000459a97
RDX: 0000000000408440 RSI: 0000000000000002 RDI: 00007ffca08e1580
RBP: 00000000000011b0 R08: 0000000000000000 R09: 000000000000000d
R10: 0000000000000006 R11: 0000000000000202 R12: 00007ffca08e25e0
R13: 00000000010c0940 R14: 0000000000000000 R15: badc0ffeebadface

Allocated by task 24298:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc4/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc mm/slab.c:3718 [inline]
 __kmalloc+0x14e/0x720 mm/slab.c:3727
 kmalloc_array include/linux/slab.h:635 [inline]
 kcalloc include/linux/slab.h:646 [inline]
 iter_file_splice_write+0x25d/0x1010 fs/splice.c:693
 do_splice_from fs/splice.c:852 [inline]
 direct_splice_actor+0x128/0x190 fs/splice.c:1019
 splice_direct_to_actor+0x318/0x8f0 fs/splice.c:974
 do_splice_direct+0x2d4/0x420 fs/splice.c:1062
 do_sendfile+0x62a/0xe20 fs/read_write.c:1440
 __do_sys_sendfile64 fs/read_write.c:1495 [inline]
 __se_sys_sendfile64 fs/read_write.c:1487 [inline]
 __x64_sys_sendfile64+0x15d/0x250 fs/read_write.c:1487
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 24298:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x11a/0x170 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xd9/0x210 mm/slab.c:3813
 iter_file_splice_write+0x78d/0x1010 fs/splice.c:777
 do_splice_from fs/splice.c:852 [inline]
 direct_splice_actor+0x128/0x190 fs/splice.c:1019
 splice_direct_to_actor+0x318/0x8f0 fs/splice.c:974
 do_splice_direct+0x2d4/0x420 fs/splice.c:1062
 do_sendfile+0x62a/0xe20 fs/read_write.c:1440
 __do_sys_sendfile64 fs/read_write.c:1495 [inline]
 __se_sys_sendfile64 fs/read_write.c:1487 [inline]
 __x64_sys_sendfile64+0x15d/0x250 fs/read_write.c:1487
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8801b9465cc0
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 88 bytes inside of
 256-byte region [ffff8801b9465cc0, ffff8801b9465dc0)
The buggy address belongs to the page:
page:ffffea0006e51940 count:1 mapcount:0 mapping:ffff8801dac007c0 index:0xffff8801b9465680
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea0006e43988 ffffea000680d248 ffff8801dac007c0
raw: ffff8801b9465680 ffff8801b9465040 0000000100000008 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801b9465c00: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
 ffff8801b9465c80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
>ffff8801b9465d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff8801b9465d80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff8801b9465e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (9):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-root 2018/08/22 12:04 upstream ad1d69735878 95b5c82b .config log report
ci-upstream-kasan-gce-root 2018/08/21 22:51 upstream 0214f46b3a03 95b5c82b .config log report
ci-upstream-kasan-gce-root 2018/08/21 09:38 upstream 778a33959a8a 95b5c82b .config log report
ci-upstream-kasan-gce-root 2018/08/20 20:30 upstream cc26ebbebde8 95b5c82b .config log report
ci-upstream-kasan-gce-root 2018/08/20 20:16 upstream cc26ebbebde8 95b5c82b .config log report
ci-upstream-kasan-gce-root 2018/08/19 22:40 upstream 2ad0d5269970 2dc4378f .config log report
ci-upstream-kasan-gce-root 2018/08/19 09:34 upstream 08b5fa819970 2dc4378f .config log report
ci-upstream-kasan-gce-root 2018/08/18 20:27 upstream a18d783fedfe de20bcbb .config log report
ci-upstream-kasan-gce-root 2018/08/18 02:59 upstream 1f7a4c73a739 db1858f6 .config log report
* Struck through repros no longer work on HEAD.