]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast()
authorVitaly Kuznetsov <vkuznets@redhat.com>
Fri, 25 Mar 2022 13:21:39 +0000 (14:21 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 29 Mar 2022 17:22:01 +0000 (13:22 -0400)
When kvm_irq_delivery_to_apic_fast() is called with APIC_DEST_SELF
shorthand, 'src' must not be NULL. Crash the VM with KVM_BUG_ON()
instead of crashing the host.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20220325132140.25650-3-vkuznets@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/lapic.c

index 80a2020c4db401e94d1e189f0b6c505fee06caf7..66b0eb0bda94e9149de3ae788e340923807bb0f9 100644 (file)
@@ -1024,6 +1024,10 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
        *r = -1;
 
        if (irq->shorthand == APIC_DEST_SELF) {
+               if (KVM_BUG_ON(!src, kvm)) {
+                       *r = 0;
+                       return true;
+               }
                *r = kvm_apic_set_irq(src->vcpu, irq, dest_map);
                return true;
        }