0018-KVM-x86-Add-memory-barrier-on-vmcs-field-lookup.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Andrew Honig <[email protected]>
  3. Date: Wed, 10 Jan 2018 10:12:03 -0800
  4. Subject: [PATCH] KVM: x86: Add memory barrier on vmcs field lookup
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. commit 75f139aaf896d6fdeec2e468ddfa4b2fe469bf40 upstream.
  9. This adds a memory barrier when performing a lookup into
  10. the vmcs_field_to_offset_table. This is related to
  11. CVE-2017-5753.
  12. Signed-off-by: Andrew Honig <[email protected]>
  13. Reviewed-by: Jim Mattson <[email protected]>
  14. Signed-off-by: Paolo Bonzini <[email protected]>
  15. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  16. Signed-off-by: Fabian Grünbichler <[email protected]>
  17. ---
  18. arch/x86/kvm/vmx.c | 12 ++++++++++--
  19. 1 file changed, 10 insertions(+), 2 deletions(-)
  20. diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
  21. index 146caacd8fdd..80732f87cac0 100644
  22. --- a/arch/x86/kvm/vmx.c
  23. +++ b/arch/x86/kvm/vmx.c
  24. @@ -883,8 +883,16 @@ static inline short vmcs_field_to_offset(unsigned long field)
  25. {
  26. BUILD_BUG_ON(ARRAY_SIZE(vmcs_field_to_offset_table) > SHRT_MAX);
  27. - if (field >= ARRAY_SIZE(vmcs_field_to_offset_table) ||
  28. - vmcs_field_to_offset_table[field] == 0)
  29. + if (field >= ARRAY_SIZE(vmcs_field_to_offset_table))
  30. + return -ENOENT;
  31. +
  32. + /*
  33. + * FIXME: Mitigation for CVE-2017-5753. To be replaced with a
  34. + * generic mechanism.
  35. + */
  36. + asm("lfence");
  37. +
  38. + if (vmcs_field_to_offset_table[field] == 0)
  39. return -ENOENT;
  40. return vmcs_field_to_offset_table[field];
  41. --
  42. 2.14.2