syzbot


KASAN: use-after-free Read in n_tty_receive_buf_common

Status: fixed on 2020/04/02 14:59
Reported-by: syzbot+015a0585ad2e44d7786a@syzkaller.appspotmail.com
Fix commit: a4719f6d07b2 vt: selection, push sel_lock up
First crash: 1161d, last: 1072d

Fix bisection: fixed by (bisect log) :
commit a4719f6d07b2c63223f7452c435c5f578f105cfe
Author: Jiri Slaby <jslaby@suse.cz>
Date: Fri Feb 28 11:54:06 2020 +0000

  vt: selection, push sel_lock up

similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in n_tty_receive_buf_common C done 40 1066d 1161d 1/1 fixed on 2020/04/07 16:31
upstream KASAN: use-after-free Read in n_tty_receive_buf_common C done 68 1083d 1159d 17/24 fixed on 2020/04/15 17:19

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in n_tty_check_throttle drivers/tty/n_tty.c:266 [inline]
BUG: KASAN: use-after-free in n_tty_receive_buf_common+0x2075/0x2480 drivers/tty/n_tty.c:1761
Read of size 1 at addr ffff88808f4d4a00 by task syz-executor756/15391

CPU: 1 PID: 15391 Comm: syz-executor756 Not tainted 4.14.171-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+0x13e/0x194 lib/dump_stack.c:58
 print_address_description.cold+0x7c/0x1e2 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/0x2ae mm/kasan/report.c:393
 n_tty_check_throttle drivers/tty/n_tty.c:266 [inline]
 n_tty_receive_buf_common+0x2075/0x2480 drivers/tty/n_tty.c:1761
 tty_ldisc_receive_buf+0x9e/0x170 drivers/tty/tty_buffer.c:455
 paste_selection+0x1da/0x3ca drivers/tty/vt/selection.c:360
 tioclinux+0x107/0x410 drivers/tty/vt/vt.c:2696
 vt_ioctl+0x169a/0x2010 drivers/tty/vt/vt_ioctl.c:364
 tty_ioctl+0x6c5/0x1220 drivers/tty/tty_io.c:2661
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xfe0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x441339
RSP: 002b:00007ffee31737b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441339
RDX: 0000000020000000 RSI: 000000000000541c RDI: 0000000000000004
RBP: 00000000000e31b6 R08: 000000000000000d R09: 00000000004002c8
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004020b0
R13: 0000000000402140 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 15391:
 save_stack+0x32/0xa0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc mm/kasan/kasan.c:551 [inline]
 kasan_kmalloc+0xbf/0xe0 mm/kasan/kasan.c:529
 __do_kmalloc mm/slab.c:3720 [inline]
 __kmalloc+0x15b/0x7c0 mm/slab.c:3729
 kmalloc include/linux/slab.h:493 [inline]
 set_selection+0x78c/0xde0 drivers/tty/vt/selection.c:295
 tioclinux+0xf0/0x410 drivers/tty/vt/vt.c:2692
 vt_ioctl+0x169a/0x2010 drivers/tty/vt/vt_ioctl.c:364
 tty_ioctl+0x6c5/0x1220 drivers/tty/tty_io.c:2661
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xfe0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 15393:
 save_stack+0x32/0xa0 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+0xcb/0x260 mm/slab.c:3815
 set_selection+0x7a9/0xde0 drivers/tty/vt/selection.c:301
 tioclinux+0xf0/0x410 drivers/tty/vt/vt.c:2692
 vt_ioctl+0x169a/0x2010 drivers/tty/vt/vt_ioctl.c:364
 tty_ioctl+0x6c5/0x1220 drivers/tty/tty_io.c:2661
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xfe0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff88808f4d4a00
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
 32-byte region [ffff88808f4d4a00, ffff88808f4d4a20)
The buggy address belongs to the page:
page:ffffea00023d3500 count:1 mapcount:0 mapping:ffff88808f4d4000 index:0xffff88808f4d4fc1
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff88808f4d4000 ffff88808f4d4fc1 000000010000003f
raw: ffffea00027e2660 ffffea00027e74e0 ffff88812fe561c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88808f4d4900: fb fb fb fb fc fc fc fc 00 00 02 fc fc fc fc fc
 ffff88808f4d4980: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
>ffff88808f4d4a00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
                   ^
 ffff88808f4d4a80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
 ffff88808f4d4b00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================

Crashes (25):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci2-linux-4-14 2020/02/26 21:28 linux-4.14.y 98db2bf27b9e 251aabb7 .config console log report syz C
ci2-linux-4-14 2020/02/15 11:16 linux-4.14.y 98db2bf27b9e 5d7b90f1 .config console log report syz C
ci2-linux-4-14 2019/12/15 00:43 linux-4.14.y a844dc4c5442 eef6e580 .config console log report syz C
ci2-linux-4-14 2019/12/13 11:55 linux-4.14.y a844dc4c5442 2a752b7c .config console log report syz C
ci2-linux-4-14 2019/12/13 05:25 linux-4.14.y a844dc4c5442 08003f64 .config console log report syz C
ci2-linux-4-14 2019/12/13 04:00 linux-4.14.y a844dc4c5442 08003f64 .config console log report syz C
ci2-linux-4-14 2019/12/04 21:55 linux-4.14.y fbc5fe7a54d0 b2088328 .config console log report syz C
ci2-linux-4-14 2020/01/02 13:59 linux-4.14.y 4c5bf01e16a7 25a0186e .config console log report syz
ci2-linux-4-14 2019/12/30 02:36 linux-4.14.y e1f7d50ae3a3 af6b8ef8 .config console log report syz
ci2-linux-4-14 2019/12/15 09:11 linux-4.14.y a844dc4c5442 eef6e580 .config console log report syz
ci2-linux-4-14 2019/12/04 11:34 linux-4.14.y fbc5fe7a54d0 0ecb9746 .config console log report syz
ci2-linux-4-14 2020/03/02 06:52 linux-4.14.y 78d697fc93f9 4a4e0509 .config console log report
ci2-linux-4-14 2020/02/15 12:42 linux-4.14.y 98db2bf27b9e 5d7b90f1 .config console log report
ci2-linux-4-14 2020/02/07 03:08 linux-4.14.y e0f8b8a65a47 06150bf1 .config console log report
ci2-linux-4-14 2020/01/28 08:22 linux-4.14.y 9a95f25269bd 56cd6c9b .config console log report
ci2-linux-4-14 2020/01/12 10:37 linux-4.14.y b0cdffaa546e 31290a45 .config console log report
ci2-linux-4-14 2020/01/09 23:21 linux-4.14.y b0cdffaa546e 4de4e9f0 .config console log report
ci2-linux-4-14 2019/12/20 14:25 linux-4.14.y bfb9e5c03076 34011c05 .config console log report
ci2-linux-4-14 2019/12/18 20:51 linux-4.14.y bfb9e5c03076 79b211f7 .config console log report
ci2-linux-4-14 2019/12/14 14:02 linux-4.14.y a844dc4c5442 eef6e580 .config console log report
ci2-linux-4-14 2019/12/13 08:51 linux-4.14.y a844dc4c5442 2a752b7c .config console log report
ci2-linux-4-14 2019/12/10 10:23 linux-4.14.y a844dc4c5442 4b83c8fb .config console log report
ci2-linux-4-14 2019/12/10 01:02 linux-4.14.y a844dc4c5442 b31eda3d .config console log report
ci2-linux-4-14 2019/12/08 10:23 linux-4.14.y a844dc4c5442 1508f453 .config console log report
ci2-linux-4-14 2019/12/07 00:22 linux-4.14.y a844dc4c5442 85f26751 .config console log report
* Struck through repros no longer work on HEAD.