KASAN: use-after-free Read in vc_do_resize

Status: upstream: reported C repro on 2020/05/11 06:21
First crash: 997d, last: 908d

Cause bisection: failed (bisect log)

Fix bisection: failed (bisect log)
Last patch testing requests:
Created Duration User Patch Repo Result
2022/12/29 17:31 7m retest repro linux-next error
2022/09/22 05:29 18m retest repro upstream OK log
2022/09/20 12:29 10m retest repro linux-next report log
2022/09/19 12:29 16m retest repro upstream OK log
2022/09/18 16:29 17m retest repro upstream OK log
2020/09/01 14:22 17m upstream OK

Sample crash report:
BUG: KASAN: use-after-free in memcpy include/linux/string.h:406 [inline]
BUG: KASAN: use-after-free in scr_memcpyw include/linux/vt_buffer.h:49 [inline]
BUG: KASAN: use-after-free in vc_do_resize+0x9d8/0x1180 drivers/tty/vt/vt.c:1291
Read of size 2 at addr ffff88809e2c5e82 by task syz-executor.0/7082

CPU: 1 PID: 7082 Comm: syz-executor.0 Not tainted 5.8.0-rc7-next-20200731-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
 check_memory_region_inline mm/kasan/generic.c:186 [inline]
 check_memory_region+0x13d/0x180 mm/kasan/generic.c:192
 memcpy+0x20/0x60 mm/kasan/common.c:105
 memcpy include/linux/string.h:406 [inline]
 scr_memcpyw include/linux/vt_buffer.h:49 [inline]
 vc_do_resize+0x9d8/0x1180 drivers/tty/vt/vt.c:1291
 fbcon_modechanged+0x36c/0x710 drivers/video/fbdev/core/fbcon.c:2990
 fbcon_update_vcs+0x3a/0x50 drivers/video/fbdev/core/fbcon.c:3048
 fb_set_var+0xae8/0xd60 drivers/video/fbdev/core/fbmem.c:1056
 do_fb_ioctl+0x33f/0x6c0 drivers/video/fbdev/core/fbmem.c:1109
 fb_ioctl+0xdd/0x130 drivers/video/fbdev/core/fbmem.c:1185
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl fs/ioctl.c:739 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:739
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
RIP: 0033:0x45ce79
Code: 2d b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 fb b5 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f31baceec78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000000d580 RCX: 000000000045ce79
RDX: 0000000020000000 RSI: 0000000000004601 RDI: 0000000000000003
RBP: 000000000118bf60 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000118bf2c
R13: 00007ffc0f8542af R14: 00007f31bacef9c0 R15: 000000000118bf2c

Allocated by task 4808:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:461
 __do_kmalloc mm/slab.c:3655 [inline]
 __kmalloc+0x1a8/0x320 mm/slab.c:3664
 kmalloc include/linux/slab.h:559 [inline]
 kzalloc include/linux/slab.h:666 [inline]
 tomoyo_encode2.part.0+0xe9/0x3a0 security/tomoyo/realpath.c:45
 tomoyo_encode2 security/tomoyo/realpath.c:31 [inline]
 tomoyo_encode+0x28/0x50 security/tomoyo/realpath.c:80
 tomoyo_realpath_from_path+0x186/0x620 security/tomoyo/realpath.c:288
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x212/0x3f0 security/tomoyo/file.c:822
 security_inode_getattr+0xcf/0x140 security/security.c:1278
 vfs_getattr fs/stat.c:121 [inline]
 vfs_statx+0x170/0x390 fs/stat.c:206
 vfs_stat include/linux/fs.h:3165 [inline]
 __do_sys_newstat+0x91/0x110 fs/stat.c:361
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46

The buggy address belongs to the object at ffff88809e2c5e80
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 2 bytes inside of
 32-byte region [ffff88809e2c5e80, ffff88809e2c5ea0)
The buggy address belongs to the page:
page:0000000092cae990 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88809e2c5fc1 pfn:0x9e2c5
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00026668c8 ffffea00024f9c08 ffff8880aa000100
raw: ffff88809e2c5fc1 ffff88809e2c5000 000000010000003d 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809e2c5d80: 05 fc fc fc fc fc fc fc fa fb fb fb fc fc fc fc
 ffff88809e2c5e00: fa fb fb fb fc fc fc fc 00 00 fc fc fc fc fc fc
>ffff88809e2c5e80: fb fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
 ffff88809e2c5f00: 00 01 fc fc fc fc fc fc 00 03 fc fc fc fc fc fc
 ffff88809e2c5f80: 00 03 fc fc fc fc fc fc fc fc fc fc fc fc fc fc

Crashes (10):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-linux-next-kasan-gce-root 2020/08/08 12:32 linux-next 01830e6c042e ff51e522 .config console log report syz
ci-upstream-kasan-gce-root 2020/08/03 13:54 upstream bcf876870b95 196277c4 .config console log report syz C
ci-upstream-kasan-gce-selinux-root 2020/08/04 19:03 upstream c0842fbc1b18 80a06902 .config console log report syz
ci-upstream-kasan-gce-smack-root 2020/08/04 07:28 upstream bcf876870b95 196277c4 .config console log report syz
ci-upstream-kasan-gce-root 2020/08/03 07:29 upstream bcf876870b95 196277c4 .config console log report
ci-upstream-kasan-gce 2020/07/28 03:07 upstream 92ed30191993 cb93dc6a .config console log report
ci-upstream-kasan-gce 2020/06/30 03:44 upstream 4e99b32169e8 a2cdad9d .config console log report
ci-upstream-kasan-gce-smack-root 2020/05/24 07:24 upstream 423b8baf18a8 96c92ad3 .config console log report
ci-upstream-linux-next-kasan-gce-root 2020/05/21 02:19 linux-next ac935d227366 c61086ab .config console log report
ci-upstream-linux-next-kasan-gce-root 2020/05/11 01:31 linux-next ac935d227366 8742a2b9 .config console log report
* Struck through repros no longer work on HEAD.