1 From foo@baz Mon Aug 15 02:53:54 PM CEST 2022
2 From: Stefan Ghinea <stefan.ghinea@windriver.com>
3 Date: Wed, 10 Aug 2022 23:26:24 +0300
4 Subject: KVM: x86: Avoid theoretical NULL pointer dereference in kvm_irq_delivery_to_apic_fast()
5 To: stable@vger.kernel.org
6 Cc: Vitaly Kuznetsov <vkuznets@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Stefan Ghinea <stefan.ghinea@windriver.com>
7 Message-ID: <20220810202625.32529-3-stefan.ghinea@windriver.com>
9 From: Vitaly Kuznetsov <vkuznets@redhat.com>
11 commit 00b5f37189d24ac3ed46cb7f11742094778c46ce upstream
13 When kvm_irq_delivery_to_apic_fast() is called with APIC_DEST_SELF
14 shorthand, 'src' must not be NULL. Crash the VM with KVM_BUG_ON()
15 instead of crashing the host.
17 Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
18 Message-Id: <20220325132140.25650-3-vkuznets@redhat.com>
19 Cc: stable@vger.kernel.org
20 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
21 Signed-off-by: Stefan Ghinea <stefan.ghinea@windriver.com>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 arch/x86/kvm/lapic.c | 4 ++++
25 1 file changed, 4 insertions(+)
27 --- a/arch/x86/kvm/lapic.c
28 +++ b/arch/x86/kvm/lapic.c
29 @@ -961,6 +961,10 @@ bool kvm_irq_delivery_to_apic_fast(struc
32 if (irq->shorthand == APIC_DEST_SELF) {
33 + if (KVM_BUG_ON(!src, kvm)) {
37 *r = kvm_apic_set_irq(src->vcpu, irq, dest_map);