KASAN: null-ptr-deref Read in do_con_write

From: syzbot
Date: Thu Feb 13 2020 - 11:57:14 EST


Hello,

syzbot found the following crash on:

HEAD commit: f2850dd5 Merge tag 'kbuild-fixes-v5.6' of git://git.kernel..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=122f97a5e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=6780df5a5f208964
dashboard link: https://syzkaller.appspot.com/bug?extid=4b25dd89f2c5d49296d2
compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17b29701e00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11c8fc09e00000

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

==================================================================
BUG: KASAN: null-ptr-deref in scr_memcpyw include/linux/vt_buffer.h:49 [inline]
BUG: KASAN: null-ptr-deref in delete_char drivers/tty/vt/vt.c:852 [inline]
BUG: KASAN: null-ptr-deref in csi_P drivers/tty/vt/vt.c:1985 [inline]
BUG: KASAN: null-ptr-deref in do_con_trol drivers/tty/vt/vt.c:2379 [inline]
BUG: KASAN: null-ptr-deref in do_con_write+0x94d2/0xf360 drivers/tty/vt/vt.c:2797
Read of size 4294967294 at addr 0000000000000012 by task syz-executor662/8804

CPU: 0 PID: 8804 Comm: syz-executor662 Not tainted 5.6.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+0x1fb/0x318 lib/dump_stack.c:118
__kasan_report+0x167/0x1c0 mm/kasan/report.c:510
kasan_report+0x26/0x50 mm/kasan/common.c:641
check_memory_region_inline mm/kasan/generic.c:182 [inline]
check_memory_region+0x2b6/0x2f0 mm/kasan/generic.c:192
memcpy+0x28/0x60 mm/kasan/common.c:127
scr_memcpyw include/linux/vt_buffer.h:49 [inline]
delete_char drivers/tty/vt/vt.c:852 [inline]
csi_P drivers/tty/vt/vt.c:1985 [inline]
do_con_trol drivers/tty/vt/vt.c:2379 [inline]
do_con_write+0x94d2/0xf360 drivers/tty/vt/vt.c:2797
con_write+0x25/0x40 drivers/tty/vt/vt.c:3135
process_output_block drivers/tty/n_tty.c:595 [inline]
n_tty_write+0xd0c/0x1200 drivers/tty/n_tty.c:2333
do_tty_write drivers/tty/tty_io.c:962 [inline]
tty_write+0x5a1/0x950 drivers/tty/tty_io.c:1046
__vfs_write+0xb8/0x740 fs/read_write.c:494
vfs_write+0x270/0x580 fs/read_write.c:558
ksys_write+0x117/0x220 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+0x7b/0x90 fs/read_write.c:620
do_syscall_64+0xf7/0x1c0 arch/x86/entry/common.c:294
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4404f9
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 5b 14 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fffb1720718 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004404f9
RDX: 0000000000000078 RSI: 0000000020000140 RDI: 0000000000000004
RBP: 00000000006ca018 R08: 0000000000000000 R09: 00000000004002c8
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000401de0
R13: 0000000000401e70 R14: 0000000000000000 R15: 0000000000000000
==================================================================


---
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.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches