BUG: KASAN: use-after-free in userfaultfd_release+0x5c1/0x6e0 fs/userfaultfd.c:824 Read of size 8 at addr ffff8801c844e788 by task syz-executor0/4720 CPU: 1 PID: 4720 Comm: syz-executor0 Not tainted 4.13.0+ #76 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:16 [inline] dump_stack+0x194/0x257 lib/dump_stack.c:52 print_address_description+0x73/0x250 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 [inline] kasan_report+0x24e/0x340 mm/kasan/report.c:409 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430 userfaultfd_release+0x5c1/0x6e0 fs/userfaultfd.c:824 __fput+0x333/0x7f0 fs/file_table.c:210 ____fput+0x15/0x20 fs/file_table.c:246 task_work_run+0x199/0x270 kernel/task_work.c:112 exit_task_work include/linux/task_work.h:21 [inline] do_exit+0xa52/0x1b40 kernel/exit.c:865 do_group_exit+0x149/0x400 kernel/exit.c:968 get_signal+0x7e8/0x17e0 kernel/signal.c:2334 do_signal+0x94/0x1ee0 arch/x86/kernel/signal.c:808 exit_to_usermode_loop+0x224/0x300 arch/x86/entry/common.c:158 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline] syscall_return_slowpath+0x42f/0x500 arch/x86/entry/common.c:266 entry_SYSCALL_64_fastpath+0xbc/0xbe RIP: 0033:0x451e59 RSP: 002b:00007f1914e7dc08 EFLAGS: 00000216 ORIG_RAX: 0000000000000000 RAX: 0000000000000020 RBX: 0000000000718000 RCX: 0000000000451e59 RDX: 0000000000000020 RSI: 0000000020517f87 RDI: 0000000000000005 RBP: 00000000000044c0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000216 R12: 00000000004ba1ce R13: 00000000ffffffff R14: 0000000000000005 R15: 0000000020517f87 Allocated by task 4721: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 [inline] kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:551 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:489 kmem_cache_alloc+0x12e/0x760 mm/slab.c:3561 dup_userfaultfd+0x21c/0x890 fs/userfaultfd.c:653 dup_mmap kernel/fork.c:658 [inline] dup_mm kernel/fork.c:1179 [inline] copy_mm+0xa38/0x1310 kernel/fork.c:1233 copy_process.part.36+0x1ecf/0x4c00 kernel/fork.c:1739 copy_process kernel/fork.c:1548 [inline] _do_fork+0x1ef/0xfe0 kernel/fork.c:2031 SYSC_clone kernel/fork.c:2141 [inline] SyS_clone+0x37/0x50 kernel/fork.c:2135 do_syscall_64+0x26c/0x8c0 arch/x86/entry/common.c:287 return_from_SYSCALL_64+0x0/0x7a Freed by task 4721: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 [inline] kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524 __cache_free mm/slab.c:3503 [inline] kmem_cache_free+0x77/0x280 mm/slab.c:3763 userfaultfd_ctx_put+0x50c/0x740 fs/userfaultfd.c:165 userfaultfd_event_wait_completion+0x754/0x910 fs/userfaultfd.c:599 dup_fctx fs/userfaultfd.c:687 [inline] dup_userfaultfd_complete+0x2de/0x480 fs/userfaultfd.c:695 dup_mmap kernel/fork.c:726 [inline] dup_mm kernel/fork.c:1179 [inline] copy_mm+0xe9b/0x1310 kernel/fork.c:1233 copy_process.part.36+0x1ecf/0x4c00 kernel/fork.c:1739 copy_process kernel/fork.c:1548 [inline] _do_fork+0x1ef/0xfe0 kernel/fork.c:2031 SYSC_clone kernel/fork.c:2141 [inline] SyS_clone+0x37/0x50 kernel/fork.c:2135 do_syscall_64+0x26c/0x8c0 arch/x86/entry/common.c:287 return_from_SYSCALL_64+0x0/0x7a The buggy address belongs to the object at ffff8801c844e600 which belongs to the cache userfaultfd_ctx_cache of size 400 The buggy address is located 392 bytes inside of 400-byte region [ffff8801c844e600, ffff8801c844e790) The buggy address belongs to the page: page:ffffea0007211380 count:1 mapcount:0 mapping:ffff8801c844e000 index:0xffff8801ca4e7240 flags: 0x200000000000100(slab) raw: 0200000000000100 ffff8801c844e000 ffff8801ca4e7240 0000000100000008 raw: ffffea0007293f60 ffff8801d5653d50 ffff8801d5651780 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8801c844e680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8801c844e700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8801c844e780: fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff8801c844e800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8801c844e880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================