From: Miaohe Lin Date: Fri, 21 Feb 2020 14:04:46 +0000 (+0800) Subject: KVM: apic: avoid calculating pending eoi from an uninitialized val X-Git-Tag: v5.5.7~50 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7cad6ccee697b8f425ecd2c9222784c7c16561ca;p=users%2Fdwmw2%2Flinux.git KVM: apic: avoid calculating pending eoi from an uninitialized val commit 23520b2def95205f132e167cf5b25c609975e959 upstream. When pv_eoi_get_user() fails, 'val' may remain uninitialized and the return value of pv_eoi_get_pending() becomes random. Fix the issue by initializing the variable. Reviewed-by: Vitaly Kuznetsov Signed-off-by: Miaohe Lin Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index cfa1120bb6913..f05123acaa64c 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -630,9 +630,11 @@ static inline bool pv_eoi_enabled(struct kvm_vcpu *vcpu) static bool pv_eoi_get_pending(struct kvm_vcpu *vcpu) { u8 val; - if (pv_eoi_get_user(vcpu, &val) < 0) + if (pv_eoi_get_user(vcpu, &val) < 0) { printk(KERN_WARNING "Can't read EOI MSR value: 0x%llx\n", (unsigned long long)vcpu->arch.pv_eoi.msr_val); + return false; + } return val & 0x1; }