]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
ee236964b9869e480b7b7c7007bcc8594e99272b
[thirdparty/kernel/stable-queue.git] /
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()
5
6 From: Vitaly Kuznetsov <vkuznets@redhat.com>
7
8 commit 00b5f37189d24ac3ed46cb7f11742094778c46ce upstream.
9
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.
13
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>
19 ---
20 arch/x86/kvm/lapic.c | 4 ++++
21 1 file changed, 4 insertions(+)
22
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
26 *r = -1;
27
28 if (irq->shorthand == APIC_DEST_SELF) {
29 + if (KVM_BUG_ON(!src, kvm)) {
30 + *r = 0;
31 + return true;
32 + }
33 *r = kvm_apic_set_irq(src->vcpu, irq, dest_map);
34 return true;
35 }