diff options
author | Andrew Honig <ahonig@google.com> | 2018-01-10 21:12:03 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-03-03 18:50:58 +0300 |
commit | 39a34000fbdf7b64db95112686658662fd723841 (patch) | |
tree | 988792b455117f0ef8b18cc1be00635634a95ee7 /arch/x86/kvm | |
parent | ccaa16ab073a8e0b94ce1d32d9da1199adf712df (diff) | |
download | linux-39a34000fbdf7b64db95112686658662fd723841.tar.xz |
KVM: x86: Add memory barrier on vmcs field lookup
commit 75f139aaf896d6fdeec2e468ddfa4b2fe469bf40 upstream.
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>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/vmx.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 346fac6eab9f..690120f552db 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -573,8 +573,18 @@ static const int max_vmcs_field = ARRAY_SIZE(vmcs_field_to_offset_table); static inline short vmcs_field_to_offset(unsigned long field) { - if (field >= max_vmcs_field || vmcs_field_to_offset_table[field] == 0) + if (field >= max_vmcs_field) return -1; + + /* + * FIXME: Mitigation for CVE-2017-5753. To be replaced with a + * generic mechanism. + */ + asm("lfence"); + + if (vmcs_field_to_offset_table[field] == 0) + return -1; + return vmcs_field_to_offset_table[field]; } |