0008-x86-kvm-Be-careful-not-to-clear-KVM_VCPU_FLUSH_TLB-b.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Boris Ostrovsky <[email protected]>
  3. Date: Fri, 31 Jan 2020 08:06:40 -0300
  4. Subject: [PATCH] x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit
  5. CVE-2019-3016
  6. CVE-2020-3016
  7. kvm_steal_time_set_preempted() may accidentally clear KVM_VCPU_FLUSH_TLB
  8. bit if it is called more than once while VCPU is preempted.
  9. This is part of CVE-2019-3016.
  10. (This bug was also independently discovered by Jim Mattson
  11. <[email protected]>)
  12. Signed-off-by: Boris Ostrovsky <[email protected]>
  13. Reviewed-by: Joao Martins <[email protected]>
  14. Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]>
  15. Signed-off-by: Thomas Lamprecht <[email protected]>
  16. ---
  17. arch/x86/kvm/x86.c | 3 +++
  18. 1 file changed, 3 insertions(+)
  19. diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
  20. index 778b3a899769..92d8e4ebba16 100644
  21. --- a/arch/x86/kvm/x86.c
  22. +++ b/arch/x86/kvm/x86.c
  23. @@ -3393,6 +3393,9 @@ static void kvm_steal_time_set_preempted(struct kvm_vcpu *vcpu)
  24. if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED))
  25. return;
  26. + if (vcpu->arch.st.steal.preempted)
  27. + return;
  28. +
  29. vcpu->arch.st.steal.preempted = KVM_VCPU_PREEMPTED;
  30. kvm_write_guest_offset_cached(vcpu->kvm, &vcpu->arch.st.stime,