cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
28f2e1
From 529a5d908f5d16714b8ae0a51eaaaa84994dfae8 Mon Sep 17 00:00:00 2001
28f2e1
From: "Michael S. Tsirkin" <mst@redhat.com>
28f2e1
Date: Tue, 21 Dec 2021 09:45:44 -0500
28f2e1
Subject: [PATCH 1/2] acpi: validate hotplug selector on access
28f2e1
MIME-Version: 1.0
28f2e1
Content-Type: text/plain; charset=UTF-8
28f2e1
Content-Transfer-Encoding: 8bit
28f2e1
28f2e1
RH-Author: Jon Maloy <jmaloy@redhat.com>
28f2e1
RH-MergeRequest: 97: acpi: validate hotplug selector on access
28f2e1
RH-Commit: [1/1] 79bcfb0df0091e2b716d2e1c545f047b3409c26c (jmaloy/qemu-kvm)
28f2e1
RH-Bugzilla: 2036580
28f2e1
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
28f2e1
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
28f2e1
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
28f2e1
28f2e1
When bus is looked up on a pci write, we didn't
28f2e1
validate that the lookup succeeded.
28f2e1
Fuzzers thus can trigger QEMU crash by dereferencing the NULL
28f2e1
bus pointer.
28f2e1
28f2e1
Fixes: b32bd763a1 ("pci: introduce acpi-index property for PCI device")
28f2e1
Fixes: CVE-2021-4158
28f2e1
Cc: "Igor Mammedov" <imammedo@redhat.com>
28f2e1
Fixes: https://gitlab.com/qemu-project/qemu/-/issues/770
28f2e1
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
28f2e1
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
28f2e1
Reviewed-by: Ani Sinha <ani@anisinha.ca>
28f2e1
(cherry picked from commit 9bd6565ccee68f72d5012e24646e12a1c662827e)
28f2e1
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
28f2e1
---
28f2e1
 hw/acpi/pcihp.c | 3 +++
28f2e1
 1 file changed, 3 insertions(+)
28f2e1
28f2e1
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
28f2e1
index 30405b5113..a5e182dd3a 100644
28f2e1
--- a/hw/acpi/pcihp.c
28f2e1
+++ b/hw/acpi/pcihp.c
28f2e1
@@ -491,6 +491,9 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data,
28f2e1
         }
28f2e1
 
28f2e1
         bus = acpi_pcihp_find_hotplug_bus(s, s->hotplug_select);
28f2e1
+        if (!bus) {
28f2e1
+            break;
28f2e1
+        }
28f2e1
         QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) {
28f2e1
             Object *o = OBJECT(kid->child);
28f2e1
             PCIDevice *dev = PCI_DEVICE(o);
28f2e1
-- 
28f2e1
2.27.0
28f2e1