KVM: apic: avoid calculating pending eoi from an uninitialized val
PATCH v2 1/1 KVM: apic: avoid calculating pending eoi from an uninitialized val
From: Miaohe Lin <[email protected]>
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.
---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(-)
arch/x86/kvm/lapic.c +3 -1
@@ -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 ; }
Signature · 1 line
2.19.1
Quoted 5 lines · linmiaohe
From: Miaohe Lin <[email protected]>
When
pv_eoi_get_user()fails, 'val' may remain uninitialized and the return value ofpv_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.
Quoted 28 lines
Reviewed-by Vitaly Kuznetsov <[email protected]>Signed-off-by Miaohe Lin <[email protected]>---
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(-)arch/x86/kvm/lapic.c +3
-1@@ -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 ; }
Signature · 1 line
Vitaly