KASAN: use-after-free Read in n_tty_receive_buf_common

34 views
Skip to first unread message

syzbot

unread,
Dec 4, 2019, 6:30:09 AM12/4/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=14fb9c2ee00000
kernel config: https://syzkaller.appspot.com/x/.config?x=c8b1666d827aa49d
dashboard link: https://syzkaller.appspot.com/bug?extid=f3bc55221079c0047ca2
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=154dd196e00000

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

IPv6: ADDRCONF(NETDEV_UP): vxcan1: link is not ready
8021q: adding VLAN 0 to HW filter on device batadv0
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan0: link becomes ready
==================================================================
BUG: KASAN: use-after-free in n_tty_receive_buf_closing
drivers/tty/n_tty.c:1555 [inline]
BUG: KASAN: use-after-free in __receive_buf drivers/tty/n_tty.c:1630
[inline]
BUG: KASAN: use-after-free in n_tty_receive_buf_common+0x24b0/0x28e0
drivers/tty/n_tty.c:1740
Read of size 1 at addr ffff8880a6e88881 by task syz-executor.1/7709

CPU: 1 PID: 7709 Comm: syz-executor.1 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_load1_noabort+0x14/0x20 mm/kasan/report.c:430
n_tty_receive_buf_closing drivers/tty/n_tty.c:1555 [inline]
__receive_buf drivers/tty/n_tty.c:1630 [inline]
n_tty_receive_buf_common+0x24b0/0x28e0 drivers/tty/n_tty.c:1740
n_tty_receive_buf2+0x34/0x40 drivers/tty/n_tty.c:1775
tty_ldisc_receive_buf+0xad/0x1c0 drivers/tty/tty_buffer.c:456
paste_selection+0x1ff/0x443 drivers/tty/vt/selection.c:359
tioclinux+0x133/0x470 drivers/tty/vt/vt.c:3019
vt_ioctl+0x19ab/0x2530 drivers/tty/vt/vt_ioctl.c:364
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
RIP: 0033:0x45a679
Code: ad 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 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f57e4450c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045a679
RDX: 0000000020000180 RSI: 000000000000541c RDI: 0000000000000003
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f57e44516d4
R13: 00000000004c5951 R14: 00000000004dbb60 R15: 00000000ffffffff
kobject: 'loop2' (00000000be539375): kobject_uevent_env

Allocated by task 7700:
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
__do_kmalloc mm/slab.c:3727 [inline]
__kmalloc+0x15d/0x750 mm/slab.c:3736
kmalloc_array include/linux/slab.h:637 [inline]
set_selection+0x7e4/0x1370 drivers/tty/vt/selection.c:293
tioclinux+0x11c/0x470 drivers/tty/vt/vt.c:3015
vt_ioctl+0x19ab/0x2530 drivers/tty/vt/vt_ioctl.c:364
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

Freed by task 7703:
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
set_selection+0x801/0x1370 drivers/tty/vt/selection.c:300
tioclinux+0x11c/0x470 drivers/tty/vt/vt.c:3015
kobject: 'loop2' (00000000be539375): fill_kobj_path: path
= '/devices/virtual/block/loop2'
vt_ioctl+0x19ab/0x2530 drivers/tty/vt/vt_ioctl.c:364
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 ffff8880a6e88880
which belongs to the cache kmalloc-16384 of size 16384
The buggy address is located 1 bytes inside of
16384-byte region [ffff8880a6e88880, ffff8880a6e8c880)
The buggy address belongs to the page:
page:ffffea00029ba200 count:1 mapcount:0 mapping:ffff88812c315200 index:0x0
compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffffea0002247c08 ffffea0002985208 ffff88812c315200
raw: 0000000000000000 ffff8880a6e88880 0000000100000001 0000000000000000
kobject: 'loop5' (0000000036e3b682): kobject_uevent_env
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a6e88780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880a6e88800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8880a6e88880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a6e88900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a6e88980: 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 4, 2019, 7:35:10 AM12/4/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=150a042ae00000
kernel config: https://syzkaller.appspot.com/x/.config?x=253d29a660cb0d
dashboard link: https://syzkaller.appspot.com/bug?extid=015a0585ad2e44d7786a
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1688542ae00000

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

IPv6: ADDRCONF(NETDEV_UP): vxcan1: link is not ready
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan0: link becomes ready
8021q: adding VLAN 0 to HW filter on device batadv0
==================================================================
BUG: KASAN: use-after-free in n_tty_receive_char_inline
drivers/tty/n_tty.c:1411 [inline]
BUG: KASAN: use-after-free in n_tty_receive_buf_standard
drivers/tty/n_tty.c:1583 [inline]
BUG: KASAN: use-after-free in __receive_buf drivers/tty/n_tty.c:1646
[inline]
BUG: KASAN: use-after-free in n_tty_receive_buf_common+0x1feb/0x2410
drivers/tty/n_tty.c:1742
Read of size 1 at addr ffff88808de7d905 by task syz-executor.3/7413

CPU: 1 PID: 7413 Comm: syz-executor.3 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_load1_noabort+0x14/0x20 mm/kasan/report.c:427
n_tty_receive_char_inline drivers/tty/n_tty.c:1411 [inline]
n_tty_receive_buf_standard drivers/tty/n_tty.c:1583 [inline]
__receive_buf drivers/tty/n_tty.c:1646 [inline]
n_tty_receive_buf_common+0x1feb/0x2410 drivers/tty/n_tty.c:1742
n_tty_receive_buf2+0x34/0x40 drivers/tty/n_tty.c:1777
tty_ldisc_receive_buf+0xa5/0x1a0 drivers/tty/tty_buffer.c:455
paste_selection+0x1e6/0x3f2 drivers/tty/vt/selection.c:360
tioclinux+0x10e/0x400 drivers/tty/vt/vt.c:2696
vt_ioctl+0x180c/0x2170 drivers/tty/vt/vt_ioctl.c:364
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
RIP: 0033:0x45a679
RSP: 002b:00007f4ab427dc78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045a679
RDX: 0000000020000180 RSI: 000000000000541c RDI: 0000000000000003
RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f4ab427e6d4
R13: 00000000004c5951 R14: 00000000004dbb60 R15: 00000000ffffffff

Allocated by task 7384:
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
__do_kmalloc mm/slab.c:3720 [inline]
__kmalloc+0x15d/0x7a0 mm/slab.c:3729
kmalloc include/linux/slab.h:493 [inline]
set_selection+0x79a/0xe30 drivers/tty/vt/selection.c:295
tioclinux+0xf7/0x400 drivers/tty/vt/vt.c:2692
vt_ioctl+0x180c/0x2170 drivers/tty/vt/vt_ioctl.c:364
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

Freed by task 7400:
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
set_selection+0x7b7/0xe30 drivers/tty/vt/selection.c:301
tioclinux+0xf7/0x400 drivers/tty/vt/vt.c:2692
vt_ioctl+0x180c/0x2170 drivers/tty/vt/vt_ioctl.c:364
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 ffff88808de7d900
which belongs to the cache kmalloc-8192 of size 8192
The buggy address is located 5 bytes inside of
8192-byte region [ffff88808de7d900, ffff88808de7f900)
The buggy address belongs to the page:
page:ffffea0002379f00 count:1 mapcount:0 mapping:ffff88808de7d900 index:0x0
compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffff88808de7d900 0000000000000000 0000000100000001
raw: ffffea0002355f20 ffffea00024bf020 ffff8880aa802080 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88808de7d800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88808de7d880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff88808de7d900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88808de7d980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808de7da00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

syzbot

unread,
Dec 4, 2019, 4:56:08 PM12/4/19
to syzkaller...@googlegroups.com
syzbot has found a reproducer for 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=16381282e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=253d29a660cb0d
dashboard link: https://syzkaller.appspot.com/bug?extid=015a0585ad2e44d7786a
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=152d2e41e00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1211f061e00000

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

==================================================================
BUG: KASAN: use-after-free in n_tty_receive_char_inline
drivers/tty/n_tty.c:1411 [inline]
BUG: KASAN: use-after-free in n_tty_receive_buf_standard
drivers/tty/n_tty.c:1583 [inline]
BUG: KASAN: use-after-free in __receive_buf drivers/tty/n_tty.c:1646
[inline]
BUG: KASAN: use-after-free in n_tty_receive_buf_common+0x1feb/0x2410
drivers/tty/n_tty.c:1742
Read of size 1 at addr ffff88809feda3c0 by task syz-executor453/9268

CPU: 0 PID: 9268 Comm: syz-executor453 Not tainted 4.14.157-syzkaller #0
RIP: 0033:0x4417b9
RSP: 002b:00007ffeb350ec98 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000007c3e5 RCX: 00000000004417b9
RDX: 0000000020000040 RSI: 000000000000541c RDI: 0000000000000003
RBP: 0000000000000000 R08: 000000000000000d R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000000016f
R13: 0000000000402490 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 9266:
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
__do_kmalloc mm/slab.c:3720 [inline]
__kmalloc+0x15d/0x7a0 mm/slab.c:3729
kmalloc include/linux/slab.h:493 [inline]
set_selection+0x79a/0xe30 drivers/tty/vt/selection.c:295
tioclinux+0xf7/0x400 drivers/tty/vt/vt.c:2692
vt_ioctl+0x180c/0x2170 drivers/tty/vt/vt_ioctl.c:364
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

Freed by task 9267:
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
set_selection+0x7b7/0xe30 drivers/tty/vt/selection.c:301
tioclinux+0xf7/0x400 drivers/tty/vt/vt.c:2692
vt_ioctl+0x180c/0x2170 drivers/tty/vt/vt_ioctl.c:364
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 ffff88809feda3c0
which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
32-byte region [ffff88809feda3c0, ffff88809feda3e0)
The buggy address belongs to the page:
page:ffffea00027fb680 count:1 mapcount:0 mapping:ffff88809feda000
index:0xffff88809fedafc1
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff88809feda000 ffff88809fedafc1 000000010000003f
raw: ffffea00027e0160 ffffea00027fce20 ffff8880aa8001c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809feda280: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
ffff88809feda300: 00 00 01 fc fc fc fc fc fb fb fb fb fc fc fc fc
> ffff88809feda380: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
^
ffff88809feda400: 00 00 01 fc fc fc fc fc fb fb fb fb fc fc fc fc
ffff88809feda480: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================

syzbot

unread,
Dec 7, 2019, 1:30:10 PM12/7/19
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: fb683b5e Linux 4.19.88
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=17806f36e00000
kernel config: https://syzkaller.appspot.com/x/.config?x=598969d2888c3fa1
dashboard link: https://syzkaller.appspot.com/bug?extid=f3bc55221079c0047ca2
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14f03196e00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12a89c2ae00000

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

==================================================================
BUG: KASAN: use-after-free in n_tty_receive_buf_closing
drivers/tty/n_tty.c:1555 [inline]
BUG: KASAN: use-after-free in __receive_buf drivers/tty/n_tty.c:1630
[inline]
BUG: KASAN: use-after-free in n_tty_receive_buf_common+0x24b0/0x28e0
drivers/tty/n_tty.c:1740
Read of size 1 at addr ffff88808bb56841 by task syz-executor086/7933

CPU: 0 PID: 7933 Comm: syz-executor086 Not tainted 4.19.88-syzkaller #0
RIP: 0033:0x441399
Code: e8 ac e8 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 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 eb 08 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffe022fda78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441399
RDX: 0000000020000040 RSI: 000000000000541c RDI: 0000000000000004
RBP: 000000000000d5f3 R08: 00000000004002c8 R09: 00000000004002c8
R10: 000000000000000d R11: 0000000000000246 R12: 0000000000402110
R13: 00000000004021a0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7935:
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
__do_kmalloc mm/slab.c:3727 [inline]
__kmalloc+0x15d/0x750 mm/slab.c:3736
kmalloc_array include/linux/slab.h:637 [inline]
set_selection+0x7e4/0x1370 drivers/tty/vt/selection.c:293
tioclinux+0x11c/0x470 drivers/tty/vt/vt.c:3015
vt_ioctl+0x19ab/0x2530 drivers/tty/vt/vt_ioctl.c:364
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

Freed by task 7936:
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
set_selection+0x801/0x1370 drivers/tty/vt/selection.c:300
tioclinux+0x11c/0x470 drivers/tty/vt/vt.c:3015
vt_ioctl+0x19ab/0x2530 drivers/tty/vt/vt_ioctl.c:364
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 ffff88808bb56840
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 1 bytes inside of
512-byte region [ffff88808bb56840, ffff88808bb56a40)
The buggy address belongs to the page:
page:ffffea00022ed580 count:1 mapcount:0 mapping:ffff88812c31c940 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea00022af1c8 ffffea00023fdb48 ffff88812c31c940
raw: 0000000000000000 ffff88808bb560c0 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88808bb56700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808bb56780: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ffff88808bb56800: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff88808bb56880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88808bb56900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

syzbot

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

commit a4719f6d07b2c63223f7452c435c5f578f105cfe
Author: Jiri Slaby <jsl...@suse.cz>
Date: Fri Feb 28 11:54:06 2020 +0000

vt: selection, push sel_lock up

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=11f1096de00000
start commit: 98db2bf2 Linux 4.14.171
git tree: linux-4.14.y
kernel config: https://syzkaller.appspot.com/x/.config?x=49cf7d1ab0dd7451
dashboard link: https://syzkaller.appspot.com/bug?extid=015a0585ad2e44d7786a
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12589c55e00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11131d09e00000

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

#syz fix: vt: selection, push sel_lock up

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

syzbot

unread,
Apr 6, 2020, 11:09:03 PM4/6/20
to syzkaller...@googlegroups.com
syzbot suspects this bug was fixed by commit:

commit b4492f1e7456bd162714c0ec2815c2749d930844
Author: Jiri Slaby <jsl...@suse.cz>
Date: Fri Feb 28 11:54:06 2020 +0000

vt: selection, push sel_lock up

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=13f5983be00000
start commit: 35766839 Linux 4.19.103
git tree: linux-4.19.y
kernel config: https://syzkaller.appspot.com/x/.config?x=84f14e7b6cbc7d27
dashboard link: https://syzkaller.appspot.com/bug?extid=f3bc55221079c0047ca2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12b1c07ee00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=175b7ee9e00000
Reply all
Reply to author
Forward
0 new messages