syzbot


KASAN: use-after-free Read in io_poll_remove_entries
Status: upstream: reported C repro on 2022/03/22 08:52
Reported-by: syzbot+cd301bb6523ea8cc8ca2@syzkaller.appspotmail.com
First crash: 66d, last: 7h03m

Cause bisection: introduced by (bisect log) :
commit 91eac1c69c202d9dad8bf717ae5b92db70bfe5cf
Author: Jens Axboe <axboe@kernel.dk>
Date: Wed Mar 16 22:59:10 2022 +0000

  io_uring: cache poll/double-poll state with a request flag

Crash: KASAN: use-after-free Read in tty_release (log)
Repro: C syz .config
Patch testing requests:
Created Duration User Patch Repo Result
2022/03/23 01:22 12m axboe@kernel.dk git://git.kernel.dk/linux-block for-5.18/io_uring OK

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0x3eb0/0x56c0 kernel/locking/lockdep.c:4899
Read of size 8 at addr ffff88807dc21328 by task kworker/0:3/3314

CPU: 0 PID: 3314 Comm: kworker/0:3 Not tainted 5.18.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events io_fallback_req_func
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 __lock_acquire+0x3eb0/0x56c0 kernel/locking/lockdep.c:4899
 lock_acquire kernel/locking/lockdep.c:5641 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5606
 __raw_spin_lock_irq include/linux/spinlock_api_smp.h:119 [inline]
 _raw_spin_lock_irq+0x32/0x50 kernel/locking/spinlock.c:170
 spin_lock_irq include/linux/spinlock.h:374 [inline]
 io_poll_remove_entry fs/io_uring.c:5794 [inline]
 io_poll_remove_entries.part.0+0x15f/0x7e0 fs/io_uring.c:5827
 io_poll_remove_entries fs/io_uring.c:5807 [inline]
 io_apoll_task_func+0xe6/0x270 fs/io_uring.c:5928
 io_fallback_req_func+0xf9/0x1ae fs/io_uring.c:1497
 process_one_work+0x996/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:298
 </TASK>

Allocated by task 4579:
 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
 io_ring_ctx_alloc fs/io_uring.c:1511 [inline]
 io_uring_create fs/io_uring.c:11146 [inline]
 io_uring_setup.cold+0x133/0x257d fs/io_uring.c:11253
 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+0x44/0xae

Freed by task 3626:
 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/0x1a0 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1728 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754
 slab_free mm/slub.c:3510 [inline]
 kfree+0xd6/0x4d0 mm/slub.c:4552
 io_ring_ctx_free fs/io_uring.c:9967 [inline]
 io_ring_exit_work+0xf57/0xf9d fs/io_uring.c:10110
 process_one_work+0x996/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:298

Last potentially related work creation:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348
 insert_work+0x48/0x350 kernel/workqueue.c:1358
 __queue_work+0x62e/0x1140 kernel/workqueue.c:1517
 queue_work_on+0xee/0x110 kernel/workqueue.c:1545
 queue_work include/linux/workqueue.h:502 [inline]
 io_ring_ctx_wait_and_kill+0x2f2/0x327 fs/io_uring.c:10163
 io_uring_release+0x42/0x46 fs/io_uring.c:10171
 __fput+0x277/0x9d0 fs/file_table.c:317
 task_work_run+0xdd/0x1a0 kernel/task_work.c:164
 exit_task_work include/linux/task_work.h:37 [inline]
 do_exit+0xaff/0x2a00 kernel/exit.c:795
 io_sq_thread.cold+0x1b9/0x1c3 fs/io_uring.c:8056
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

The buggy address belongs to the object at ffff88807dc21000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 808 bytes inside of
 2048-byte region [ffff88807dc21000, ffff88807dc21800)

The buggy address belongs to the physical page:
page:ffffea0001f70800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7dc20
head:ffffea0001f70800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888010c42000
raw: 0000000000000000 0000000080080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4579, tgid 4579 (syz-executor771), ts 58231839072, free_ts 58158976115
 prep_new_page mm/page_alloc.c:2441 [inline]
 get_page_from_freelist+0xba2/0x3e00 mm/page_alloc.c:4182
 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5408
 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272
 alloc_slab_page mm/slub.c:1799 [inline]
 allocate_slab+0x26c/0x3c0 mm/slub.c:1944
 new_slab mm/slub.c:2004 [inline]
 ___slab_alloc+0x8df/0xf20 mm/slub.c:3005
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3092
 slab_alloc_node mm/slub.c:3183 [inline]
 slab_alloc mm/slub.c:3225 [inline]
 __kmalloc+0x318/0x350 mm/slub.c:4410
 kmalloc include/linux/slab.h:586 [inline]
 sk_prot_alloc+0x110/0x290 net/core/sock.c:1936
 sk_alloc+0x36/0x770 net/core/sock.c:1989
 alg_create+0x9a/0x150 crypto/af_alg.c:381
 __sock_create+0x353/0x790 net/socket.c:1468
 sock_create net/socket.c:1519 [inline]
 __sys_socket+0xef/0x200 net/socket.c:1561
 __do_sys_socket net/socket.c:1570 [inline]
 __se_sys_socket net/socket.c:1568 [inline]
 __x64_sys_socket+0x6f/0xb0 net/socket.c:1568
 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+0x44/0xae
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1356 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1406
 free_unref_page_prepare mm/page_alloc.c:3328 [inline]
 free_unref_page+0x19/0x6a0 mm/page_alloc.c:3423
 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2523
 qlink_free mm/kasan/quarantine.c:157 [inline]
 qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:446
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:749 [inline]
 slab_alloc_node mm/slub.c:3217 [inline]
 kmem_cache_alloc_node+0x255/0x3f0 mm/slub.c:3267
 __alloc_skb+0x215/0x340 net/core/skbuff.c:414
 alloc_skb_fclone include/linux/skbuff.h:1350 [inline]
 tcp_stream_alloc_skb+0x66/0x900 net/ipv4/tcp.c:863
 tcp_sendmsg_locked+0xac8/0x2fb0 net/ipv4/tcp.c:1298
 tcp_sendmsg+0x2b/0x40 net/ipv4/tcp.c:1449
 inet_sendmsg+0x99/0xe0 net/ipv4/af_inet.c:819
 sock_sendmsg_nosec net/socket.c:705 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:725
 sock_write_iter+0x283/0x3c0 net/socket.c:1061
 call_write_iter include/linux/fs.h:2050 [inline]
 new_sync_write+0x38a/0x560 fs/read_write.c:504
 vfs_write+0x7c0/0xac0 fs/read_write.c:591

Memory state around the buggy address:
 ffff88807dc21200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807dc21280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807dc21300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                  ^
 ffff88807dc21380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807dc21400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (324):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce 2022/04/18 23:51 upstream b2d229d4ddb1 8bcc32a6 .config log report syz C KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-root 2022/04/18 23:25 upstream b2d229d4ddb1 8bcc32a6 .config log report syz C KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-smack-root 2022/03/23 01:20 upstream b47d5a4f6b8d d88ef0c5 .config log report syz C KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/27 04:12 upstream babf0bb978e3 3037caa9 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/25 20:18 upstream fdaf9a5840ac 647c0e27 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/25 19:12 upstream fdaf9a5840ac 647c0e27 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/25 05:05 upstream aa051d36ce4a 647c0e27 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/24 09:59 upstream 1e57930e9f40 e7f9308d .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/05/23 19:10 upstream 4b0986a3613c 4c7657cb .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/23 15:41 upstream 4b0986a3613c 4c7657cb .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/23 05:00 upstream 4b0986a3613c 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/05/23 00:34 upstream eaea45fc0e7b 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/22 19:08 upstream eaea45fc0e7b 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/22 17:29 upstream eaea45fc0e7b 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/22 02:50 upstream 6c3f5bec9b40 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-root 2022/05/21 16:35 upstream 3b5e1590a267 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/05/21 15:32 upstream 3b5e1590a267 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/21 10:07 upstream 3b5e1590a267 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/20 06:28 upstream b015dcd62b86 cb1ac2e7 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/05/19 14:56 upstream f993aed406ea 50c53f39 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/19 09:38 upstream f993aed406ea 50c53f39 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/19 06:35 upstream f993aed406ea 50c53f39 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/19 00:18 upstream ef1302160bfb 50c53f39 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/18 10:45 upstream 210e04ff7681 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/05/17 23:16 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/17 20:07 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/05/17 13:43 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/17 11:32 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/17 04:45 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/17 02:34 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/17 00:10 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/16 22:33 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-root 2022/05/16 21:29 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/05/16 18:50 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/16 17:14 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/05/16 14:14 upstream 42226c989789 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/16 03:24 upstream bc403203d65a 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/15 13:50 upstream 2fe1020d73ca 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/05/15 09:00 upstream 2fe1020d73ca 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/05/15 06:34 upstream 2fe1020d73ca 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-smack-root 2022/05/14 08:39 upstream ec7f49619d8e 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-selinux-root 2022/03/22 06:18 upstream 8565d64430f8 e2d91b1d .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-386 2022/05/27 12:47 upstream 7e284070abe5 116e7a7b .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-386 2022/05/19 23:45 upstream b015dcd62b86 cb1ac2e7 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce-386 2022/05/15 15:17 upstream bc403203d65a 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-linux-next-kasan-gce-root 2022/05/26 18:55 linux-next b1d84fc09a96 3037caa9 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-linux-next-kasan-gce-root 2022/05/23 08:46 linux-next 18ecd30af1a8 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-linux-next-kasan-gce-root 2022/05/22 08:12 linux-next 18ecd30af1a8 7268fa62 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-linux-next-kasan-gce-root 2022/05/21 00:47 linux-next 18ecd30af1a8 bd37ad7e .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-linux-next-kasan-gce-root 2022/05/19 11:02 linux-next 3f7bdc402fb0 50c53f39 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-linux-next-kasan-gce-root 2022/05/17 08:27 linux-next 3f7bdc402fb0 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-linux-next-kasan-gce-root 2022/05/17 05:55 linux-next 3f7bdc402fb0 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-linux-next-kasan-gce-root 2022/05/15 16:50 linux-next 1e1b28b936ae 744a39e2 .config log report info KASAN: use-after-free Read in io_poll_remove_entries
ci-upstream-kasan-gce 2022/04/10 16:19 upstream e1f700ebd6be e22c3da3 .config log report info KFENCE: use-after-free in io_poll_remove_entries
ci-upstream-kasan-gce-386 2022/04/01 13:45 upstream e8b767f5e040 20955a24 .config log report info BUG: corrupted list in io_poll_remove_entries