================================================================== BUG: KASAN: use-after-free in handle_userfault+0x206f/0x2390 fs/userfaultfd.c:371 Read of size 8 at addr ffff8801c9b02388 by task syz-executor2/4173 CPU: 0 PID: 4173 Comm: syz-executor2 Not tainted 4.13.0-mm1+ #7 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 handle_userfault+0x206f/0x2390 fs/userfaultfd.c:371 do_anonymous_page mm/memory.c:3135 [inline] handle_pte_fault mm/memory.c:3908 [inline] __handle_mm_fault+0x3823/0x39c0 mm/memory.c:4034 handle_mm_fault+0x334/0x8d0 mm/memory.c:4071 __do_page_fault+0x4f6/0xb60 arch/x86/mm/fault.c:1445 do_page_fault+0xee/0x720 arch/x86/mm/fault.c:1520 page_fault+0x22/0x30 arch/x86/entry/entry_64.S:1066 RIP: 0010:__clear_user+0x42/0x70 arch/x86/lib/usercopy_64.c:23 RSP: 0000:ffff8801d4edfb88 EFLAGS: 00010202 RAX: 0000000000000000 RBX: 0000000000000008 RCX: 0000000000000008 RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000020012e40 RBP: ffff8801d4edfb98 R08: ffff8801d74379a0 R09: 1ffff1003a9dbf45 R10: ffff8801d46b0200 R11: 0000000000000000 R12: 0000000020012e40 R13: ffff8801d46b0200 R14: ffff8801d46b0200 R15: 0000000020012f84 copy_xregs_to_user arch/x86/include/asm/fpu/internal.h:394 [inline] copy_fpregs_to_sigframe arch/x86/kernel/fpu/signal.c:125 [inline] copy_fpstate_to_sigframe+0x196/0x470 arch/x86/kernel/fpu/signal.c:175 get_sigframe arch/x86/kernel/signal.c:283 [inline] __setup_rt_frame arch/x86/kernel/signal.c:464 [inline] setup_rt_frame arch/x86/kernel/signal.c:698 [inline] handle_signal arch/x86/kernel/signal.c:742 [inline] do_signal+0x9f6/0x1ee0 arch/x86/kernel/signal.c:810 exit_to_usermode_loop+0x224/0x300 arch/x86/entry/common.c:158 prepare_exit_to_usermode+0x267/0x2c0 arch/x86/entry/common.c:197 retint_user+0x8/0x20 RIP: 0033: (null) RSP: 002b:0000000020013008 EFLAGS: 00010217 RAX: 0000000000000000 RBX: 0000000000718000 RCX: 0000000000451e59 RDX: 0000000020059ffc RSI: 0000000020013000 RDI: 0000000000000400 RBP: 0000000000000450 R08: 0000000020058ffd R09: 0000000000000000 R10: 0000000020058ffc R11: 0000000000000216 R12: 00000000004b721f R13: 00000000ffffffff R14: 0000000000000400 R15: 0000000020013000 Allocated by task 4156: 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+0x1eae/0x4af0 kernel/fork.c:1735 copy_process kernel/fork.c:1548 [inline] _do_fork+0x1ef/0xfe0 kernel/fork.c:2027 SYSC_clone kernel/fork.c:2138 [inline] SyS_clone+0x37/0x50 kernel/fork.c:2132 do_syscall_64+0x26c/0x8c0 arch/x86/entry/common.c:287 return_from_SYSCALL_64+0x0/0x7a Freed by task 4156: 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+0x1eae/0x4af0 kernel/fork.c:1735 copy_process kernel/fork.c:1548 [inline] _do_fork+0x1ef/0xfe0 kernel/fork.c:2027 SYSC_clone kernel/fork.c:2138 [inline] SyS_clone+0x37/0x50 kernel/fork.c:2132 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 ffff8801c9b02200 which belongs to the cache userfaultfd_ctx_cache of size 400 The buggy address is located 392 bytes inside of 400-byte region [ffff8801c9b02200, ffff8801c9b02390) The buggy address belongs to the page: page:ffffea000726c080 count:1 mapcount:0 mapping:ffff8801c9b02000 index:0xffff8801d79b0bc0 flags: 0x200000000000100(slab) raw: 0200000000000100 ffff8801c9b02000 ffff8801d79b0bc0 0000000100000008 raw: ffff8801d56e4a50 ffff8801d56e4a50 ffff8801d56e3600 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8801c9b02280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8801c9b02300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8801c9b02380: fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff8801c9b02400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8801c9b02480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================