================================================================== BUG: KASAN: use-after-free in handle_userfault+0x2076/0x23a0 fs/userfaultfd.c:371 Read of size 8 at addr ffff8801cb5f86a0 by task syz-executor0/9993 CPU: 0 PID: 9993 Comm: syz-executor0 Not tainted 4.14.0-rc7+ #160 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x257 lib/dump_stack.c:53 print_address_description+0x73/0x250 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 [inline] kasan_report+0x25b/0x340 mm/kasan/report.c:409 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430 handle_userfault+0x2076/0x23a0 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+0x5c9/0xc90 arch/x86/mm/fault.c:1455 do_page_fault+0xee/0x720 arch/x86/mm/fault.c:1530 page_fault+0x22/0x30 arch/x86/entry/entry_64.S:1067 RIP: 0010:__clear_user+0x42/0x70 arch/x86/lib/usercopy_64.c:23 RSP: 0000:ffff8801c7937b88 EFLAGS: 00010202 RAX: 0000000000000000 RBX: 0000000000000008 RCX: 0000000000000008 RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000020012e40 RBP: ffff8801c7937b98 R08: 0000000000000001 R09: 1ffff10038f26f4d R10: ffff8801c7937a30 R11: 0000000000000000 R12: 0000000020012e40 R13: ffff8801c5b5a540 R14: 0000000020012c40 R15: 00007ffffffff000 copy_xregs_to_user arch/x86/include/asm/fpu/internal.h:372 [inline] copy_fpregs_to_sigframe arch/x86/kernel/fpu/signal.c:126 [inline] copy_fpstate_to_sigframe+0x196/0x470 arch/x86/kernel/fpu/signal.c:177 get_sigframe arch/x86/kernel/signal.c:284 [inline] __setup_rt_frame arch/x86/kernel/signal.c:465 [inline] setup_rt_frame arch/x86/kernel/signal.c:699 [inline] handle_signal arch/x86/kernel/signal.c:743 [inline] do_signal+0x9f6/0x1ee0 arch/x86/kernel/signal.c:811 exit_to_usermode_loop+0x214/0x310 arch/x86/entry/common.c:158 prepare_exit_to_usermode+0x273/0x2d0 arch/x86/entry/common.c:197 retint_user+0x8/0x20 RIP: 0033: (null) RSP: 002b:0000000020013008 EFLAGS: 00010217 RAX: 0000000000000000 RBX: 0000000000758020 RCX: 0000000000452869 RDX: 0000000020059ffc RSI: 0000000020013000 RDI: 0000000000000400 RBP: 0000000000000047 R08: 0000000020058ffd R09: 0000000000000000 R10: 0000000020058ffc R11: 0000000000000212 R12: 00000000006ee748 R13: 00000000ffffffff R14: 00007ff888b896d4 R15: 0000000000000000 Allocated by task 9978: 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:3562 dup_userfaultfd+0x21c/0x890 fs/userfaultfd.c:659 dup_mmap kernel/fork.c:662 [inline] dup_mm kernel/fork.c:1201 [inline] copy_mm+0xa38/0x1310 kernel/fork.c:1255 copy_process.part.39+0x1ea3/0x4af0 kernel/fork.c:1757 copy_process kernel/fork.c:1570 [inline] _do_fork+0x1ef/0xfb0 kernel/fork.c:2049 SYSC_clone kernel/fork.c:2159 [inline] SyS_clone+0x37/0x50 kernel/fork.c:2153 do_syscall_64+0x26c/0x8d0 arch/x86/entry/common.c:287 return_from_SYSCALL_64+0x0/0x7a Freed by task 9978: 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:3504 [inline] kmem_cache_free+0x77/0x280 mm/slab.c:3764 userfaultfd_ctx_put+0x50c/0x740 fs/userfaultfd.c:165 userfaultfd_event_wait_completion+0x788/0x9c0 fs/userfaultfd.c:605 dup_fctx fs/userfaultfd.c:693 [inline] dup_userfaultfd_complete+0x2de/0x480 fs/userfaultfd.c:701 dup_mmap kernel/fork.c:730 [inline] dup_mm kernel/fork.c:1201 [inline] copy_mm+0xe9b/0x1310 kernel/fork.c:1255 copy_process.part.39+0x1ea3/0x4af0 kernel/fork.c:1757 copy_process kernel/fork.c:1570 [inline] _do_fork+0x1ef/0xfb0 kernel/fork.c:2049 SYSC_clone kernel/fork.c:2159 [inline] SyS_clone+0x37/0x50 kernel/fork.c:2153 do_syscall_64+0x26c/0x8d0 arch/x86/entry/common.c:287 return_from_SYSCALL_64+0x0/0x7a The buggy address belongs to the object at ffff8801cb5f8540 which belongs to the cache userfaultfd_ctx_cache of size 360 The buggy address is located 352 bytes inside of 360-byte region [ffff8801cb5f8540, ffff8801cb5f86a8) The buggy address belongs to the page: page:ffffea00072d7e00 count:1 mapcount:0 mapping:ffff8801cb5f8000 index:0xffff8801cb5f8ff7 flags: 0x200000000000100(slab) raw: 0200000000000100 ffff8801cb5f8000 ffff8801cb5f8ff7 0000000100000009 raw: ffffea00073551e0 ffffea00072324e0 ffff8801d6620d80 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8801cb5f8580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8801cb5f8600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8801cb5f8680: fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc ^ ffff8801cb5f8700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8801cb5f8780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ==================================================================