aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorAndrew Honig <ahonig@google.com>2018-01-10 10:12:03 -0800
committerPaolo Bonzini <pbonzini@redhat.com>2018-01-11 18:20:31 +0100
commit75f139aaf896d6fdeec2e468ddfa4b2fe469bf40 (patch)
treee95c8451e33be341ccfaa853dd7a2927857882ef /arch/x86/kvm/vmx.c
parentLinux 4.14 (diff)
downloadlinux-dev-75f139aaf896d6fdeec2e468ddfa4b2fe469bf40.tar.xz
linux-dev-75f139aaf896d6fdeec2e468ddfa4b2fe469bf40.zip
KVM: x86: Add memory barrier on vmcs field lookup
This adds a memory barrier when performing a lookup into the vmcs_field_to_offset_table. This is related to CVE-2017-5753. Signed-off-by: Andrew Honig <ahonig@google.com> Reviewed-by: Jim Mattson <jmattson@google.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to '')
-rw-r--r--arch/x86/kvm/vmx.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a6f4f095f8f4..7f8fcc5ce664 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -884,8 +884,16 @@ static inline short vmcs_field_to_offset(unsigned long field)
{
BUILD_BUG_ON(ARRAY_SIZE(vmcs_field_to_offset_table) > SHRT_MAX);
- if (field >= ARRAY_SIZE(vmcs_field_to_offset_table) ||
- vmcs_field_to_offset_table[field] == 0)
+ if (field >= ARRAY_SIZE(vmcs_field_to_offset_table))
+ return -ENOENT;
+
+ /*
+ * FIXME: Mitigation for CVE-2017-5753. To be replaced with a
+ * generic mechanism.
+ */
+ asm("lfence");
+
+ if (vmcs_field_to_offset_table[field] == 0)
return -ENOENT;
return vmcs_field_to_offset_table[field];