Kernel bug: KASAN: slab-use-after-free Read in io_waitid_wait
Subsystem: io-uring
Status: fixed

Crash report:
==================================================================
BUG: KASAN: slab-use-after-free in __list_del_entry_valid_or_report+0x1ba/0x200 lib/list_debug.c:49
Read of size 8 at addr ffff888051712d50 by task syz.0.17/6127

CPU: 0 UID: 0 PID: 6127 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xcd/0x630 mm/kasan/report.c:482
 kasan_report+0xe0/0x110 mm/kasan/report.c:595
 __list_del_entry_valid_or_report+0x1ba/0x200 lib/list_debug.c:49
 __list_del_entry_valid include/linux/list.h:132 [inline]
 __list_del_entry include/linux/list.h:223 [inline]
 list_del_init include/linux/list.h:295 [inline]
 io_waitid_wait+0xf7/0x230 io_uring/waitid.c:239
 __wake_up_common+0x132/0x1f0 kernel/sched/wait.c:108
 __wake_up_common_lock kernel/sched/wait.c:125 [inline]
 __wake_up_sync_key+0x36/0x50 kernel/sched/wait.c:192
 do_notify_parent_cldstop+0x540/0xb50 kernel/signal.c:2333
 ptrace_stop.part.0+0x7e1/0x950 kernel/signal.c:2437
 ptrace_stop kernel/signal.c:2376 [inline]
 ptrace_signal kernel/signal.c:2743 [inline]
 get_signal+0x13d5/0x26d0 kernel/signal.c:2921
 arch_do_signal_or_restart+0x8f/0x7c0 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop kernel/entry/common.c:40 [inline]
 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline]
 irqentry_exit_to_user_mode+0x141/0x2b0 kernel/entry/common.c:73
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623
RIP: 0033:0x7fc598db6c60
Code: 6e c7 89 13 48 8b 50 08 0f 16 40 50 0f 11 00 48 89 50 50 48 8b 50 10 48 89 78 10 48 89 50 40 48 89 d7 eb b2 66 0f 1f 44 00 00 <64> 48 8b 0c 25 10 00 00 00 8b 91 08 03 00 00 48 8d b9 08 03 00 00
RSP: 002b:00007ffccd0733d8 EFLAGS: 00010202
RAX: 00000000fffffffa RBX: 00007fc598fe5fa0 RCX: 0000000000000000
RDX: 00007ffccd073420 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 00007fc598e11f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fc598fe5fa0 R14: 00007fc598fe5fa0 R15: 0000000000000006
 </TASK>

Allocated by task 6123:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:56
 kasan_save_track+0x14/0x30 mm/kasan/common.c:77
 poison_kmalloc_redzone mm/kasan/common.c:400 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:417
 kasan_kmalloc include/linux/kasan.h:262 [inline]
 __do_kmalloc_node mm/slub.c:5603 [inline]
 __kmalloc_noprof+0x32f/0x880 mm/slub.c:5615
 kmalloc_noprof include/linux/slab.h:961 [inline]
 io_uring_alloc_async_data io_uring/io_uring.h:328 [inline]
 io_waitid_prep+0x1aa/0x470 io_uring/waitid.c:251
 io_init_req io_uring/io_uring.c:2248 [inline]
 io_submit_sqe io_uring/io_uring.c:2295 [inline]
 io_submit_sqes+0x855/0x2710 io_uring/io_uring.c:2447
 __do_sys_io_uring_enter+0xd69/0x1630 io_uring/io_uring.c:3514
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0x4e0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 6123:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:56
 kasan_save_track+0x14/0x30 mm/kasan/common.c:77
 __kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:587
 kasan_save_free_info mm/kasan/kasan.h:406 [inline]
 poison_slab_object mm/kasan/common.c:252 [inline]
 __kasan_slab_free+0x5f/0x80 mm/kasan/common.c:284
 kasan_slab_free include/linux/kasan.h:234 [inline]
 slab_free_hook mm/slub.c:2514 [inline]
 slab_free mm/slub.c:6566 [inline]
 kfree+0x2b8/0x6d0 mm/slub.c:6773
 io_req_async_data_free io_uring/io_uring.h:349 [inline]
 io_waitid_free io_uring/waitid.c:40 [inline]
 io_waitid_finish io_uring/waitid.c:108 [inline]
 io_waitid_complete+0x249/0x5e0 io_uring/waitid.c:123
 io_waitid_cb+0xe4/0x3a0 io_uring/waitid.c:217
 io_handle_tw_list+0x483/0x500 io_uring/io_uring.c:1151
 tctx_task_work_run+0xac/0x380 io_uring/io_uring.c:1216
 tctx_task_work+0x7a/0xd0 io_uring/io_uring.c:1234
 task_work_run+0x150/0x240 kernel/task_work.c:227
 get_signal+0x1d0/0x26d0 kernel/signal.c:2807
 arch_do_signal_or_restart+0x8f/0x7c0 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop kernel/entry/common.c:40 [inline]
 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline]
 irqentry_exit_to_user_mode+0x141/0x2b0 kernel/entry/common.c:73
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:623

The buggy address belongs to the object at ffff888051712d00
 which belongs to the cache kmalloc-96 of size 96
The buggy address is located 80 bytes inside of
 freed 96-byte region [ffff888051712d00, ffff888051712d60)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x51712
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000000 ffff88801b042280 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080200020 00000000f5000000 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 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 6123, tgid 6123 (syz.0.17), ts 124233232510, free_ts 119982111762
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1c0/0x230 mm/page_alloc.c:1850
 prep_new_page mm/page_alloc.c:1858 [inline]
 get_page_from_freelist+0x10a3/0x3a30 mm/page_alloc.c:3884
 __alloc_frozen_pages_noprof+0x25f/0x2470 mm/page_alloc.c:5183
 alloc_pages_mpol+0x1fb/0x550 mm/mempolicy.c:2416
 alloc_slab_page mm/slub.c:3030 [inline]
 allocate_slab mm/slub.c:3203 [inline]
 new_slab+0x24a/0x360 mm/slub.c:3257
 ___slab_alloc+0xdc4/0x1ae0 mm/slub.c:4627
 __slab_alloc.constprop.0+0x63/0x110 mm/slub.c:4746
 __slab_alloc_node mm/slub.c:4822 [inline]
 slab_alloc_node mm/slub.c:5233 [inline]
 __do_kmalloc_node mm/slub.c:5602 [inline]
 __kmalloc_noprof+0x501/0x880 mm/slub.c:5615
 kmalloc_noprof include/linux/slab.h:961 [inline]
 io_uring_alloc_async_data io_uring/io_uring.h:328 [inline]
 io_waitid_prep+0x1aa/0x470 io_uring/waitid.c:251
 io_init_req io_uring/io_uring.c:2248 [inline]
 io_submit_sqe io_uring/io_uring.c:2295 [inline]
 io_submit_sqes+0x855/0x2710 io_uring/io_uring.c:2447
 __do_sys_io_uring_enter+0xd69/0x1630 io_uring/io_uring.c:3514
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xcd/0x4e0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 6077 tgid 6077 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1394 [inline]
 __free_frozen_pages+0x7df/0x1160 mm/page_alloc.c:2906
 vfree+0x1fd/0xb50 mm/vmalloc.c:3440
 kcov_put kernel/kcov.c:439 [inline]
 kcov_put kernel/kcov.c:435 [inline]
 kcov_close+0x34/0x60 kernel/kcov.c:535
 __fput+0x402/0xb70 fs/file_table.c:468
 task_work_run+0x150/0x240 kernel/task_work.c:227
 exit_task_work include/linux/task_work.h:40 [inline]
 do_exit+0x86f/0x2bf0 kernel/exit.c:966
 do_group_exit+0xd3/0x2a0 kernel/exit.c:1107
 get_signal+0x2671/0x26d0 kernel/signal.c:3034
 arch_do_signal_or_restart+0x8f/0x7c0 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop+0x85/0x130 kernel/entry/common.c:40
 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline]
 syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline]
 do_syscall_64+0x419/0x4e0 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888051712c00: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
 ffff888051712c80: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc
>ffff888051712d00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                                                 ^
 ffff888051712d80: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
 ffff888051712e00: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc
==================================================================