Re: KASAN: use-after-free Write in vcs_read

From: syzbot
Date: Sat Aug 22 2020 - 00:17:46 EST


syzbot has found a reproducer for the following issue on:

HEAD commit: 494d311a Add linux-next specific files for 20200821
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=12454db1900000
kernel config: https://syzkaller.appspot.com/x/.config?x=a61d44f28687f508
dashboard link: https://syzkaller.appspot.com/bug?extid=ad1f53726c3bd11180cb
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16704b7e900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1588a046900000

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

==================================================================
BUG: KASAN: use-after-free in vcs_read_buf drivers/tty/vt/vc_screen.c:357 [inline]
BUG: KASAN: use-after-free in vcs_read+0xaa7/0xb40 drivers/tty/vt/vc_screen.c:449
Write of size 2 at addr ffff888093948000 by task syz-executor760/6850

CPU: 0 PID: 6850 Comm: syz-executor760 Not tainted 5.9.0-rc1-next-20200821-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+0x18f/0x20d lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xae/0x497 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
vcs_read_buf drivers/tty/vt/vc_screen.c:357 [inline]
vcs_read+0xaa7/0xb40 drivers/tty/vt/vc_screen.c:449
do_loop_readv_writev fs/read_write.c:734 [inline]
do_loop_readv_writev fs/read_write.c:721 [inline]
do_iter_read+0x48e/0x6e0 fs/read_write.c:955
vfs_readv+0xe5/0x150 fs/read_write.c:1073
do_preadv fs/read_write.c:1165 [inline]
__do_sys_preadv fs/read_write.c:1215 [inline]
__se_sys_preadv fs/read_write.c:1210 [inline]
__x64_sys_preadv+0x231/0x310 fs/read_write.c:1210
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x441259
Code: e8 fc ab 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 1b 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fffb3e6b7d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441259
RDX: 0000000000000006 RSI: 0000000020001b00 RDI: 0000000000000003
RBP: 00000000006cb018 R08: 0000000000000000 R09: 00000000004002c8
R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000402000
R13: 0000000000402090 R14: 0000000000000000 R15: 0000000000000000

The buggy address belongs to the page:
page:000000006b61c24f refcount:0 mapcount:-128 mapping:0000000000000000 index:0x0 pfn:0x93948
flags: 0xfffe0000000000()
raw: 00fffe0000000000 ffffea00029cd508 ffffea00024f3848 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffff7f 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888093947f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888093947f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff888093948000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff888093948080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff888093948100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================