diff --git a/libvirt.spec b/libvirt.spec index d6745df10ed8a6f3159f6fbc02bf58c405926464..8f19a97a0027e12f1acdbfd33b000f9fdd762b89 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -3,7 +3,7 @@ # This spec file assumes you are building on a Fedora or RHEL version # that's still supported by the vendor. It may work on other distros # or versions, but no effort will be made to ensure that going forward. -%define anolis_release .0.1 +%define anolis_release 20 %define min_rhel 8 %define min_fedora 33 @@ -211,7 +211,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 8.0.0 -Release: 19%{anolis_release}%{?dist}%{?extra_release} +Release: %{anolis_release}%{?dist}%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -309,6 +309,8 @@ Patch85: libvirt-qemu-domain-Fix-logic-when-tainting-domain.patch Patch86: libvirt-qemu-agent-Make-fetching-of-can-offline-member-from-guest-query-vcpus-optional.patch Patch1000: libvirt-Add-loongarch-support.patch Patch1001: libvirt-add-loongarch-edit-xml-validate.patch +Patch1002: node_device_conf-Avoid-memleak-in-virNodeDeviceGetPCIVPDDynamicCap.patch +Patch1003: virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2188,6 +2190,10 @@ exit 0 %changelog +* Thu Jun 29 2023 Liwei Ge - 8.0.0-20 +- Avoid memleak in virNodeDeviceGetPCIVPDDynamicCap (CVE-2023-2700) +- Resolve leak in virPCIVirtualFunctionList cleanup (CVE-2023-2700) + * Mon Jun 19 2023 zhaotianrui - 8.0.0-19.0.1 - Add loongarch support - Fix loongarch xml validate diff --git a/node_device_conf-Avoid-memleak-in-virNodeDeviceGetPCIVPDDynamicCap.patch b/node_device_conf-Avoid-memleak-in-virNodeDeviceGetPCIVPDDynamicCap.patch new file mode 100644 index 0000000000000000000000000000000000000000..91aed8dddb568f894248f26b2064670cd54cc065 --- /dev/null +++ b/node_device_conf-Avoid-memleak-in-virNodeDeviceGetPCIVPDDynamicCap.patch @@ -0,0 +1,46 @@ +From 64d32118540aca3d42bc5ee21c8b780cafe04bfa Mon Sep 17 00:00:00 2001 +From: Michal Privoznik +Date: Wed, 30 Nov 2022 14:53:21 +0100 +Subject: [PATCH] node_device_conf: Avoid memleak in + virNodeDeviceGetPCIVPDDynamicCap() + +The virNodeDeviceGetPCIVPDDynamicCap() function is called from +virNodeDeviceGetPCIDynamicCaps() and therefore has to be a wee +bit more clever about adding VPD capability. Namely, it has to +remove the old one before adding a new one. This is how other +functions called from virNodeDeviceGetPCIDynamicCaps() behave +as well. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2143235 +Signed-off-by: Michal Privoznik +Reviewed-by: Peter Krempa +--- + src/conf/node_device_conf.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index 83e66b85e3..af331baaf3 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -3068,6 +3068,9 @@ virNodeDeviceGetPCIVPDDynamicCap(virNodeDevCapPCIDev *devCapPCIDev) + virPCIDeviceAddress devAddr; + g_autoptr(virPCIVPDResource) res = NULL; + ++ g_clear_pointer(&devCapPCIDev->vpd, virPCIVPDResourceFree); ++ devCapPCIDev->flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VPD; ++ + devAddr.domain = devCapPCIDev->domain; + devAddr.bus = devCapPCIDev->bus; + devAddr.slot = devCapPCIDev->slot; +@@ -3081,8 +3084,6 @@ virNodeDeviceGetPCIVPDDynamicCap(virNodeDevCapPCIDev *devCapPCIDev) + if ((res = virPCIDeviceGetVPD(pciDev))) { + devCapPCIDev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VPD; + devCapPCIDev->vpd = g_steal_pointer(&res); +- } else { +- virPCIVPDResourceFree(g_steal_pointer(&devCapPCIDev->vpd)); + } + } + return 0; +-- +GitLab + diff --git a/virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch b/virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch new file mode 100644 index 0000000000000000000000000000000000000000..0004fff9326d99ff1d36964b14f4b5568fd7e6da --- /dev/null +++ b/virpci-Resolve-leak-in-virPCIVirtualFunctionList-cleanup.patch @@ -0,0 +1,50 @@ +From 6425a311b8ad19d6f9c0b315bf1d722551ea3585 Mon Sep 17 00:00:00 2001 +From: Tim Shearer +Date: Mon, 1 May 2023 13:15:48 +0000 +Subject: [PATCH] virpci: Resolve leak in virPCIVirtualFunctionList cleanup +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Repeatedly querying an SR-IOV PCI device's capabilities exposes a +memory leak caused by a failure to free the virPCIVirtualFunction +array within the parent struct's g_autoptr cleanup. + +Valgrind output after getting a single interface's XML description +1000 times: + +==325982== 256,000 bytes in 1,000 blocks are definitely lost in loss record 2,634 of 2,635 +==325982== at 0x4C3C096: realloc (vg_replace_malloc.c:1437) +==325982== by 0x59D952D: g_realloc (in /usr/lib64/libglib-2.0.so.0.5600.4) +==325982== by 0x4EE1F52: virReallocN (viralloc.c:52) +==325982== by 0x4EE1FB7: virExpandN (viralloc.c:78) +==325982== by 0x4EE219A: virInsertElementInternal (viralloc.c:183) +==325982== by 0x4EE23B2: virAppendElement (viralloc.c:288) +==325982== by 0x4F65D85: virPCIGetVirtualFunctionsFull (virpci.c:2389) +==325982== by 0x4F65753: virPCIGetVirtualFunctions (virpci.c:2256) +==325982== by 0x505CB75: virNodeDeviceGetPCISRIOVCaps (node_device_conf.c:2969) +==325982== by 0x505D181: virNodeDeviceGetPCIDynamicCaps (node_device_conf.c:3099) +==325982== by 0x505BC4E: virNodeDeviceUpdateCaps (node_device_conf.c:2677) +==325982== by 0x260FCBB2: nodeDeviceGetXMLDesc (node_device_driver.c:355) + +Signed-off-by: Tim Shearer +Reviewed-by: Ján Tomko +--- + src/util/virpci.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/util/virpci.c b/src/util/virpci.c +index 9e564e4a4f..cc2b07bbba 100644 +--- a/src/util/virpci.c ++++ b/src/util/virpci.c +@@ -2245,6 +2245,7 @@ virPCIVirtualFunctionListFree(virPCIVirtualFunctionList *list) + g_free(list->functions[i].ifname); + } + ++ g_free(list->functions); + g_free(list); + } + +-- +GitLab +