* [PATCH v2] KVM: apic: avoid calculating pending eoi from an uninitialized val
@ 2020-02-21 14:04 linmiaohe
2020-02-21 16:14 ` Vitaly Kuznetsov
0 siblings, 1 reply; 3+ messages in thread
From: linmiaohe @ 2020-02-21 14:04 UTC (permalink / raw)
To: pbonzini, rkrcmar, sean.j.christopherson, vkuznets, wanpengli,
jmattson, joro, tglx, mingo, bp, hpa
Cc: linmiaohe, kvm, linux-kernel, x86
From: Miaohe Lin <linmiaohe@huawei.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.
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Miaohe Lin <linmiaohe@huawei.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;
}
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] KVM: apic: avoid calculating pending eoi from an uninitialized val
2020-02-21 14:04 [PATCH v2] KVM: apic: avoid calculating pending eoi from an uninitialized val linmiaohe
@ 2020-02-21 16:14 ` Vitaly Kuznetsov
0 siblings, 0 replies; 3+ messages in thread
From: Vitaly Kuznetsov @ 2020-02-21 16:14 UTC (permalink / raw)
To: linmiaohe
Cc: kvm, linux-kernel, x86, pbonzini, rkrcmar, sean.j.christopherson,
wanpengli, jmattson, joro, tglx, mingo, bp, hpa
linmiaohe <linmiaohe@huawei.com> writes:
> From: Miaohe Lin <linmiaohe@huawei.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@redhat.com>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] KVM: apic: avoid calculating pending eoi from an uninitialized val
@ 2020-02-24 1:53 linmiaohe
0 siblings, 0 replies; 3+ messages in thread
From: linmiaohe @ 2020-02-24 1:53 UTC (permalink / raw)
To: Vitaly Kuznetsov
Cc: kvm, linux-kernel, x86, pbonzini, rkrcmar, sean.j.christopherson,
wanpengli, jmattson, joro, tglx, mingo, bp, hpa
Vitaly Kuznetsov <vkuznets@redhat.com> writes:
>linmiaohe <linmiaohe@huawei.com> writes:
>
>> From: Miaohe Lin <linmiaohe@huawei.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.
My bad, sorry about it, I should be more careful about it. I will drop the last sentence in v3. Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-24 1:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 14:04 [PATCH v2] KVM: apic: avoid calculating pending eoi from an uninitialized val linmiaohe
2020-02-21 16:14 ` Vitaly Kuznetsov
2020-02-24 1:53 linmiaohe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).