BUG: KASAN: use-after-free in free_ldt_struct.part.2+0x10a/0x150 arch/x86/kernel/ldt.c:116 Read of size 4 at addr ffff88006ce6ad48 by task init/1 CPU: 2 PID: 1 Comm: init Not tainted 4.13.0-rc5-next-20170817+ #5 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 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:116 free_ldt_struct arch/x86/kernel/ldt.c:173 [inline] destroy_context_ldt+0x60/0x80 arch/x86/kernel/ldt.c:171 destroy_context arch/x86/include/asm/mmu_context.h:157 [inline] __mmdrop+0xe9/0x530 kernel/fork.c:890 mmdrop include/linux/sched/mm.h:42 [inline] finish_task_switch+0x456/0x740 kernel/sched/core.c:2658 context_switch kernel/sched/core.c:2789 [inline] __schedule+0x8f0/0x2070 kernel/sched/core.c:3362 schedule+0x108/0x440 kernel/sched/core.c:3421 schedule_hrtimeout_range_clock+0x23e/0x810 kernel/time/hrtimer.c:1708 schedule_hrtimeout_range+0x2a/0x40 kernel/time/hrtimer.c:1753 poll_schedule_timeout+0x10f/0x1f0 fs/select.c:242 do_select+0x11ea/0x1710 fs/select.c:579 core_sys_select+0x480/0x960 fs/select.c:653 SYSC_select fs/select.c:694 [inline] SyS_select+0x194/0x230 fs/select.c:676 entry_SYSCALL_64_fastpath+0x1f/0xbe RIP: 0033:0x7fea0b20ddd3 RSP: 002b:00007ffcd7ebb0f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000017 RAX: ffffffffffffffda RBX: 00007ffcd7ebb2a0 RCX: 00007fea0b20ddd3 RDX: 0000000000000000 RSI: 00007ffcd7ebb450 RDI: 000000000000000b RBP: 00007ffcd7ebb450 R08: 00007ffcd7ebb4d0 R09: 0000000000000001 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 00007ffcd7ebb830 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 5485: 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+0x136/0x750 mm/slab.c:3627 kmalloc include/linux/slab.h:493 [inline] alloc_ldt_struct+0x52/0x140 arch/x86/kernel/ldt.c:67 write_ldt+0x3ea/0xab0 arch/x86/kernel/ldt.c:277 sys_modify_ldt+0x1ef/0x240 arch/x86/kernel/ldt.c:307 entry_SYSCALL_64_fastpath+0x1f/0xbe Freed by task 5522: 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:121 free_ldt_struct arch/x86/kernel/ldt.c:173 [inline] destroy_context_ldt+0x60/0x80 arch/x86/kernel/ldt.c:171 destroy_context arch/x86/include/asm/mmu_context.h:157 [inline] __mmdrop+0xe9/0x530 kernel/fork.c:890 mmdrop include/linux/sched/mm.h:42 [inline] __mmput kernel/fork.c:917 [inline] mmput+0x541/0x6e0 kernel/fork.c:928 copy_process.part.36+0x22e1/0x4af0 kernel/fork.c:1932 copy_process kernel/fork.c:1547 [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/0x8c0 arch/x86/entry/common.c:287 return_from_SYSCALL_64+0x0/0x7a The buggy address belongs to the object at ffff88006ce6ad40 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 8 bytes inside of 32-byte region [ffff88006ce6ad40, ffff88006ce6ad60) The buggy address belongs to the page: page:ffffea0001b39a80 count:1 mapcount:0 mapping:ffff88006ce6a000 index:0xffff88006ce6afc1 flags: 0x500000000000100(slab) raw: 0500000000000100 ffff88006ce6a000 ffff88006ce6afc1 000000010000003d raw: ffffea0001b39ee0 ffffea0001af9da0 ffff88003e8001c0 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88006ce6ac00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff88006ce6ac80: fb fb fb fb fc fc fc fc 00 00 06 fc fc fc fc fc >ffff88006ce6ad00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ^ ffff88006ce6ad80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff88006ce6ae00: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ================================================================== ==================================================================