================================================================== BUG: KASAN: use-after-free in io_cancel_defer_files fs/io_uring.c:8641 [inline] BUG: KASAN: use-after-free in io_uring_cancel_task_requests+0x563/0x2c50 fs/io_uring.c:8759 Read of size 8 at addr ffff88814449af08 by task syz-executor.3/21304 CPU: 0 PID: 21304 Comm: syz-executor.3 Not tainted 5.10.102-syzkaller-00166-gcbfab5c59cf6 #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_lvl+0x1e2/0x24b lib/dump_stack.c:118 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233 __kasan_report+0x142/0x220 mm/kasan/report.c:419 kasan_report+0x51/0x70 mm/kasan/report.c:436 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309 io_cancel_defer_files fs/io_uring.c:8641 [inline] io_uring_cancel_task_requests+0x563/0x2c50 fs/io_uring.c:8759 __io_uring_files_cancel+0x151/0x350 fs/io_uring.c:8845 io_uring_files_cancel include/linux/io_uring.h:51 [inline] do_exit+0x2cc/0x23a0 kernel/exit.c:768 do_group_exit+0x16a/0x2d0 kernel/exit.c:910 get_signal+0x131f/0x1f70 kernel/signal.c:2780 arch_do_signal+0x8d/0x620 arch/x86/kernel/signal.c:805 exit_to_user_mode_loop kernel/entry/common.c:161 [inline] exit_to_user_mode_prepare+0xaa/0xe0 kernel/entry/common.c:191 syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:266 do_syscall_64+0x3d/0x70 arch/x86/entry/common.c:56 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fde135de059 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:00007fde126d0168 EFLAGS: 00000246 ORIG_RAX: 00000000000001aa RAX: 0000000000004000 RBX: 00007fde136f12a0 RCX: 00007fde135de059 RDX: 0000000000000000 RSI: 00000000000051f4 RDI: 0000000000000003 RBP: 00007fde1363808d R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffeff4a990f R14: 00007fde126d0300 R15: 0000000000022000 Allocated by task 21304: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:428 [inline] ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516 kasan_kmalloc include/linux/kasan.h:269 [inline] kmem_cache_alloc_trace+0x210/0x3a0 mm/slub.c:2981 kmalloc include/linux/slab.h:552 [inline] io_req_defer+0x40e/0x11b0 fs/io_uring.c:5923 io_queue_sqe+0x2a/0x1180 fs/io_uring.c:6399 io_queue_link_head fs/io_uring.c:6431 [inline] io_submit_sqes+0x18d3/0x2da0 fs/io_uring.c:6732 __do_sys_io_uring_enter fs/io_uring.c:9113 [inline] __se_sys_io_uring_enter+0x322/0x12b0 fs/io_uring.c:9055 __x64_sys_io_uring_enter+0xe5/0x100 fs/io_uring.c:9055 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Freed by task 21300: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4c/0x80 mm/kasan/common.c:46 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357 ____kasan_slab_free+0x133/0x170 mm/kasan/common.c:360 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368 kasan_slab_free include/linux/kasan.h:235 [inline] slab_free_hook mm/slub.c:1602 [inline] slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1628 slab_free mm/slub.c:3210 [inline] kfree+0xd5/0x320 mm/slub.c:4198 __io_queue_deferred fs/io_uring.c:1541 [inline] io_commit_cqring+0x76a/0xa00 fs/io_uring.c:1587 io_iopoll_complete fs/io_uring.c:2380 [inline] io_do_iopoll+0x1e18/0x23f0 fs/io_uring.c:2433 io_iopoll_try_reap_events+0x116/0x290 fs/io_uring.c:2472 __io_uring_cancel_task_requests fs/io_uring.c:8715 [inline] io_uring_cancel_task_requests+0x26ad/0x2c50 fs/io_uring.c:8763 io_uring_flush+0x170/0x6d0 fs/io_uring.c:8926 filp_close+0xb0/0x150 fs/open.c:1319 close_files fs/file.c:401 [inline] put_files_struct+0x1d4/0x350 fs/file.c:429 exit_files+0x80/0xa0 fs/file.c:458 do_exit+0x6d9/0x23a0 kernel/exit.c:808 __do_sys_exit+0x18/0x20 kernel/exit.c:879 __se_sys_exit+0x14/0x20 kernel/exit.c:877 __x64_sys_exit+0x3b/0x40 kernel/exit.c:877 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 The buggy address belongs to the object at ffff88814449af00 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 8 bytes inside of 32-byte region [ffff88814449af00, ffff88814449af20) The buggy address belongs to the page: page:ffffea0005112680 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x14449a flags: 0x8000000000000200(slab) raw: 8000000000000200 ffffea000420ff00 0000001300000013 ffff888100043980 raw: 0000000000000000 0000000080400040 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 5926, ts 414044536156, free_ts 413985921428 set_page_owner include/linux/page_owner.h:35 [inline] post_alloc_hook mm/page_alloc.c:2385 [inline] prep_new_page mm/page_alloc.c:2391 [inline] get_page_from_freelist+0xa74/0xa90 mm/page_alloc.c:4063 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5107 alloc_slab_page mm/slub.c:1813 [inline] allocate_slab+0x6b/0x350 mm/slub.c:1815 new_slab mm/slub.c:1876 [inline] new_slab_objects mm/slub.c:2635 [inline] ___slab_alloc+0x143/0x2f0 mm/slub.c:2798 __slab_alloc mm/slub.c:2838 [inline] slab_alloc_node mm/slub.c:2920 [inline] slab_alloc mm/slub.c:2962 [inline] kmem_cache_alloc_trace+0x278/0x3a0 mm/slub.c:2979 kmalloc include/linux/slab.h:552 [inline] io_req_defer+0x40e/0x11b0 fs/io_uring.c:5923 io_queue_sqe+0x2a/0x1180 fs/io_uring.c:6399 io_submit_sqe+0x385/0xfd0 fs/io_uring.c:6489 io_submit_sqes+0x1050/0x2da0 fs/io_uring.c:6717 __do_sys_io_uring_enter fs/io_uring.c:9113 [inline] __se_sys_io_uring_enter+0x322/0x12b0 fs/io_uring.c:9055 __x64_sys_io_uring_enter+0xe5/0x100 fs/io_uring.c:9055 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9 page last free stack trace: reset_page_owner include/linux/page_owner.h:28 [inline] free_pages_prepare mm/page_alloc.c:1331 [inline] free_pcp_prepare+0x18f/0x1c0 mm/page_alloc.c:1405 free_unref_page_prepare mm/page_alloc.c:3291 [inline] free_unref_page mm/page_alloc.c:3341 [inline] free_the_page mm/page_alloc.c:5166 [inline] __free_pages+0x2e3/0x4a0 mm/page_alloc.c:5174 __free_slab+0xdf/0x1a0 mm/slub.c:1901 free_slab mm/slub.c:1916 [inline] discard_slab mm/slub.c:1922 [inline] unfreeze_partials+0x17d/0x1b0 mm/slub.c:2416 put_cpu_partial+0xc8/0x190 mm/slub.c:2452 __slab_free+0x2eb/0x4e0 mm/slub.c:3102 do_slab_free mm/slub.c:3198 [inline] ___cache_free+0x131/0x150 mm/slub.c:3217 qlink_free+0x38/0x40 mm/kasan/quarantine.c:146 qlist_free_all mm/kasan/quarantine.c:165 [inline] kasan_quarantine_reduce+0x178/0x1d0 mm/kasan/quarantine.c:272 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:438 kasan_slab_alloc include/linux/kasan.h:259 [inline] slab_post_alloc_hook mm/slab.h:583 [inline] slab_alloc_node mm/slub.c:2954 [inline] slab_alloc mm/slub.c:2962 [inline] kmem_cache_alloc+0x1a2/0x380 mm/slub.c:2967 getname_flags+0xba/0x650 fs/namei.c:141 user_path_at_empty+0x2d/0x50 fs/namei.c:2726 user_path_at include/linux/namei.h:59 [inline] vfs_statx+0x10a/0x3f0 fs/stat.c:193 vfs_fstatat fs/stat.c:215 [inline] __do_sys_newfstatat fs/stat.c:384 [inline] __se_sys_newfstatat+0xc8/0x760 fs/stat.c:378 __x64_sys_newfstatat+0x9b/0xb0 fs/stat.c:378 Memory state around the buggy address: ffff88814449ae00: fb fb fb fb fc fc fc fc 00 00 03 fc fc fc fc fc ffff88814449ae80: fb fb fb fb fc fc fc fc 00 00 00 04 fc fc fc fc >ffff88814449af00: fa fb fb fb fc fc fc fc 00 00 01 fc fc fc fc fc ^ ffff88814449af80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff88814449b000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== general protection fault, probably for non-canonical address 0xf13bfc3e00000a68: 0000 [#1] PREEMPT SMP KASAN KASAN: maybe wild-memory-access in range [0x89e001f000005340-0x89e001f000005347] CPU: 0 PID: 21304 Comm: syz-executor.3 Tainted: G B 5.10.102-syzkaller-00166-gcbfab5c59cf6 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:io_cancel_defer_files fs/io_uring.c:8642 [inline] RIP: 0010:io_uring_cancel_task_requests+0x580/0x2c50 fs/io_uring.c:8759 Code: 3c 08 00 74 08 4c 89 f7 e8 fd 71 e2 ff 4d 8b 36 4d 39 fe 74 40 49 8d 5e 10 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 48 89 df e8 d2 71 e2 ff 48 8b 3b 48 8b 74 24 18 RSP: 0018:ffffc90006b47700 EFLAGS: 00010803 RAX: 113c003e00000a68 RBX: 89e001f000005344 RCX: dffffc0000000000 RDX: 0000000000000000 RSI: 0000000000000046 RDI: 0000000000000001 RBP: ffffc90006b47910 R08: ffffffff813fcc54 R09: fffffbfff0dc85b9 R10: fffffbfff0dc85b9 R11: 0000000000000000 R12: 1ffff11022abec0f R13: ffff8881155f6000 R14: 89e001f000005334 R15: ffff8881155f6070 FS: 00007fde126d0700(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fde127129d0 CR3: 000000014a060000 CR4: 00000000003506b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __io_uring_files_cancel+0x151/0x350 fs/io_uring.c:8845 io_uring_files_cancel include/linux/io_uring.h:51 [inline] do_exit+0x2cc/0x23a0 kernel/exit.c:768 do_group_exit+0x16a/0x2d0 kernel/exit.c:910 get_signal+0x131f/0x1f70 kernel/signal.c:2780 arch_do_signal+0x8d/0x620 arch/x86/kernel/signal.c:805 exit_to_user_mode_loop kernel/entry/common.c:161 [inline] exit_to_user_mode_prepare+0xaa/0xe0 kernel/entry/common.c:191 syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:266 do_syscall_64+0x3d/0x70 arch/x86/entry/common.c:56 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fde135de059 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:00007fde126d0168 EFLAGS: 00000246 ORIG_RAX: 00000000000001aa RAX: 0000000000004000 RBX: 00007fde136f12a0 RCX: 00007fde135de059 RDX: 0000000000000000 RSI: 00000000000051f4 RDI: 0000000000000003 RBP: 00007fde1363808d R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffeff4a990f R14: 00007fde126d0300 R15: 0000000000022000 Modules linked in: ---[ end trace a1711cf0a715e61f ]--- RIP: 0010:io_cancel_defer_files fs/io_uring.c:8642 [inline] RIP: 0010:io_uring_cancel_task_requests+0x580/0x2c50 fs/io_uring.c:8759 Code: 3c 08 00 74 08 4c 89 f7 e8 fd 71 e2 ff 4d 8b 36 4d 39 fe 74 40 49 8d 5e 10 48 89 d8 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 48 89 df e8 d2 71 e2 ff 48 8b 3b 48 8b 74 24 18 RSP: 0018:ffffc90006b47700 EFLAGS: 00010803 RAX: 113c003e00000a68 RBX: 89e001f000005344 RCX: dffffc0000000000 RDX: 0000000000000000 RSI: 0000000000000046 RDI: 0000000000000001 RBP: ffffc90006b47910 R08: ffffffff813fcc54 R09: fffffbfff0dc85b9 R10: fffffbfff0dc85b9 R11: 0000000000000000 R12: 1ffff11022abec0f R13: ffff8881155f6000 R14: 89e001f000005334 R15: ffff8881155f6070 FS: 00007fde126d0700(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fde127129d0 CR3: 000000014a060000 CR4: 00000000003506b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 ---------------- Code disassembly (best guess): 0: 3c 08 cmp $0x8,%al 2: 00 74 08 4c add %dh,0x4c(%rax,%rcx,1) 6: 89 f7 mov %esi,%edi 8: e8 fd 71 e2 ff callq 0xffe2720a d: 4d 8b 36 mov (%r14),%r14 10: 4d 39 fe cmp %r15,%r14 13: 74 40 je 0x55 15: 49 8d 5e 10 lea 0x10(%r14),%rbx 19: 48 89 d8 mov %rbx,%rax 1c: 48 c1 e8 03 shr $0x3,%rax 20: 48 b9 00 00 00 00 00 movabs $0xdffffc0000000000,%rcx 27: fc ff df * 2a: 80 3c 08 00 cmpb $0x0,(%rax,%rcx,1) <-- trapping instruction 2e: 74 08 je 0x38 30: 48 89 df mov %rbx,%rdi 33: e8 d2 71 e2 ff callq 0xffe2720a 38: 48 8b 3b mov (%rbx),%rdi 3b: 48 8b 74 24 18 mov 0x18(%rsp),%rsi