WSL2-Linux-Kernel/arch/x86/kernel
Kirill A. Shutemov a17989cb9b x86/ldt: Unmap PTEs for the slot before freeing LDT pages
commit a0e6e0831c upstream

modify_ldt(2) leaves the old LDT mapped after switching over to the new
one. The old LDT gets freed and the pages can be re-used.

Leaving the mapping in place can have security implications. The mapping is
present in the userspace page tables and Meltdown-like attacks can read
these freed and possibly reused pages.

It's relatively simple to fix: unmap the old LDT and flush TLB before
freeing the old LDT memory.

This further allows to avoid flushing the TLB in map_ldt_struct() as the
slot is unmapped and flushed by unmap_ldt_struct() or has never been mapped
at all.

[ tglx: Massaged changelog and removed the needless line breaks ]

Fixes: f55f0501cb ("x86/pti: Put the LDT in its own PGD if PTI is on")
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: bp@alien8.de
Cc: hpa@zytor.com
Cc: dave.hansen@linux.intel.com
Cc: luto@kernel.org
Cc: peterz@infradead.org
Cc: boris.ostrovsky@oracle.com
Cc: jgross@suse.com
Cc: bhe@redhat.com
Cc: willy@infradead.org
Cc: linux-mm@kvack.org
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20181026122856.66224-3-kirill.shutemov@linux.intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-27 16:10:50 +01:00
..
acpi Revert "x86/apic: Ignore secondary threads if nosmt=force" 2018-08-15 18:12:53 +02:00
apic x86/smp: fix non-SMP broken build due to redefinition of apic_id_is_primary_thread 2018-08-15 18:13:01 +02:00
cpu Revert "x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation" 2018-11-23 08:19:27 +01:00
fpu x86/fpu: Remove second definition of fpu in __fpu__restore_sig() 2018-11-13 11:14:51 -08:00
kprobes x86: Don't include linux/irq.h from asm/hardirq.h 2018-08-15 18:12:58 +02:00
.gitignore
Makefile x86/paravirt: Make native_save_fl() extern inline 2018-07-22 14:28:42 +02:00
alternative.c Revert "x86/alternative: Print unadorned pointers" 2018-02-13 10:19:49 +01:00
amd_gart_64.c x86: remove arch specific dma_supported implementation 2017-06-28 06:54:46 -07:00
amd_nb.c x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-22 15:42:24 +01:00
apb_timer.c Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-25 14:30:04 -08:00
aperture_64.c x86/gart: Exclude GART aperture from vmcore 2018-04-12 12:32:20 +02:00
apm_32.c x86/apm: Don't access __preempt_count with zeroed fs 2018-07-25 11:25:07 +02:00
asm-offsets.c x86/mm: Use/Fix PCID to optimize user/kernel switches 2018-01-02 20:31:01 +01:00
asm-offsets_32.c x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-22 15:42:24 +01:00
asm-offsets_64.c x86/entry/64: Separate cpu_current_top_of_stack from TSS.sp0 2017-12-25 14:26:23 +01:00
audit_64.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bootflag.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
check.c x86/corruption-check: Fix panic in memory_corruption_check() when boot option without value is provided 2018-11-13 11:14:47 -08:00
cpuid.c Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-12 19:25:04 -08:00
crash.c kexec: move vmcoreinfo out of the kernel's .bss section 2017-07-12 16:25:59 -07:00
crash_dump_32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
crash_dump_64.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
devicetree.c x86/devicetree: Fix device IRQ settings in DT 2018-05-30 07:52:35 +02:00
doublefault.c x86/entry: Fix assumptions that the HW TSS is at the beginning of cpu_tss 2017-12-25 14:26:22 +01:00
dumpstack.c x86/entry/64: Wipe KASAN stack shadow before rewind_stack_do_exit() 2018-09-05 09:26:40 +02:00
dumpstack_32.c x86/entry: Rename SYSENTER_stack to CPU_ENTRY_AREA_entry_stack 2017-12-29 17:53:44 +01:00
dumpstack_64.c x86/entry: Rename SYSENTER_stack to CPU_ENTRY_AREA_entry_stack 2017-12-29 17:53:44 +01:00
e820.c x86/boot/e820: Add support to determine the E820 type of an address 2017-07-18 11:38:01 +02:00
early-quirks.c x86/gpu: add CFL to early quirks 2018-02-22 15:42:18 +01:00
early_printk.c x86/earlyprintk: Add a force option for pciserial device 2018-11-27 16:10:47 +01:00
ebda.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
eisa.c x86/EISA: Don't probe EISA bus for Xen PV guests 2018-09-26 08:38:08 +02:00
espfix_64.c kmemcheck: stop using GFP_NOTRACK and SLAB_NOTRACK 2018-02-22 15:42:23 +01:00
ftrace.c x86: Don't include linux/irq.h from asm/hardirq.h 2018-08-15 18:12:58 +02:00
ftrace_32.S x86/retpoline/ftrace: Convert ftrace assembler indirect jumps 2018-01-17 09:45:29 +01:00
ftrace_64.S x86/retpoline/ftrace: Convert ftrace assembler indirect jumps 2018-01-17 09:45:29 +01:00
head32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
head64.c x86/mm: Expand static page table for fixmap space 2018-10-03 17:00:54 -07:00
head_32.S x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-22 15:42:24 +01:00
head_64.S x86/mm: Expand static page table for fixmap space 2018-10-03 17:00:54 -07:00
hpet.c x86: Don't include linux/irq.h from asm/hardirq.h 2018-08-15 18:12:58 +02:00
hw_breakpoint.c x86/kernel: Audit and remove any unnecessary uses of module.h 2016-07-14 15:06:41 +02:00
i8237.c
i8253.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
i8259.c x86: Don't include linux/irq.h from asm/hardirq.h 2018-08-15 18:12:58 +02:00
idt.c x86: Don't include linux/irq.h from asm/hardirq.h 2018-08-15 18:12:58 +02:00
io_delay.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ioport.c x86/entry/64: Make cpu_entry_area.tss read-only 2017-12-25 14:26:24 +01:00
irq.c x86: Don't include linux/irq.h from asm/hardirq.h 2018-08-15 18:12:58 +02:00
irq_32.c x86: Don't include linux/irq.h from asm/hardirq.h 2018-08-15 18:12:58 +02:00
irq_64.c x86: Don't include linux/irq.h from asm/hardirq.h 2018-08-15 18:12:58 +02:00
irq_work.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
irqflags.S x86/paravirt: Make native_save_fl() extern inline 2018-07-22 14:28:42 +02:00
irqinit.c x86: Don't include linux/irq.h from asm/hardirq.h 2018-08-15 18:12:58 +02:00
itmt.c sched/x86: Remove unnecessary TBM3 check to update topology 2017-01-19 08:42:37 +01:00
jump_label.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
kdebugfs.c x86, mpparse, x86/acpi, x86/PCI, x86/dmi, SFI: Use memremap() for RAM mappings 2017-07-18 11:37:58 +02:00
kexec-bzimage64.c Fix kexec forbidding kernels signed with keys in the secondary keyring to boot 2018-09-09 19:55:54 +02:00
kgdb.c sched/x86: Add 'struct inactive_task_frame' to better document the sleeping task stack frame 2016-08-24 12:27:41 +02:00
ksysfs.c x86/sysfs: Fix off-by-one error in loop termination 2017-09-25 09:36:16 +02:00
kvm.c KVM: x86: fix backward migration with async_PF 2018-03-11 16:23:23 +01:00
kvmclock.c kvmclock: fix TSC calibration for nested guests 2018-08-24 13:09:18 +02:00
ldt.c x86/ldt: Unmap PTEs for the slot before freeing LDT pages 2018-11-27 16:10:50 +01:00
livepatch.c livepatch/x86: apply alternatives and paravirt patches after relocations 2016-08-18 23:41:55 +02:00
machine_kexec_32.c x86/kexec: Avoid double free_page() upon do_kexec_load() failure 2018-05-25 16:17:35 +02:00
machine_kexec_64.c x86/kexec: Avoid double free_page() upon do_kexec_load() failure 2018-05-25 16:17:35 +02:00
mmconf-fam10h_64.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
module.c x86: Treat R_X86_64_PLT32 as R_X86_64_PC32 2018-03-19 08:42:44 +01:00
mpparse.c x86/cpu: Rename cpu_data.x86_mask to cpu_data.x86_stepping 2018-02-22 15:42:24 +01:00
msr.c x86/msr: Remove bogus cleanup from the error path 2016-12-25 10:47:41 +01:00
nmi.c x86/nmi: Use raw lock 2017-08-16 20:40:09 +02:00
nmi_selftest.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
paravirt-spinlocks.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
paravirt.c x86/paravirt: Fix some warning messages 2018-11-04 14:52:45 +01:00
paravirt_patch_32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
paravirt_patch_64.c x86/paravirt: Dont patch flush_tlb_single 2017-12-25 14:26:24 +01:00
pci-calgary_64.c x86: remove arch specific dma_supported implementation 2017-06-28 06:54:46 -07:00
pci-dma.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pci-iommu_table.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pci-nommu.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pci-swiotlb.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pcspeaker.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
perf_regs.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
platform-quirks.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pmem.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
probe_roms.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
process.c x86/speculation: Rework speculative_store_bypass_update() 2018-05-22 18:54:06 +02:00
process_32.c x86/entry/64: Make cpu_entry_area.tss read-only 2017-12-25 14:26:24 +01:00
process_64.c x86/process: Re-export start_thread() 2018-09-05 09:26:37 +02:00
ptrace.c x86/asm: Move 'status' from thread_struct to thread_info 2018-02-07 11:12:22 -08:00
pvclock.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/nmi.h> 2017-03-02 08:42:30 +01:00
quirks.c x86/mce: Check for alternate indication of machine check recovery on Skylake 2018-07-03 11:24:46 +02:00
reboot.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
reboot_fixups_32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
relocate_kernel_32.S
relocate_kernel_64.S x86/kexec: Make kexec (mostly) work in 5-level paging mode 2018-02-22 15:42:18 +01:00
resource.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
rtc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
setup.c x86, hibernate: Fix nosave_regions setup for hibernation 2018-11-10 07:48:36 -08:00
setup_percpu.c x86/cpu_entry_area: Sync cpu_entry_area to initial_page_table 2018-03-08 22:41:07 -08:00
signal.c x86/asm: Move 'status' from thread_struct to thread_info 2018-02-07 11:12:22 -08:00
signal_compat.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
smp.c x86/irq: Let interrupt handlers set kvm_cpu_l1tf_flush_l1d 2018-08-15 18:12:58 +02:00
smpboot.c x86/mm/32: Initialize the CR4 shadow before __flush_tlb_all() 2018-08-24 13:09:11 +02:00
stacktrace.c x86/stacktrace: Make zombie stack traces reliable 2018-03-03 10:24:25 +01:00
step.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sys_x86_64.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sysfb.c
sysfb_efi.c Merge branch 'linus' into efi/core, to pick up fixes 2016-05-07 07:00:07 +02:00
sysfb_simplefb.c x86/sysfb: Fix lfb_size calculation 2016-11-16 09:38:23 +01:00
tboot.c x86/pti: Make unpoison of pgd for trusted boot work for real 2018-01-17 09:45:28 +01:00
tce_64.c x86/cpufeature: Remove cpu_has_clflush 2016-03-31 13:35:09 +02:00
time.c x86/time: Correct the attribute on jiffies' definition 2018-11-10 07:48:36 -08:00
tls.c x86/ldt: Make the LDT mapping RO 2018-01-02 20:31:02 +01:00
tls.h
topology.c
trace_clock.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tracepoint.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
traps.c x86: Call fixup_exception() before notify_die() in math_error() 2018-07-03 11:24:46 +02:00
tsc.c x86/tsc: Force inlining of cyc2ns bits 2018-11-10 07:48:36 -08:00
tsc_msr.c x86/tsc: Add missing header to tsc_msr.c 2018-10-03 17:00:48 -07:00
tsc_sync.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
unwind_frame.c x86/unwind: Disable unwinder warnings on 32-bit 2017-10-10 12:49:49 +02:00
unwind_guess.c x86/unwind: Add the ORC unwinder 2017-07-26 13:18:20 +02:00
unwind_orc.c x86/unwinder: Handle stack overflows more gracefully 2017-12-25 14:26:21 +01:00
uprobes.c uprobes/x86: Remove incorrect WARN_ON() in uprobe_init_insn() 2018-07-17 11:39:31 +02:00
verify_cpu.S x86/boot: Annotate verify_cpu() as a callable function 2017-12-25 14:26:13 +01:00
vm86_32.c x86/vm86/32: Fix POPF emulation 2018-03-21 12:06:41 +01:00
vmlinux.lds.S x86/kprobes: Fix kernel crash when probing .entry_trampoline code 2018-03-15 10:54:38 +01:00
vsmp_64.c
x86_init.c x86/virt, x86/platform: Merge 'struct x86_hyper' into 'struct x86_platform' and 'struct x86_init' 2017-12-25 14:26:20 +01:00