linux/arch/x86/kvm
Sean Christopherson 5ef1d8c1dd KVM: SVM: Flush pages under kvm->lock to fix UAF in svm_register_enc_region()
Do the cache flush of converted pages in svm_register_enc_region() before
dropping kvm->lock to fix use-after-free issues where region and/or its
array of pages could be freed by a different task, e.g. if userspace has
__unregister_enc_region_locked() already queued up for the region.

Note, the "obvious" alternative of using local variables doesn't fully
resolve the bug, as region->pages is also dynamically allocated.  I.e. the
region structure itself would be fine, but region->pages could be freed.

Flushing multiple pages under kvm->lock is unfortunate, but the entire
flow is a rare slow path, and the manual flush is only needed on CPUs that
lack coherency for encrypted memory.

Fixes: 19a23da539 ("Fix unsynchronized access to sev members through svm_register_enc_region")
Reported-by: Gabe Kirkpatrick <gkirkpatrick@google.com>
Cc: Josh Eads <josheads@google.com>
Cc: Peter Gonda <pgonda@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20240217013430.2079561-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-02-23 03:55:59 -05:00
..
mmu Generic: 2024-01-17 13:03:37 -08:00
svm KVM: SVM: Flush pages under kvm->lock to fix UAF in svm_register_enc_region() 2024-02-23 03:55:59 -05:00
vmx KVM x86 fixes for 6.8: 2024-02-14 12:34:43 -05:00
.gitignore KVM: x86: use a separate asm-offsets.c file 2022-11-09 12:10:17 -05:00
cpuid.c Generic: 2024-01-17 13:03:37 -08:00
cpuid.h KVM: x86: Use KVM-governed feature framework to track "LAM enabled" 2023-11-28 17:54:09 -08:00
debugfs.c LoongArch KVM changes for v6.8 2024-01-02 13:16:29 -05:00
emulate.c KVM: x86: Introduce get_untagged_addr() in kvm_x86_ops and call it in emulator 2023-11-28 17:54:06 -08:00
fpu.h KVM: x86: Move FPU register accessors into fpu.h 2021-06-17 13:09:24 -04:00
governed_features.h KVM: x86: Use KVM-governed feature framework to track "LAM enabled" 2023-11-28 17:54:09 -08:00
hyperv.c KVM: x86: Give a hint when Win2016 might fail to boot due to XSAVES erratum 2024-01-31 16:21:00 -05:00
hyperv.h KVM: x86: Give a hint when Win2016 might fail to boot due to XSAVES erratum 2024-01-31 16:21:00 -05:00
i8254.c KVM: x86: Unify pr_fmt to use module name for all KVM modules 2022-12-29 15:47:35 -05:00
i8254.h KVM: x86: PIT: Preserve state of speaker port data bit 2022-06-08 13:06:20 -04:00
i8259.c KVM: x86: Fix poll command 2023-06-01 13:44:13 -07:00
ioapic.c KVM: x86/ioapic: Resample the pending state of an IRQ when unmasking 2023-03-27 10:13:28 -04:00
ioapic.h x86/kvm: remove unused ack_notifier callbacks 2021-11-18 07:05:57 -05:00
irq_comm.c KVM: x86: Make Hyper-V emulation optional 2023-12-07 09:34:57 -08:00
irq.c KVM: x86/xen: Remove unneeded xen context from kvm_arch when !CONFIG_KVM_XEN 2023-12-07 09:33:42 -08:00
irq.h x86/kvm: remove unused ack_notifier callbacks 2021-11-18 07:05:57 -05:00
Kconfig KVM x86 misc changes for 6.8: 2024-01-08 08:10:04 -05:00
kvm_cache_regs.h KVM: x86: Add helpers to query individual CR0/CR4 bits 2023-03-22 10:10:53 -07:00
kvm_emulate.h KVM: x86: Introduce get_untagged_addr() in kvm_x86_ops and call it in emulator 2023-11-28 17:54:06 -08:00
kvm_onhyperv.c KVM: x86/mmu: Move filling of Hyper-V's TLB range struct into Hyper-V code 2023-04-10 15:17:29 -07:00
kvm_onhyperv.h KVM: x86: Move Hyper-V partition assist page out of Hyper-V emulation context 2023-12-07 09:34:01 -08:00
kvm-asm-offsets.c KVM: SVM: move MSR_IA32_SPEC_CTRL save/restore to assembly 2022-11-09 12:25:53 -05:00
lapic.c KVM: x86: Introduce helper to check if vector is set in Hyper-V SynIC 2023-12-07 09:34:14 -08:00
lapic.h KVM: x86: Split out logic to generate "readable" APIC regs mask to helper 2023-01-24 10:04:35 -08:00
Makefile KVM: x86: Make Hyper-V emulation optional 2023-12-07 09:34:57 -08:00
mmu.h KVM: x86: Use KVM-governed feature framework to track "LAM enabled" 2023-11-28 17:54:09 -08:00
mtrr.c KVM: x86/mmu: Zap SPTEs on MTRR update iff guest MTRRs are honored 2023-10-09 14:35:14 -07:00
pmu.c KVM: x86/pmu: Track emulated counter events instead of previous counter 2023-11-30 12:52:55 -08:00
pmu.h KVM: x86/pmu: Track emulated counter events instead of previous counter 2023-11-30 12:52:55 -08:00
reverse_cpuid.h KVM: x86: Use a switch statement and macros in __feature_translate() 2023-11-30 12:27:02 -08:00
smm.c KVM: x86: Remove redundant vcpu->arch.cr0 assignments 2023-09-27 12:57:48 -07:00
smm.h KVM: x86: smm: preserve interrupt shadow in SMRAM 2022-11-09 12:31:26 -05:00
trace.h KVM: x86/xen: Add CPL to Xen hypercall tracepoint 2022-11-28 13:31:01 -05:00
tss.h
x86.c KVM selftests fixes/cleanups (and one KVM x86 cleanup) for 6.8: 2024-02-14 12:34:58 -05:00
x86.h KVM: x86: Virtualize LAM for supervisor pointer 2023-11-28 17:54:07 -08:00
xen.c Generic: 2024-01-17 13:03:37 -08:00
xen.h KVM: x86/xen: update Xen CPUID Leaf 4 (tsc info) sub-leaves, if present 2023-01-24 10:05:20 -08:00