From: Sasha Levin Date: Thu, 30 Jul 2020 23:33:48 +0000 (-0400) Subject: x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit X-Git-Tag: v4.14.192~40 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=fd4a641bb5731c0ce5397698560a823602dbaac2;p=users%2Fdwmw2%2Flinux.git x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit [ Upstream commit 8c6de56a42e0c657955e12b882a81ef07d1d073e ] kvm_steal_time_set_preempted() may accidentally clear KVM_VCPU_FLUSH_TLB bit if it is called more than once while VCPU is preempted. This is part of CVE-2019-3016. (This bug was also independently discovered by Jim Mattson ) Signed-off-by: Boris Ostrovsky Reviewed-by: Joao Martins Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 09f47c837c258..3aed03942d7d4 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3075,6 +3075,9 @@ static void kvm_steal_time_set_preempted(struct kvm_vcpu *vcpu) if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED)) return; + if (vcpu->arch.st.steal.preempted) + return; + vcpu->arch.st.steal.preempted = 1; kvm_write_guest_offset_cached(vcpu->kvm, &vcpu->arch.st.stime,