syzbot


KASAN: use-after-free Read in tty_open

Status: fixed on 2020/04/17 06:51
Reported-by: syzbot+e5f98c8dae836d203ee6@syzkaller.appspotmail.com
Fix commit: 54584f79579b vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console
First crash: 1596d, last: 1490d
Fix bisection: fixed by (bisect log) :
commit 54584f79579b9f6ed49b93cadcd2361223ecce28
Author: Eric Biggers <ebiggers@google.com>
Date: Sun Mar 22 03:43:04 2020 +0000

  vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in tty_open serial C done done 8 1483d 1595d 15/26 fixed on 2020/05/10 10:41
linux-4.14 KASAN: use-after-free Read in tty_open C done 5 1494d 1596d 1/1 fixed on 2020/04/13 10:52
Fix bisection attempts (4)
Created Duration User Patch Repo Result
2020/04/17 02:52 3h54m bisect fix linux-4.19.y job log (1)
2020/03/02 00:32 26m bisect fix linux-4.19.y job log (0) log
2020/02/01 00:02 29m bisect fix linux-4.19.y job log (0) log
2020/01/01 23:36 26m bisect fix linux-4.19.y job log (0) log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in constant_test_bit arch/x86/include/asm/bitops.h:317 [inline]
BUG: KASAN: use-after-free in tty_port_kopened include/linux/tty.h:666 [inline]
BUG: KASAN: use-after-free in tty_open_by_driver drivers/tty/tty_io.c:1960 [inline]
BUG: KASAN: use-after-free in tty_open+0xacb/0xb70 drivers/tty/tty_io.c:2029
Read of size 8 at addr ffff8880918c9700 by task syz-executor385/31184

CPU: 1 PID: 31184 Comm: syz-executor385 Not tainted 4.19.87-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+0x197/0x210 lib/dump_stack.c:118
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 constant_test_bit arch/x86/include/asm/bitops.h:317 [inline]
 tty_port_kopened include/linux/tty.h:666 [inline]
 tty_open_by_driver drivers/tty/tty_io.c:1960 [inline]
 tty_open+0xacb/0xb70 drivers/tty/tty_io.c:2029
 chrdev_open+0x245/0x6b0 fs/char_dev.c:423
 do_dentry_open+0x4c3/0x1210 fs/open.c:796
 vfs_open+0xa0/0xd0 fs/open.c:905
 do_last fs/namei.c:3418 [inline]
 path_openat+0x10d7/0x45e0 fs/namei.c:3534
 do_filp_open+0x1a1/0x280 fs/namei.c:3564
 do_sys_open+0x3fe/0x550 fs/open.c:1088
 __do_sys_open fs/open.c:1106 [inline]
 __se_sys_open fs/open.c:1101 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1101
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x405721
Code: 75 14 b8 02 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 a4 18 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 02 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
RSP: 002b:00007f79c9caf980 EFLAGS: 00000293 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 6666666666666667 RCX: 0000000000405721
RDX: 0000000000000000 RSI: 0000000000000800 RDI: 00007f79c9caf9a0
RBP: 00000000006dbc20 R08: 000000000000000f R09: 00007f79c9cb0700
R10: 00007f79c9cb09d0 R11: 0000000000000293 R12: 00000000006dbc2c
R13: 00007ffe4bf79dff R14: 00007f79c9cb09c0 R15: 000000000000002d

Allocated by task 7615:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 kmem_cache_alloc_trace+0x152/0x760 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 vc_allocate drivers/tty/vt/vt.c:1088 [inline]
 vc_allocate+0x1f5/0x760 drivers/tty/vt/vt.c:1069
 con_install+0x52/0x410 drivers/tty/vt/vt.c:3204
 tty_driver_install_tty drivers/tty/tty_io.c:1226 [inline]
 tty_init_dev drivers/tty/tty_io.c:1339 [inline]
 tty_init_dev+0xf7/0x460 drivers/tty/tty_io.c:1316
 tty_open_by_driver drivers/tty/tty_io.c:1981 [inline]
 tty_open+0x4bf/0xb70 drivers/tty/tty_io.c:2029
 chrdev_open+0x245/0x6b0 fs/char_dev.c:423
 do_dentry_open+0x4c3/0x1210 fs/open.c:796
 vfs_open+0xa0/0xd0 fs/open.c:905
 do_last fs/namei.c:3418 [inline]
 path_openat+0x10d7/0x45e0 fs/namei.c:3534
 do_filp_open+0x1a1/0x280 fs/namei.c:3564
 do_sys_open+0x3fe/0x550 fs/open.c:1088
 __do_sys_open fs/open.c:1106 [inline]
 __se_sys_open fs/open.c:1101 [inline]
 __x64_sys_open+0x7e/0xc0 fs/open.c:1101
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 31191:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcf/0x220 mm/slab.c:3822
 vt_disallocate_all+0x2bd/0x3e0 drivers/tty/vt/vt_ioctl.c:323
 vt_ioctl+0xc38/0x2530 drivers/tty/vt/vt_ioctl.c:816
 tty_ioctl+0x7f3/0x1510 drivers/tty/tty_io.c:2669
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0xd5f/0x1380 fs/ioctl.c:688
 ksys_ioctl+0xab/0xd0 fs/ioctl.c:705
 __do_sys_ioctl fs/ioctl.c:712 [inline]
 __se_sys_ioctl fs/ioctl.c:710 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:710
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880918c9500
 which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 512 bytes inside of
 2048-byte region [ffff8880918c9500, ffff8880918c9d00)
The buggy address belongs to the page:
page:ffffea0002463200 count:1 mapcount:0 mapping:ffff88812c31cc40 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffffea0002462f88 ffffea0002494308 ffff88812c31cc40
raw: 0000000000000000 ffff8880918c8400 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880918c9600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880918c9680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880918c9700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff8880918c9780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880918c9800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/12/02 22:18 linux-4.19.y 174651bdf802 ab342da3 .config console log report syz C ci2-linux-4-19
2020/03/18 02:52 linux-4.19.y 339485c9a80f 97bc55ce .config console log report ci2-linux-4-19
* Struck through repros no longer work on HEAD.