KASAN: use-after-free Read in mem_cgroup_throttle_swaprate

From: syzbot
Date: Tue Apr 21 2020 - 04:36:15 EST


Hello,

syzbot found the following crash on:

HEAD commit: 95988fbc Merge tag 'arm64-fixes' of git://git.kernel.org/p..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12de165fe00000
kernel config: https://syzkaller.appspot.com/x/.config?x=11f10cc27c63cade
dashboard link: https://syzkaller.appspot.com/bug?extid=25aae20a3d0192870dd5
compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+25aae20a3d0192870dd5@xxxxxxxxxxxxxxxxxxxxxxxxx

==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:199 [inline]
BUG: KASAN: use-after-free in arch_atomic_read arch/x86/include/asm/atomic.h:31 [inline]
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in blk_cgroup_congested include/linux/blk-cgroup.h:288 [inline]
BUG: KASAN: use-after-free in mem_cgroup_throttle_swaprate+0x2a9/0x4a0 mm/swapfile.c:3755
Read of size 4 at addr ffff888097c78cd8 by task syz-executor.3/19679

CPU: 1 PID: 19679 Comm: syz-executor.3 Not tainted 5.7.0-rc1-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+0x1e9/0x30e lib/dump_stack.c:118
print_address_description+0x74/0x5c0 mm/kasan/report.c:382
__kasan_report+0x103/0x1a0 mm/kasan/report.c:511
kasan_report+0x4d/0x80 mm/kasan/common.c:625

Allocated by task 1:
save_stack mm/kasan/common.c:49 [inline]
set_track mm/kasan/common.c:57 [inline]
__kasan_kmalloc+0x114/0x160 mm/kasan/common.c:495
kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551
kmalloc include/linux/slab.h:555 [inline]
kzalloc include/linux/slab.h:669 [inline]
cgroup1_root_to_use kernel/cgroup/cgroup-v1.c:1183 [inline]
cgroup1_get_tree+0x747/0xae0 kernel/cgroup/cgroup-v1.c:1207
vfs_get_tree+0x88/0x270 fs/super.c:1547
do_new_mount fs/namespace.c:2816 [inline]
do_mount+0x17ec/0x2900 fs/namespace.c:3141
__do_sys_mount fs/namespace.c:3350 [inline]
__se_sys_mount+0xd3/0x100 fs/namespace.c:3327
do_syscall_64+0xf3/0x1b0 arch/x86/entry/common.c:295
entry_SYSCALL_64_after_hwframe+0x49/0xb3

Freed by task 8747:
save_stack mm/kasan/common.c:49 [inline]
set_track mm/kasan/common.c:57 [inline]
kasan_set_free_info mm/kasan/common.c:317 [inline]
__kasan_slab_free+0x125/0x190 mm/kasan/common.c:456
__cache_free mm/slab.c:3426 [inline]
kfree+0x10a/0x220 mm/slab.c:3757
process_one_work+0x76e/0xfd0 kernel/workqueue.c:2268
worker_thread+0xa7f/0x1450 kernel/workqueue.c:2414
kthread+0x353/0x380 kernel/kthread.c:268
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff888097c78000
which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 3288 bytes inside of
8192-byte region [ffff888097c78000, ffff888097c7a000)
The buggy address belongs to the page:
page:ffffea00025f1e00 refcount:1 mapcount:0 mapping:000000006ff58934 index:0x0 head:ffffea00025f1e00 order:2 compound_mapcount:0 compound_pincount:0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea00025f1408 ffffea00025f2708 ffff8880aa4021c0
raw: 0000000000000000 ffff888097c78000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888097c78b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888097c78c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888097c78c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888097c78d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888097c78d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxxx

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.