KASAN: use-after-free Read in register_shrinker_prepared

From: syzbot
Date: Wed Jun 05 2019 - 15:12:11 EST


Hello,

syzbot found the following crash on:

HEAD commit: 56b697c6 Add linux-next specific files for 20190604
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1557b42ea00000
kernel config: https://syzkaller.appspot.com/x/.config?x=4248d6bc70076f7d
dashboard link: https://syzkaller.appspot.com/bug?extid=b8b2e599b6176efeaf51
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

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+b8b2e599b6176efeaf51@xxxxxxxxxxxxxxxxxxxxxxxxx

==================================================================
BUG: KASAN: use-after-free in __list_add_valid+0x9a/0xa0 lib/list_debug.c:26
Read of size 8 at addr ffff8880897dde68 by task syz-executor.4/26131

CPU: 1 PID: 26131 Comm: syz-executor.4 Not tainted 5.2.0-rc3-next-20190604 #8
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
__list_add_valid+0x9a/0xa0 lib/list_debug.c:26
__list_add include/linux/list.h:60 [inline]
list_add_tail include/linux/list.h:93 [inline]
register_shrinker_prepared+0x3d/0x190 mm/vmscan.c:414
sget_userns+0x42c/0x560 fs/super.c:627
sget+0x10c/0x150 fs/super.c:660
mount_bdev+0xff/0x3c0 fs/super.c:1319
hfs_mount+0x35/0x40 fs/hfs/super.c:457
legacy_get_tree+0x108/0x220 fs/fs_context.c:661
vfs_get_tree+0x8e/0x390 fs/super.c:1476
do_new_mount fs/namespace.c:2790 [inline]
do_mount+0x138c/0x1c00 fs/namespace.c:3110
ksys_mount+0xdb/0x150 fs/namespace.c:3319
__do_sys_mount fs/namespace.c:3333 [inline]
__se_sys_mount fs/namespace.c:3330 [inline]
__x64_sys_mount+0xbe/0x150 fs/namespace.c:3330
do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45bcca
Code: b8 a6 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 9d 8d fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 7a 8d fb ff c3 66 0f 1f 84 00 00 00 00 00
RSP: 002b:00007f56d13e4a88 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f56d13e4b40 RCX: 000000000045bcca
RDX: 00007f56d13e4ae0 RSI: 00000000200000c0 RDI: 00007f56d13e4b00
RBP: 0000000000000000 R08: 00007f56d13e4b40 R09: 00007f56d13e4ae0
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000004
R13: 00000000004c7f8b R14: 00000000004de500 R15: 00000000ffffffff

Allocated by task 26058:
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
__do_kmalloc mm/slab.c:3654 [inline]
__kmalloc+0x15c/0x740 mm/slab.c:3663
kmalloc include/linux/slab.h:552 [inline]
kzalloc include/linux/slab.h:742 [inline]
ops_init+0xff/0x410 net/core/net_namespace.c:120
setup_net+0x2d3/0x740 net/core/net_namespace.c:316
copy_net_ns+0x1df/0x340 net/core/net_namespace.c:439
create_new_namespaces+0x400/0x7b0 kernel/nsproxy.c:107
unshare_nsproxy_namespaces+0xc2/0x200 kernel/nsproxy.c:206
ksys_unshare+0x444/0x980 kernel/fork.c:2718
__do_sys_unshare kernel/fork.c:2786 [inline]
__se_sys_unshare kernel/fork.c:2784 [inline]
__x64_sys_unshare+0x31/0x40 kernel/fork.c:2784
do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 26058:
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
ops_init+0xd1/0x410 net/core/net_namespace.c:135
setup_net+0x2d3/0x740 net/core/net_namespace.c:316
copy_net_ns+0x1df/0x340 net/core/net_namespace.c:439
create_new_namespaces+0x400/0x7b0 kernel/nsproxy.c:107
unshare_nsproxy_namespaces+0xc2/0x200 kernel/nsproxy.c:206
ksys_unshare+0x444/0x980 kernel/fork.c:2718
__do_sys_unshare kernel/fork.c:2786 [inline]
__se_sys_unshare kernel/fork.c:2784 [inline]
__x64_sys_unshare+0x31/0x40 kernel/fork.c:2784
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 ffff8880897ddb00
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 872 bytes inside of
1024-byte region [ffff8880897ddb00, ffff8880897ddf00)
The buggy address belongs to the page:
page:ffffea000225f700 refcount:1 mapcount:0 mapping:ffff8880aa400ac0 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000010200(slab|head)
raw: 01fffc0000010200 ffffea00020e7288 ffffea00023e1808 ffff8880aa400ac0
raw: 0000000000000000 ffff8880897dc000 0000000100000007 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880897ddd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880897ddd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880897dde00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880897dde80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880897ddf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================


---
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.