From: Michael S. Tsirkin Date: Tue, 21 Dec 2021 14:45:44 +0000 (-0500) Subject: acpi: validate hotplug selector on access X-Git-Tag: v7.0.0-rc0~102^2~53 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9bd6565ccee68f72d5012e24646e12a1c662827e;p=thirdparty%2Fqemu.git acpi: validate hotplug selector on access When bus is looked up on a pci write, we didn't validate that the lookup succeeded. Fuzzers thus can trigger QEMU crash by dereferencing the NULL bus pointer. Fixes: b32bd763a1 ("pci: introduce acpi-index property for PCI device") Fixes: CVE-2021-4158 Cc: "Igor Mammedov" Fixes: https://gitlab.com/qemu-project/qemu/-/issues/770 Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Ani Sinha --- diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 30405b5113d..a5e182dd3a3 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -491,6 +491,9 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t data, } bus = acpi_pcihp_find_hotplug_bus(s, s->hotplug_select); + if (!bus) { + break; + } QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { Object *o = OBJECT(kid->child); PCIDevice *dev = PCI_DEVICE(o);