BUG: KASAN: use-after-free in free_ldt_struct.part.2+0x10a/0x150 arch/x86/kernel/ldt.c:95 Read of size 4 at addr ffff8801cae7ca08 by task kworker/u4:2/3704 CPU: 1 PID: 3704 Comm: kworker/u4:2 Not tainted 4.13.0-rc6+ #45 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_load4_noabort+0x14/0x20 mm/kasan/report.c:429 free_ldt_struct.part.2+0x10a/0x150 arch/x86/kernel/ldt.c:95 free_ldt_struct arch/x86/kernel/ldt.c:152 [inline] destroy_context_ldt+0x60/0x80 arch/x86/kernel/ldt.c:150 destroy_context arch/x86/include/asm/mmu_context.h:149 [inline] __mmdrop+0xe9/0x530 kernel/fork.c:887 mmdrop include/linux/sched/mm.h:42 [inline] exec_mmap fs/exec.c:1061 [inline] flush_old_exec+0x1737/0x1ff0 fs/exec.c:1285 load_elf_binary+0x7fb/0x4950 fs/binfmt_elf.c:854 search_binary_handler+0x142/0x6b0 fs/exec.c:1626 exec_binprm fs/exec.c:1668 [inline] do_execveat_common.isra.33+0x17f0/0x2390 fs/exec.c:1790 do_execve+0x31/0x40 fs/exec.c:1834 call_usermodehelper_exec_async+0x457/0x8f0 kernel/kmod.c:269 ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:425 Allocated by task 3700: 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 kmem_cache_alloc_trace+0x12f/0x740 mm/slab.c:3627 kmalloc include/linux/slab.h:493 [inline] alloc_ldt_struct+0x52/0x140 arch/x86/kernel/ldt.c:46 write_ldt+0x3e9/0xac0 arch/x86/kernel/ldt.c:256 sys_modify_ldt+0x1ef/0x240 arch/x86/kernel/ldt.c:286 entry_SYSCALL_64_fastpath+0x1f/0xbe Freed by task 3703: 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] kfree+0xca/0x250 mm/slab.c:3820 free_ldt_struct.part.2+0xdd/0x150 arch/x86/kernel/ldt.c:100 free_ldt_struct arch/x86/kernel/ldt.c:152 [inline] destroy_context_ldt+0x60/0x80 arch/x86/kernel/ldt.c:150 destroy_context arch/x86/include/asm/mmu_context.h:149 [inline] __mmdrop+0xe9/0x530 kernel/fork.c:887 mmdrop include/linux/sched/mm.h:42 [inline] __mmput kernel/fork.c:914 [inline] mmput+0x541/0x6e0 kernel/fork.c:925 copy_process.part.34+0x2315/0x4bd0 kernel/fork.c:1933 copy_process kernel/fork.c:1545 [inline] _do_fork+0x1ef/0xfb0 kernel/fork.c:2026 SYSC_clone kernel/fork.c:2136 [inline] SyS_clone+0x37/0x50 kernel/fork.c:2130 do_syscall_64+0x26c/0x800 arch/x86/entry/common.c:284 return_from_SYSCALL_64+0x0/0x7a The buggy address belongs to the object at ffff8801cae7ca00 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 8 bytes inside of 32-byte region [ffff8801cae7ca00, ffff8801cae7ca20) The buggy address belongs to the page: page:ffffea00072b9f00 count:1 mapcount:0 mapping:ffff8801cae7c000 index:0xffff8801cae7cfc1 flags: 0x200000000000100(slab) raw: 0200000000000100 ffff8801cae7c000 ffff8801cae7cfc1 000000010000003f raw: ffffea00072b3b20 ffffea00072ae0a0 ffff8801dac001c0 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8801cae7c900: 00 fc fc fc fc fc fc fc 00 00 00 fc fc fc fc fc ffff8801cae7c980: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc >ffff8801cae7ca00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ^ ffff8801cae7ca80: 00 01 fc fc fc fc fc fc 00 00 00 fc fc fc fc fc ffff8801cae7cb00: 00 00 00 fc fc fc fc fc fb fb fb fb fc fc fc fc ==================================================================