syzbot


KASAN: use-after-free Read in tty_open

Status: fixed on 2020/04/13 10:52
Reported-by: syzbot+ca8328f53572aa30f94b@syzkaller.appspotmail.com
Fix commit: b9eb60a0ef39 vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console
First crash: 1577d, last: 1475d
Fix bisection: fixed by (bisect log) :
commit b9eb60a0ef3971101c94f9cddb09708c2f900b35
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 1464d 1576d 15/26 fixed on 2020/05/10 10:41
linux-4.19 KASAN: use-after-free Read in tty_open C done 2 1471d 1577d 1/1 fixed on 2020/04/17 06:51
Fix bisection attempts (4)
Created Duration User Patch Repo Result
2020/04/13 07:39 3h00m bisect fix linux-4.14.y job log (1)
2020/03/14 07:12 25m bisect fix linux-4.14.y job log (0) log
2020/02/13 06:48 24m bisect fix linux-4.14.y job log (0) log
2020/01/14 06:23 24m bisect fix linux-4.14.y job log (0) log

Sample crash report:
audit: type=1400 audit(1575378425.568:36): avc:  denied  { map } for  pid=7077 comm="syz-executor250" path="/root/syz-executor250097564" dev="sda1" ino=16483 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
==================================================================
BUG: KASAN: use-after-free in constant_test_bit arch/x86/include/asm/bitops.h:325 [inline]
BUG: KASAN: use-after-free in tty_port_kopened include/linux/tty.h:664 [inline]
BUG: KASAN: use-after-free in tty_open_by_driver drivers/tty/tty_io.c:1952 [inline]
BUG: KASAN: use-after-free in tty_open+0x995/0xa10 drivers/tty/tty_io.c:2021
Read of size 8 at addr ffff88807555e480 by task syz-executor250/7091

CPU: 1 PID: 7091 Comm: syz-executor250 Not tainted 4.14.157-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x142/0x197 lib/dump_stack.c:58
 print_address_description.cold+0x7c/0x1dc mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report mm/kasan/report.c:409 [inline]
 kasan_report.cold+0xa9/0x2af mm/kasan/report.c:393
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430
 constant_test_bit arch/x86/include/asm/bitops.h:325 [inline]
 tty_port_kopened include/linux/tty.h:664 [inline]
 tty_open_by_driver drivers/tty/tty_io.c:1952 [inline]
 tty_open+0x995/0xa10 drivers/tty/tty_io.c:2021
 chrdev_open+0x207/0x590 fs/char_dev.c:423
 do_dentry_open+0x73b/0xeb0 fs/open.c:777
 vfs_open+0x105/0x220 fs/open.c:891
 do_last fs/namei.c:3425 [inline]
 path_openat+0x8bd/0x3f70 fs/namei.c:3566
 do_filp_open+0x18e/0x250 fs/namei.c:3600
 do_sys_open+0x2c5/0x430 fs/open.c:1084
 SYSC_open fs/open.c:1102 [inline]
 SyS_open+0x2d/0x40 fs/open.c:1097
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x401140
RSP: 002b:00007fff817f6a78 EFLAGS: 00000246 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 6666666666666667 RCX: 0000000000401140
RDX: 0000000000000000 RSI: 0000000000127200 RDI: 00007fff817f6aa0
RBP: 000000000000a57f R08: 000000000000000f R09: 00000000004002e0
R10: 000000000000000f R11: 0000000000000246 R12: 0000000000402160
R13: 00000000004021f0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7086:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc mm/kasan/kasan.c:551 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
 kmem_cache_alloc_trace+0x152/0x790 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 vc_allocate drivers/tty/vt/vt.c:772 [inline]
 vc_allocate+0x148/0x580 drivers/tty/vt/vt.c:753
 con_install+0x52/0x400 drivers/tty/vt/vt.c:2881
 tty_driver_install_tty drivers/tty/tty_io.c:1225 [inline]
 tty_init_dev drivers/tty/tty_io.c:1338 [inline]
 tty_init_dev+0xea/0x3a0 drivers/tty/tty_io.c:1315
 tty_open_by_driver drivers/tty/tty_io.c:1973 [inline]
 tty_open+0x414/0xa10 drivers/tty/tty_io.c:2021
 chrdev_open+0x207/0x590 fs/char_dev.c:423
 do_dentry_open+0x73b/0xeb0 fs/open.c:777
 vfs_open+0x105/0x220 fs/open.c:891
 do_last fs/namei.c:3425 [inline]
 path_openat+0x8bd/0x3f70 fs/namei.c:3566
 do_filp_open+0x18e/0x250 fs/namei.c:3600
 do_sys_open+0x2c5/0x430 fs/open.c:1084
 SYSC_open fs/open.c:1102 [inline]
 SyS_open+0x2d/0x40 fs/open.c:1097
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 7091:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xcc/0x270 mm/slab.c:3815
 vt_disallocate_all+0x286/0x380 drivers/tty/vt/vt_ioctl.c:323
 vt_ioctl+0x76b/0x2170 drivers/tty/vt/vt_ioctl.c:816
 tty_ioctl+0x841/0x1320 drivers/tty/tty_io.c:2661
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x7ae/0x1060 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

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

Memory state around the buggy address:
 ffff88807555e380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807555e400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807555e480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88807555e500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807555e580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/12/03 13:09 linux-4.14.y fbc5fe7a54d0 ab342da3 .config console log report syz C ci2-linux-4-14
2019/12/03 08:35 linux-4.14.y fbc5fe7a54d0 ab342da3 .config console log report syz C ci2-linux-4-14
2019/12/03 02:41 linux-4.14.y fbc5fe7a54d0 ab342da3 .config console log report syz C ci2-linux-4-14
2019/12/15 06:09 linux-4.14.y a844dc4c5442 eef6e580 .config console log report syz ci2-linux-4-14
2019/12/03 15:15 linux-4.14.y fbc5fe7a54d0 ab342da3 .config console log report syz ci2-linux-4-14
* Struck through repros no longer work on HEAD.