Skip to content

Commit 00b5f37

Browse files
vittyvkbonzini
authored andcommitted
KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast()
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>
1 parent 7ec37d1 commit 00b5f37

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

arch/x86/kvm/lapic.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,10 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
10241024
*r = -1;
10251025

10261026
if (irq->shorthand == APIC_DEST_SELF) {
1027+
if (KVM_BUG_ON(!src, kvm)) {
1028+
*r = 0;
1029+
return true;
1030+
}
10271031
*r = kvm_apic_set_irq(src->vcpu, irq, dest_map);
10281032
return true;
10291033
}

0 commit comments

Comments
 (0)