| From 0db60846751e1516449a9a322471b280b989fe34 Mon Sep 17 00:00:00 2001 |
| From: Miaohe Lin <linmiaohe@huawei.com> |
| Date: Fri, 21 Feb 2020 22:04:46 +0800 |
| Subject: [PATCH] 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 <vkuznets@redhat.com> |
| Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> |
| Cc: stable@vger.kernel.org |
| Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c |
| index 9e99c019b959..d2c1cb127791 100644 |
| --- a/arch/x86/kvm/lapic.c |
| +++ b/arch/x86/kvm/lapic.c |
| @@ -632,9 +632,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) { |
| apic_debug("Can't read EOI MSR value: 0x%llx\n", |
| (unsigned long long)vcpu->arch.pv_eoi.msr_val); |
| + return false; |
| + } |
| return val & 0x1; |
| } |
| |
| -- |
| 2.7.4 |
| |