KASAN: use-after-free Read in tty_ldisc_hangup

9 views
Skip to first unread message

syzbot

unread,
Jul 7, 2022, 5:52:21 AM7/7/22
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: cb71b93c2dc3 Add linux-next specific files for 20220628
git tree: linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=16edf7fff00000
kernel config: https://syzkaller.appspot.com/x/.config?x=badbc1adb2d582eb
dashboard link: https://syzkaller.appspot.com/bug?extid=d1b88179480678804aa6
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
CC: [gre...@linuxfoundation.org jiri...@kernel.org linux-...@vger.kernel.org]

Unfortunately, I don't have any reproducer for this issue yet.

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

==================================================================
BUG: KASAN: use-after-free in __wake_up_common+0x637/0x650 kernel/sched/wait.c:100
Read of size 8 at addr ffff88807456a230 by task syz-executor.4/11978

CPU: 0 PID: 11978 Comm: syz-executor.4 Not tainted 5.19.0-rc4-next-20220628-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/29/2022
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:317 [inline]
print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
kasan_report+0xbe/0x1f0 mm/kasan/report.c:495
__wake_up_common+0x637/0x650 kernel/sched/wait.c:100
__wake_up_common_lock+0xd0/0x130 kernel/sched/wait.c:137
tty_ldisc_hangup+0x1cf/0x680 drivers/tty/tty_ldisc.c:704
__tty_hangup.part.0+0x40a/0x830 drivers/tty/tty_io.c:637
__tty_hangup drivers/tty/tty_io.c:592 [inline]
tty_vhangup+0x1d/0x30 drivers/tty/tty_io.c:707
pty_close+0x39f/0x4f0 drivers/tty/pty.c:79
tty_release+0x45e/0x1200 drivers/tty/tty_io.c:1758
__fput+0x277/0x9d0 fs/file_table.c:317
task_work_run+0xdd/0x1a0 kernel/task_work.c:177
get_signal+0x1c5/0x2600 kernel/signal.c:2634
arch_do_signal_or_restart+0x82/0x2300 arch/x86/kernel/signal.c:869
exit_to_user_mode_loop kernel/entry/common.c:166 [inline]
exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:201
__syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline]
syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294
do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7fd776e89109
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fd777fd7168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: 000000000000ce00 RBX: 00007fd776f9bf60 RCX: 00007fd776e89109
RDX: 000000000000ff2e RSI: 0000000020000080 RDI: 0000000000000007
RBP: 00007fd776ee305d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffff7e8927f R14: 00007fd777fd7300 R15: 0000000000022000
</TASK>

Allocated by task 11998:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
kasan_set_track mm/kasan/common.c:45 [inline]
set_alloc_info mm/kasan/common.c:436 [inline]
____kasan_kmalloc mm/kasan/common.c:515 [inline]
____kasan_kmalloc mm/kasan/common.c:474 [inline]
__kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524
kmalloc include/linux/slab.h:600 [inline]
__io_queue_proc+0x2dc/0x950 io_uring/poll.c:429
poll_wait include/linux/poll.h:49 [inline]
n_tty_poll+0xb4/0x8a0 drivers/tty/n_tty.c:2425
tty_poll+0x139/0x1b0 drivers/tty/tty_io.c:2212
vfs_poll include/linux/poll.h:88 [inline]
__io_arm_poll_handler+0x488/0x1060 io_uring/poll.c:511
io_arm_poll_handler+0x5c6/0xce0 io_uring/poll.c:638
io_queue_async+0xc1/0x3e0 io_uring/io_uring.c:1753
io_queue_sqe io_uring/io_uring.c:1787 [inline]
io_submit_sqe io_uring/io_uring.c:2036 [inline]
io_submit_sqes+0x15fc/0x1ec0 io_uring/io_uring.c:2147
__do_sys_io_uring_enter+0xb85/0x1eb0 io_uring/io_uring.c:3087
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x46/0xb0

Freed by task 12024:
kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
kasan_set_track+0x21/0x30 mm/kasan/common.c:45
kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
____kasan_slab_free mm/kasan/common.c:366 [inline]
____kasan_slab_free+0x166/0x1c0 mm/kasan/common.c:328
kasan_slab_free include/linux/kasan.h:200 [inline]
slab_free_hook mm/slub.c:1754 [inline]
slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1780
slab_free mm/slub.c:3534 [inline]
kfree+0xe2/0x4d0 mm/slub.c:4562
io_clean_op+0x1b1/0xa40 io_uring/io_uring.c:1555
io_dismantle_req io_uring/io_uring.c:930 [inline]
io_free_req+0xc9/0x299 io_uring/io_uring.c:940
io_put_req_find_next io_uring/io_uring.c:1236 [inline]
io_wq_free_work.cold+0x62/0x67 io_uring/io_uring.c:1636
io_worker_handle_work+0xc48/0x1c60 io_uring/io-wq.c:590
io_wqe_worker+0x640/0xe90 io_uring/io-wq.c:634
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302

The buggy address belongs to the object at ffff88807456a200
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 48 bytes inside of
64-byte region [ffff88807456a200, ffff88807456a240)

The buggy address belongs to the physical page:
page:ffffea0001d15a80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7456a
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000122 ffff888011841640
raw: 0000000000000000 0000000000200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 11998, tgid 11968 (syz-executor.4), ts 545566238808, free_ts 545120622183
prep_new_page mm/page_alloc.c:2535 [inline]
get_page_from_freelist+0x210d/0x3a30 mm/page_alloc.c:4282
__alloc_pages+0x1c7/0x510 mm/page_alloc.c:5506
alloc_pages+0x1aa/0x310 mm/mempolicy.c:2280
alloc_slab_page mm/slub.c:1824 [inline]
allocate_slab+0x27e/0x3d0 mm/slub.c:1969
new_slab mm/slub.c:2029 [inline]
___slab_alloc+0x89d/0xef0 mm/slub.c:3031
__slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3118
slab_alloc_node mm/slub.c:3209 [inline]
slab_alloc mm/slub.c:3251 [inline]
kmem_cache_alloc_trace+0x323/0x3e0 mm/slub.c:3282
kmalloc include/linux/slab.h:600 [inline]
__io_queue_proc+0x2dc/0x950 io_uring/poll.c:429
poll_wait include/linux/poll.h:49 [inline]
n_tty_poll+0xb4/0x8a0 drivers/tty/n_tty.c:2425
tty_poll+0x139/0x1b0 drivers/tty/tty_io.c:2212
vfs_poll include/linux/poll.h:88 [inline]
__io_arm_poll_handler+0x488/0x1060 io_uring/poll.c:511
io_arm_poll_handler+0x5c6/0xce0 io_uring/poll.c:638
io_queue_async+0xc1/0x3e0 io_uring/io_uring.c:1753
io_queue_sqe io_uring/io_uring.c:1787 [inline]
io_submit_sqe io_uring/io_uring.c:2036 [inline]
io_submit_sqes+0x15fc/0x1ec0 io_uring/io_uring.c:2147
__do_sys_io_uring_enter+0xb85/0x1eb0 io_uring/io_uring.c:3087
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1453 [inline]
free_pcp_prepare+0x5e4/0xd20 mm/page_alloc.c:1503
free_unref_page_prepare mm/page_alloc.c:3383 [inline]
free_unref_page+0x19/0x4d0 mm/page_alloc.c:3479
__vunmap+0x85d/0xd30 mm/vmalloc.c:2696
free_work+0x58/0x70 mm/vmalloc.c:97
process_one_work+0x991/0x1610 kernel/workqueue.c:2289
worker_thread+0x665/0x1080 kernel/workqueue.c:2436
kthread+0x2e9/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302

Memory state around the buggy address:
ffff88807456a100: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88807456a180: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88807456a200: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff88807456a280: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff88807456a300: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================


---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Sep 4, 2022, 11:48:19 PM9/4/22
to syzkaller-upst...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages