]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commit
KVM: nVMX: Fix memory corruption when using VMCS shadowing
authorJim Mattson <jmattson@google.com>
Fri, 8 Jul 2016 22:36:06 +0000 (15:36 -0700)
committerIshan Mittal <imittal@nvidia.com>
Fri, 6 Jan 2017 10:08:11 +0000 (15:38 +0530)
commit02279b9931894eb86ab60a767312f3abd037b5e2
treebbaec4aa2b05eb3e4410d43c8e1da61845b73cfb
parent718a1d4194418bbf45b710e53e1bdc9ab13029eb
KVM: nVMX: Fix memory corruption when using VMCS shadowing

commit 2f1fe81123f59271bddda673b60116bde9660385 upstream.

When freeing the nested resources of a vcpu, there is an assumption that
the vcpu's vmcs01 is the current VMCS on the CPU that executes
nested_release_vmcs12(). If this assumption is violated, the vcpu's
vmcs01 may be made active on multiple CPUs at the same time, in
violation of Intel's specification. Moreover, since the vcpu's vmcs01 is
not VMCLEARed on every CPU on which it is active, it can linger in a
CPU's VMCS cache after it has been freed and potentially
repurposed. Subsequent eviction from the CPU's VMCS cache on a capacity
miss can result in memory corruption.

It is not sufficient for vmx_free_vcpu() to call vmx_load_vmcs01(). If
the vcpu in question was last loaded on a different CPU, it must be
migrated to the current CPU before calling vmx_load_vmcs01().

Signed-off-by: Jim Mattson <jmattson@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/vmx.c
virt/kvm/kvm_main.c