KASAN: use-after-free Read in tty_open

22 views
Skip to first unread message

syzbot

unread,
Dec 2, 2019, 6:18:09 PM12/2/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 174651bd Linux 4.19.87
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=179f242ae00000
kernel config: https://syzkaller.appspot.com/x/.config?x=d306897dc6e131b7
dashboard link: https://syzkaller.appspot.com/bug?extid=e5f98c8dae836d203ee6
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1245d59ce00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=123b942ae00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+e5f98c...@syzkaller.appspotmail.com

==================================================================
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
==================================================================


---
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 syzk...@googlegroups.com.

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

syzbot

unread,
Dec 2, 2019, 10:42:09 PM12/2/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: fbc5fe7a Linux 4.14.157
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16f80cdee00000
kernel config: https://syzkaller.appspot.com/x/.config?x=d49d9f4045dcfa5d
dashboard link: https://syzkaller.appspot.com/bug?extid=ca8328f53572aa30f94b
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11762aeae00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1647942ae00000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+ca8328...@syzkaller.appspotmail.com

==================================================================
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 ffff888097608d00 by task syz-executor069/28074

CPU: 0 PID: 28074 Comm: syz-executor069 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:0x405721
RSP: 002b:00007f68aad42980 EFLAGS: 00000293 ORIG_RAX: 0000000000000002
RAX: ffffffffffffffda RBX: 6666666666666667 RCX: 0000000000405721
RDX: 0000000000000000 RSI: 0000000000000800 RDI: 00007f68aad429a0
RBP: 00000000006dbc20 R08: 000000000000000f R09: 00007f68aad43700
R10: 00007f68aad439d0 R11: 0000000000000293 R12: 00000000006dbc2c
R13: 00007ffdc0fe746f R14: 00007f68aad439c0 R15: 000000000000002d

Allocated by task 7023:
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 28077:
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 ffff888097608b00
which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 512 bytes inside of
2048-byte region [ffff888097608b00, ffff888097609300)
The buggy address belongs to the page:
page:ffffea00025d8200 count:1 mapcount:0 mapping:ffff888097608280 index:0x0
compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffff888097608280 0000000000000000 0000000100000003
raw: ffffea00026d6b20 ffffea00025dd920 ffff8880aa800c40 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888097608c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888097608c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff888097608d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888097608d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888097608e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

syzbot

unread,
Apr 13, 2020, 6:40:03 AM4/13/20
to syzkaller...@googlegroups.com
syzbot suspects this bug was fixed by commit:

commit b9eb60a0ef3971101c94f9cddb09708c2f900b35
Author: Eric Biggers <ebig...@google.com>
Date: Sun Mar 22 03:43:04 2020 +0000

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

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=109cc743e00000
start commit: fbc5fe7a Linux 4.14.157
git tree: linux-4.14.y
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=108c27f2e00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=172f677ae00000

If the result looks correct, please mark the bug fixed by replying with:

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

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
Apr 17, 2020, 2:47:03 AM4/17/20
to syzkaller...@googlegroups.com
syzbot suspects this bug was fixed by commit:

commit 54584f79579b9f6ed49b93cadcd2361223ecce28
Author: Eric Biggers <ebig...@google.com>
Date: Sun Mar 22 03:43:04 2020 +0000

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

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=17045500100000
start commit: 174651bd Linux 4.19.87
git tree: linux-4.19.y
Reply all
Reply to author
Forward
0 new messages