thebeanogamer / rpms / qemu-kvm

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