KVM: x86: Fix potential divide by 0 in lapic (CVE-2013-6367)
[pandora-kernel.git] / arch / x86 / kvm / lapic.c
index 54abb40..43e7753 100644 (file)
@@ -537,7 +537,8 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
        ASSERT(apic != NULL);
 
        /* if initial count is 0, current count should also be 0 */
-       if (apic_get_reg(apic, APIC_TMICT) == 0)
+       if (apic_get_reg(apic, APIC_TMICT) == 0 ||
+               apic->lapic_timer.period == 0)
                return 0;
 
        remaining = hrtimer_get_remaining(&apic->lapic_timer.timer);