1 From 00b5f37189d24ac3ed46cb7f11742094778c46ce Mon Sep 17 00:00:00 2001
2 From: Vitaly Kuznetsov <vkuznets@redhat.com>
3 Date: Fri, 25 Mar 2022 14:21:39 +0100
4 Subject: KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast()
6 From: Vitaly Kuznetsov <vkuznets@redhat.com>
8 commit 00b5f37189d24ac3ed46cb7f11742094778c46ce upstream.
10 When kvm_irq_delivery_to_apic_fast() is called with APIC_DEST_SELF
11 shorthand, 'src' must not be NULL. Crash the VM with KVM_BUG_ON()
12 instead of crashing the host.
14 Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
15 Message-Id: <20220325132140.25650-3-vkuznets@redhat.com>
16 Cc: stable@vger.kernel.org
17 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 arch/x86/kvm/lapic.c | 4 ++++
21 1 file changed, 4 insertions(+)
23 --- a/arch/x86/kvm/lapic.c
24 +++ b/arch/x86/kvm/lapic.c
25 @@ -987,6 +987,10 @@ bool kvm_irq_delivery_to_apic_fast(struc
28 if (irq->shorthand == APIC_DEST_SELF) {
29 + if (KVM_BUG_ON(!src, kvm)) {
33 *r = kvm_apic_set_irq(src->vcpu, irq, dest_map);