[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8736b3rk8j.fsf@vitty.brq.redhat.com>
Date: Fri, 21 Feb 2020 17:14:04 +0100
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: linmiaohe <linmiaohe@...wei.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org, x86@...nel.org,
pbonzini@...hat.com, rkrcmar@...hat.com,
sean.j.christopherson@...el.com, wanpengli@...cent.com,
jmattson@...gle.com, joro@...tes.org, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, hpa@...or.com
Subject: Re: [PATCH v2] KVM: apic: avoid calculating pending eoi from an uninitialized val
linmiaohe <linmiaohe@...wei.com> writes:
> From: Miaohe Lin <linmiaohe@...wei.com>
>
> 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.
Well, now the 'perfect' commit message doesn't match the patch :-). I
think you (or Paolo upon commit) can just drop the last sentence.
>
> Reviewed-by: Vitaly Kuznetsov <vkuznets@...hat.com>
> Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
> ---
> v1->v2:
> Collect Vitaly' R-b.
> Use Vitaly' alternative wording.
> Explicitly handle the error, as suggested by Sean.
> ---
> arch/x86/kvm/lapic.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 4f14ec7525f6..b4aca77efc8e 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -627,9 +627,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;
> }
--
Vitaly
Powered by blists - more mailing lists