From nobody Sat Feb 7 11:31:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133309; cv=none; d=zohomail.com; s=zohoarc; b=jw1Z0NJA1CpPzNhsSIpuIzm0Fj2iDxwx2P3uF2f1P2eo4eHn6792ZxE5oFV/3MsVEeapKBgPABfw0NDjpuIgBrrG0HHZe8Z9qrHxgI5vBU2WeJ086ENMWT8gego8euYezbRFt7U8RnhF3q4jWFRG0E9fOAEtnbfvE8CkAxoBpBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133309; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=sHnTHd5eOv4CE3kG7WFIppdUW+9gnxWfxjSmfY/2Ums=; b=WLev0E95qt2R/X/ltZX818ubeGkmXxDAY0VHddiG5WzozSPLv1aKr9L6DICAm5QIX0uzdeRH06WGlWATU25DYCBXcGnfPLq2+pmvJB2XsSYwADsCgtgK4Q5IqE61UPEcYqFjWTBE4cfmpxMX6vTKbCc6hbDxN4EeSXTZJCFnjEY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770133309104598.4674320237318; Tue, 3 Feb 2026 07:41:49 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 445F841A13; Tue, 3 Feb 2026 10:41:48 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id AF1D641C7D; Tue, 3 Feb 2026 10:40:10 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 1A81E41986; Tue, 3 Feb 2026 10:40:05 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 95E0D41984 for ; Tue, 3 Feb 2026 10:40:04 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-n4WVGSy_Oxykm4TbcbNAbA-1; Tue, 03 Feb 2026 10:40:03 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 37A9B1800357 for ; Tue, 3 Feb 2026 15:40:02 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9383F1956048 for ; Tue, 3 Feb 2026 15:40:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133204; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sHnTHd5eOv4CE3kG7WFIppdUW+9gnxWfxjSmfY/2Ums=; b=ROOeSOfqlLxl8SV0w2BdGThkzdAGF4s4WaSpDkTl6jMrscWssdnedaqzl/ZZROEaI8e9Uu eRvuDedhfNTc8kmSmbVSgyj4VQO1EPEe2Jn1IWIsWO3kxzX96SzJwjbSD47mZEgI0O6ysx T9msFKZ6/ABgqStrfWtp4AQAvSd4vCU= X-MC-Unique: n4WVGSy_Oxykm4TbcbNAbA-1 X-Mimecast-MFC-AGG-ID: n4WVGSy_Oxykm4TbcbNAbA_1770133202 To: devel@lists.libvirt.org Subject: [PATCH 1/9] bhyve: Avoid memleak in bhyveParsePassthru() Date: Tue, 3 Feb 2026 16:39:49 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: DLlTA_GcWdxU0XL3pxB4jif-nlg7AkltzfrMiqyYZY8_1770133202 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7IN4WBBX3OTCNSCB5N5QDSI3FKW63KQZ X-Message-ID-Hash: 7IN4WBBX3OTCNSCB5N5QDSI3FKW63KQZ X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133310787158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The aim of bhyveParsePassthru() is to parse PCI address from bhyve command line. The PCI address might be of a form bus:slot:function or bus/slot/function. If the former isn't found the latter is parsed (both using g_strsplit()). But after the first call, g_strsplit() just returns a string list containing but the whole input duplicated. Therefore, calling plain g_free() is not enough, the array must be freed too. 6 bytes in 1 blocks are definitely lost in loss record 1 of 325 at 0x4863224: malloc (vg_replace_malloc.c:451) by 0x4EC6562: g_malloc (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4EE28D9: g_strsplit (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4011297: bhyveParsePassthru (bhyve_parse_command.c:699) by 0x4010082: bhyveParseBhyvePCIArg (bhyve_parse_command.c:800) by 0x400EE14: bhyveParseBhyveCommandLine (bhyve_parse_command.c:862) by 0x400DF9C: bhyveParseCommandLineString (bhyve_parse_command.c:1058) by 0x4008CA0: testCompareXMLToArgvFiles (bhyveargv2xmltest.c:39) by 0x4008B29: testCompareXMLToArgvHelper (bhyveargv2xmltest.c:105) by 0x4009288: virTestRun (testutils.c:143) by 0x40085AC: mymain (bhyveargv2xmltest.c:164) by 0x400B582: virTestMain (testutils.c:913) Signed-off-by: Michal Privoznik Reviewed-by: Roman Bogorodskiy --- src/bhyve/bhyve_parse_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index 8b405206bd..3d9a6f3964 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -701,7 +701,7 @@ bhyveParsePassthru(virDomainDef *def G_GNUC_UNUSED, goto error; } if (g_str_equal(addr, *params)) { - g_free(params); + g_strfreev(params); if (!(params =3D g_strsplit(addr, "/", -1))) { virReportError(VIR_ERR_OPERATION_FAILED, _("Failed to parse PC= I address %1$s"), addr); goto error; --=20 2.52.0 From nobody Sat Feb 7 11:31:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133360; cv=none; d=zohomail.com; s=zohoarc; b=XjpTiy2xdbNf19hJS2AmO9IyN7VjPTu2miSt/480PCKTwRMV6QBY+A6oiD6wnO2oa69CJtAlHcE5OnWcXv9pxvXF5B68BL+F0hLNMUuSeYZVNbXR9dQqgCpfUI3dQL0I7AVVLvtCgc4GHOYeIc2bOaOJQ3oy3e48QoiznL6glRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133360; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=Wf8UiCEfV+UWMs8xNMpJukhLQVGa32G5ip41FFwh1rg=; b=C6tHDNIg1JztH1xjC5zFI7GzFWQ5K0tOkMlULguA+J9ZZyutPWYht+FK9zwkvup7/o5ileEoMlFBHQZoInV5Tz//TOF8gKBKrjr0HN/a+Pod+HLjKyqJNEhZSGnhBIdktw97YCjoE8g8MY+GlFHnIxfF8yqms1oAC7IdgNbgEeA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770133360340776.7652341787992; Tue, 3 Feb 2026 07:42:40 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 9327541A2C; Tue, 3 Feb 2026 10:42:39 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 92E0C43DD2; Tue, 3 Feb 2026 10:40:12 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 421DF41817; Tue, 3 Feb 2026 10:40:06 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id BA3C641984 for ; Tue, 3 Feb 2026 10:40:05 -0500 (EST) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-cSEhlfUdOaOLDd8M_87Ctw-1; Tue, 03 Feb 2026 10:40:04 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3BD9B195422D for ; Tue, 3 Feb 2026 15:40:03 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 98D721956048 for ; Tue, 3 Feb 2026 15:40:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wf8UiCEfV+UWMs8xNMpJukhLQVGa32G5ip41FFwh1rg=; b=Tj/8pWCcgo6KzKDrlB0HEK73o4+45NB2fGW7IFlHICKkVxYm5VTVPZgEN6ofbEbJClo+HV /ZvyN9AIjoPC7e57tmNlCpw2lQeoyCyNmYKr4ZIN72fqNDKXD+Iktwt3Dy5ZMh4AmWsOgQ 6wGjurE1c7PNsQTvwDb0kxaQ+nv+q9c= X-MC-Unique: cSEhlfUdOaOLDd8M_87Ctw-1 X-Mimecast-MFC-AGG-ID: cSEhlfUdOaOLDd8M_87Ctw_1770133203 To: devel@lists.libvirt.org Subject: [PATCH 2/9] bhyve: Avoid leaking @addrs in bhyveDomainAssignPCIAddresses() Date: Tue, 3 Feb 2026 16:39:50 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: M_yrC_dlOq9wnTiPhHADqUFg_cVpsWeon29ymlyi33I_1770133203 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 3Y24VTXWIMKU43US5O2ORO3U2N6364L2 X-Message-ID-Hash: 3Y24VTXWIMKU43US5O2ORO3U2N6364L2 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133361056158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Inside of bhyveDomainAssignPCIAddresses() the @addr variable is allocated and in a few cases stolen into domain private data. But in all other cases the associated memory is never freed. 12,800 (3,200 direct, 9,600 indirect) bytes in 100 blocks are definitely lo= st in loss record 533 of 538 at 0x4888098: calloc (vg_replace_malloc.c:1682) by 0x4EE67D9: g_malloc0_n (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4AFD4AC: virDomainPCIAddressSetAlloc (domain_addr.c:1011) by 0x4020F68: bhyveDomainPCIAddressSetCreate (bhyve_device.c:65) by 0x40210BD: bhyveDomainAssignPCIAddresses (bhyve_device.c:219) by 0x402180C: bhyveDomainAssignAddresses (bhyve_device.c:241) by 0x4020083: bhyveDomainDefAssignAddresses (bhyve_domain.c:230) by 0x4B71820: virDomainDefPostParse (domain_postparse.c:1503) by 0x4B28282: virDomainDefParseNode (domain_conf.c:20565) by 0x4B2810B: virDomainDefParse (domain_conf.c:20502) by 0x4B281DF: virDomainDefParseFile (domain_conf.c:20549) by 0x4015D6B: testCompareXMLToArgvFiles (bhyvexml2argvtest.c:47) Signed-off-by: Michal Privoznik Reviewed-by: Roman Bogorodskiy --- src/bhyve/bhyve_device.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c index 28a9c82d7b..54511383bb 100644 --- a/src/bhyve/bhyve_device.c +++ b/src/bhyve/bhyve_device.c @@ -215,25 +215,29 @@ int bhyveDomainAssignPCIAddresses(virDomainDef *def, { virDomainPCIAddressSet *addrs =3D NULL; bhyveDomainObjPrivate *priv =3D NULL; + int ret =3D -1; =20 if (!(addrs =3D bhyveDomainPCIAddressSetCreate(def, 1))) return -1; =20 if (bhyveAssignDevicePCISlots(def, addrs) < 0) - return -1; + goto cleanup; =20 if (obj && obj->privateData) { priv =3D obj->privateData; if (addrs) { virDomainPCIAddressSetFree(priv->pciaddrs); priv->persistentAddrs =3D 1; - priv->pciaddrs =3D addrs; + priv->pciaddrs =3D g_steal_pointer(&addrs); } else { priv->persistentAddrs =3D 0; } } =20 - return 0; + ret =3D 0; + cleanup: + virDomainPCIAddressSetFree(addrs); + return ret; } =20 int bhyveDomainAssignAddresses(virDomainDef *def, virDomainObj *obj) --=20 2.52.0 From nobody Sat Feb 7 11:31:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133461; cv=none; d=zohomail.com; s=zohoarc; b=i3S/RLbE0Jy5BkLVQKPDdl5ESs95Fu3AvydxSuCIUnMYj+ATdaJD2xzQl+R/G01CYAeV+p1woj1EyWVEyrTDFhq0tKZYHOVrS0Hn3gt1NIEK9IRKjfBFoBJD3rmg9mZkzG9PmJRDOhORyCk7S2/xX8U8wXgOoRV5FNh8RVsWQ6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133461; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=b/Wmclbnqq9MhBIlMhhZMmx+X5ANK2vnlU9vipQBUaQ=; b=ftegurvL/AhbQgoBVkBk8htXRqcyyZsX0kH4kh9wrv+R/YuwZ++jJ7VJFPhb5p8io95mwzKXniduooqaO4041FHb/sUVtENRntP8TO/CITt8+29uZuMrU0FB+UAzFBX1iojTEhoRxwY1XiNP2orRiw60k4Wzr1oEsmCss/5mg7s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 177013346186193.6345732224064; Tue, 3 Feb 2026 07:44:21 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 16E4841C4B; Tue, 3 Feb 2026 10:44:21 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 4F48643E98; Tue, 3 Feb 2026 10:40:26 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 7C19C41B74; Tue, 3 Feb 2026 10:40:21 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C313641A97 for ; Tue, 3 Feb 2026 10:40:07 -0500 (EST) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-lF8mFkp-NbSv0qkqnSjreg-1; Tue, 03 Feb 2026 10:40:05 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 392AA19560B6 for ; Tue, 3 Feb 2026 15:40:04 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 95BFB1956048 for ; Tue, 3 Feb 2026 15:40:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b/Wmclbnqq9MhBIlMhhZMmx+X5ANK2vnlU9vipQBUaQ=; b=TH/vt6yxn8jVKnmyH6kmVTU9KwytIFfmcojF0SY9zIEoWGRt8OGY5ZBJX1XUBkzpHerBP8 ar2uw/HosdVO6J3V9sosH2n+FD8IdKVbmdPCxvLUEuELZ1LcCdjCxU0qXq54pf1E0wcq1P xupwVZXQtVP9NuCtDaG5e/J+VEdGqxk= X-MC-Unique: lF8mFkp-NbSv0qkqnSjreg-1 X-Mimecast-MFC-AGG-ID: lF8mFkp-NbSv0qkqnSjreg_1770133204 To: devel@lists.libvirt.org Subject: [PATCH 3/9] bhyve_command: Avoid leaking @buf in virBhyveProcessBuildBhyveCmd() Date: Tue, 3 Feb 2026 16:39:51 +0100 Message-ID: <6668c0bcae325269149da90df9b2a12a01359bf4.1770133151.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: GyXhDpNKzXMuIRlBnQKUD444ihJwiPqZNhE1Ih4d_90_1770133204 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 37TMROBTVYYBDWR67NKPLC3MLNHZWXBT X-Message-ID-Hash: 37TMROBTVYYBDWR67NKPLC3MLNHZWXBT X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133463517158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik When building OS loader part of bhyve command line, there's @buf declared and it is even correctly annotated with g_auto() to be freed automatically. But then, the buffer contents is appended onto the command line using virBufferContentAndReset() which leads to a memleak because the buffer is reset. It's virBufferCurrentContent() that should have been used instead. 128 bytes in 1 blocks are definitely lost in loss record 476 of 536 at 0x48882B1: realloc (vg_replace_malloc.c:1810) by 0x4EE6622: g_realloc (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4F048BC: g_string_new (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4A59E1E: virBufferInitialize (virbuffer.c:121) by 0x4A5A63C: virBufferVasprintf (virbuffer.c:321) by 0x4A5A5DE: virBufferAsprintf (virbuffer.c:303) by 0x401B22F: virBhyveProcessBuildBhyveCmd (bhyve_command.c:1021) by 0x4015F05: testCompareXMLToArgvFiles (bhyvexml2argvtest.c:72) by 0x4015BA9: testCompareXMLToArgvHelper (bhyvexml2argvtest.c:144) by 0x4016588: virTestRun (testutils.c:143) by 0x4015919: mymain (bhyvexml2argvtest.c:341) by 0x4018882: virTestMain (testutils.c:913) Signed-off-by: Michal Privoznik Reviewed-by: Roman Bogorodskiy --- src/bhyve/bhyve_command.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index a45a5d1c33..c9bfe22c8c 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -1003,7 +1003,7 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *drive= r, virDomainDef *def, if (def->os.bootloader =3D=3D NULL && def->os.loader) { virArch arch =3D def->os.arch; - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; =20 if (ARCH_IS_X86(arch)) { if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_LPC_BOOTROM))= { @@ -1011,7 +1011,7 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *drive= r, virDomainDef *def, if (def->os.loader->nvram && def->os.loader->nvram->path) virBufferAsprintf(&buf, ",%s", def->os.loader->nvram->= path); =20 - virCommandAddArgList(cmd, "-l", virBufferContentAndReset(&= buf), NULL); + virCommandAddArgList(cmd, "-l", virBufferCurrentContent(&b= uf), NULL); } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Installed bhyve binary does not support = UEFI loader")); @@ -1019,7 +1019,7 @@ virBhyveProcessBuildBhyveCmd(struct _bhyveConn *drive= r, virDomainDef *def, } } else if (ARCH_IS_ARM(arch)) { virBufferAsprintf(&buf, "bootrom=3D%s", def->os.loader->path); - virCommandAddArgList(cmd, "-o", virBufferContentAndReset(&buf)= , NULL); + virCommandAddArgList(cmd, "-o", virBufferCurrentContent(&buf),= NULL); } } =20 --=20 2.52.0 From nobody Sat Feb 7 11:31:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133413; cv=none; d=zohomail.com; s=zohoarc; b=gAeBKp8FcLRak0ghPqFo8O9W4/fywvMKk18ssxIq70qUMCNhYsvVI+XcJIhCf82f8oXihqe8BBgkFIdOekWi8JgYliNX8+c/1u2Ydv+3/9TLOXSGgJ1A5R77yIAAUQVn4iBaIA7qkrxogJbLRSZz5H9KqTvNpe3jbRAm0XKgRO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133413; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=qoa5PJKKd6gl41GaTVM72CuA/36rXJNaHz9b7VS/MeI=; b=a+hOMH6Vj6wisInXXZtc7HKc6bbaUcw+XGY9lct4OqbNx3Ic/UThWkQv75CNrpSBAqPcgp/dVdiOpcQ2sIygNCG3vZRzEsiS/3oAMUHYE/EXmdeo73/gH5i5z0zAPamp60IZQ1L0NFRR3KXvJ7UYeBhDZ7HMdOcNFY5MXk2NqVI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770133413211994.5356201095256; Tue, 3 Feb 2026 07:43:33 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 63AD343DF2; Tue, 3 Feb 2026 10:43:32 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id A9B3E43E38; Tue, 3 Feb 2026 10:40:20 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 1AA1C41ADE; Tue, 3 Feb 2026 10:40:17 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 89BB941A1D for ; Tue, 3 Feb 2026 10:40:07 -0500 (EST) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-r-9wpemjPIqAAMIBQGs7_A-1; Tue, 03 Feb 2026 10:40:06 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C677180035C for ; Tue, 3 Feb 2026 15:40:05 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9AE701956048 for ; Tue, 3 Feb 2026 15:40:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qoa5PJKKd6gl41GaTVM72CuA/36rXJNaHz9b7VS/MeI=; b=So5Rz4kZCE0xZzlKrY839L4zVj2f2/XWPLuZDbnONlkQLq2cUYWMbTaetkP0jKczk5YY1Q X/dYs5HPWWU8pzZ9UBvmCS1pcElfg8iNQtjcfBETS1oqQ98v4an1dJNScq6y1GrebD4bYY eBMbbLJPNaY9DfMSfBrPZQDr9PEvpek= X-MC-Unique: r-9wpemjPIqAAMIBQGs7_A-1 X-Mimecast-MFC-AGG-ID: r-9wpemjPIqAAMIBQGs7_A_1770133205 To: devel@lists.libvirt.org Subject: [PATCH 4/9] bhyve_command: Avoid memleak in bhyveBuildNetArgStr() Date: Tue, 3 Feb 2026 16:39:52 +0100 Message-ID: <6ae8e4c87dcc88c42b4499d2d5ceee3f56fdd99a.1770133151.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: jZ049Dt80MEdkRsPV7DT4OP9x3Xt5G6hP5LQnU0M4lQ_1770133205 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JBRLYY7RZMMUXFBPKI3VJDQ6I3DDFXSN X-Message-ID-Hash: JBRLYY7RZMMUXFBPKI3VJDQ6I3DDFXSN X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133415335158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Inside of bhyveBuildNetArgStr() there is @nic_model which is allocated, appended into cmd line and then freed under cleanup label. Firstly, There are few cases where instead of jumping onto the label there's a return statement (this alone can lead to a memory leak), but more importantly - the variable doesn't need dynamically allocated string. It's the same story with @brname. After making them both const strings, the return statements can be used more freely (up until first possible allocation). 6 bytes in 1 blocks are definitely lost in loss record 4 of 508 at 0x4883224: malloc (vg_replace_malloc.c:451) by 0x4EE6562: g_malloc (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4F0100F: g_strdup (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x401BC02: g_strdup_inline (gstrfuncs.h:321) by 0x401BC02: bhyveBuildNetArgStr (bhyve_command.c:64) by 0x401B362: virBhyveProcessBuildBhyveCmd (bhyve_command.c:1033) by 0x4015F15: testCompareXMLToArgvFiles (bhyvexml2argvtest.c:72) by 0x4015BB9: testCompareXMLToArgvHelper (bhyvexml2argvtest.c:144) by 0x4016598: virTestRun (testutils.c:143) by 0x4015121: mymain (bhyvexml2argvtest.c:275) by 0x4018892: virTestMain (testutils.c:913) by 0x4013DC6: main (bhyvexml2argvtest.c:352) Signed-off-by: Michal Privoznik Reviewed-by: Roman Bogorodskiy --- src/bhyve/bhyve_command.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index c9bfe22c8c..ff079da9ef 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -51,17 +51,17 @@ bhyveBuildNetArgStr(const virDomainDef *def, { char macaddr[VIR_MAC_STRING_BUFLEN]; char *realifname =3D NULL; - char *brname =3D NULL; - char *nic_model =3D NULL; + const char *brname =3D NULL; + const char *nic_model =3D NULL; int ret =3D -1; virDomainNetType actualType =3D virDomainNetGetActualType(net); g_autoptr(virConnect) netconn =3D NULL; =20 if (net->model =3D=3D VIR_DOMAIN_NET_MODEL_VIRTIO) { - nic_model =3D g_strdup("virtio-net"); + nic_model =3D "virtio-net"; } else if (net->model =3D=3D VIR_DOMAIN_NET_MODEL_E1000) { if ((bhyveDriverGetBhyveCaps(driver) & BHYVE_CAP_NET_E1000) !=3D 0= ) { - nic_model =3D g_strdup("e1000"); + nic_model =3D "e1000"; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("NIC model 'e1000' is not supported by given = bhyve binary")); @@ -75,9 +75,9 @@ bhyveBuildNetArgStr(const virDomainDef *def, =20 if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { if (!netconn && !(netconn =3D virGetConnectNetwork())) - goto cleanup; + return -1; if (virDomainNetAllocateActualDevice(netconn, def, net) < 0) - goto cleanup; + return -1; } /* final validation now that actual type is known */ if (virDomainActualNetDefValidate(net) < 0) @@ -88,11 +88,11 @@ bhyveBuildNetArgStr(const virDomainDef *def, switch (actualType) { case VIR_DOMAIN_NET_TYPE_NETWORK: case VIR_DOMAIN_NET_TYPE_BRIDGE: - brname =3D g_strdup(virDomainNetGetActualBridgeName(net)); + brname =3D virDomainNetGetActualBridgeName(net); if (!brname) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No bridge name specified")); - goto cleanup; + return -1; } break; case VIR_DOMAIN_NET_TYPE_USER: @@ -116,7 +116,7 @@ bhyveBuildNetArgStr(const virDomainDef *def, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported network type %1$s"), virDomainNetTypeToString(actualType)); - goto cleanup; + return -1; } =20 if (!dryRun) { @@ -156,9 +156,7 @@ bhyveBuildNetArgStr(const virDomainDef *def, cleanup: if (ret < 0) VIR_FREE(net->ifname); - VIR_FREE(brname); VIR_FREE(realifname); - VIR_FREE(nic_model); =20 return ret; } --=20 2.52.0 From nobody Sat Feb 7 11:31:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133496; cv=none; d=zohomail.com; s=zohoarc; b=YQQgX+wjlE6cHWtJL1zMJSxKwNMcZEaPhuOq3ZCwCzOe2UJNtJjBzZqtf25oc92zZKEfBGFTpTHUxxZ321E4tdGlUYr/6oEtxiUFj8koNBqpa7c+pllFVGEHAJzvEfrVcjm41gN9PqxGysbrhEANOG4oh1qGxYu5uI5lFXeqKvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133496; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=UTV4z+1qoy3/HvVKAmC/7Kwg/MeqvhwU4rhG5GFqvlo=; b=PHIsHE2Arj4/vB2WglAcfw3wqLIrThpyCiF8cefTWYScGN9IeNiCewzkWgbXXVT2JBPx1JNQ6QM10sH5XA9O40irYJ01TUOiuj4zvyWxDeHjowhTjc6o5RVXkUntBCmjsqtQXimKeDT/KC3tnfi7ygH4gCAtC34Sd16WxYuGEAs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770133496390341.90412315688855; Tue, 3 Feb 2026 07:44:56 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id CFB7B419EC; Tue, 3 Feb 2026 10:44:55 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 0FB8743E43; Tue, 3 Feb 2026 10:41:03 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 48AE03F33A; Tue, 3 Feb 2026 10:40:58 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B585A41B63 for ; Tue, 3 Feb 2026 10:40:08 -0500 (EST) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-63-BhAn33NaOpm94ayFActjmA-1; Tue, 03 Feb 2026 10:40:07 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4421D1956060 for ; Tue, 3 Feb 2026 15:40:06 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 97B141956048 for ; Tue, 3 Feb 2026 15:40:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133208; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UTV4z+1qoy3/HvVKAmC/7Kwg/MeqvhwU4rhG5GFqvlo=; b=NmWg21EYrEgpZvMMO9mpeTVnEWr//r+5lZ0uPfhWwPdUYtkKUDgSbCw9zsC9/me0+cOK9c wpDN9O4NMe7LQu92oIXhG8x9UxX4oJBM+NyjYbYuR3iesE5DmzQkRnE4XUl4XMoT7sHhI0 SKKWtXEt69DHU/LNf2+EA0WXkfQxRs8= X-MC-Unique: BhAn33NaOpm94ayFActjmA-1 X-Mimecast-MFC-AGG-ID: BhAn33NaOpm94ayFActjmA_1770133206 To: devel@lists.libvirt.org Subject: [PATCH 5/9] bhyvexml2argvmock: Provide virCPUProbeHost() Date: Tue, 3 Feb 2026 16:39:53 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: mPEfP5xjBvK9KgrHSKpbyo876-kOccl30dG9KTOXu7Q_1770133206 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JBW4XAIGKFAR6H5RRPWTS6TJOLSO56MQ X-Message-ID-Hash: JBW4XAIGKFAR6H5RRPWTS6TJOLSO56MQ X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133500944154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The bhyvexml2argvmock is loaded by bhyvexml2argvtest which calls virBhyveCapsBuild() which in turn calls virCPUProbeHost(). To make our test environment stable, it shouldn't depend on actual CPU and thus mocked implementation for virCPUProbeHost should be offered. Surprisingly, this is done in bhyveargv2xmlmock but not in bhyvexml2argvmock. Until now. Signed-off-by: Michal Privoznik Reviewed-by: Roman Bogorodskiy --- tests/bhyvexml2argvmock.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c index fe76564d51..7dbdd48682 100644 --- a/tests/bhyvexml2argvmock.c +++ b/tests/bhyvexml2argvmock.c @@ -8,6 +8,8 @@ #include "virnetdevtap.h" #include "virmock.h" #include "internal.h" +#include "cpu/cpu.h" +#include "testutilshostcpus.h" =20 #define VIR_FROM_THIS VIR_FROM_BHYVE =20 @@ -89,3 +91,9 @@ int bind(int sockfd G_GNUC_UNUSED, { return 0; } + +virCPUDef * +virCPUProbeHost(virArch arch) +{ + return testUtilsHostCpusGetDefForArch(arch); +} --=20 2.52.0 From nobody Sat Feb 7 11:31:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133536; cv=none; d=zohomail.com; s=zohoarc; b=XWpdqRlAydrBa3djDie62nP0+96L47XrW19WtYrMh4PWbBFKDkgjpQoCn1ePeKHxkvrVRDtYfoM7wwZeSOzy8vNHZ+WO1p6zTJXsKAW4G2W3/6K1Tv80Rfy7CzvvV+fxMneiWzjjaDUCbpFh+IBe/CZl5PmjQPbNqRyy1n/5DdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133536; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=mwSAk2iiTN7lujtIGrYNwx6dZjLbiGEOfKVgSYq2yZ4=; b=mSi/4CI32aV5PDJgTE7ZkYE2rGo+MwyDml7FEHt/Xs+jp5dNuXvzAZHHGRw90EfFQU3viEwD0S7v+b+H5tYU4aujQtY/aR8l1SO59mXPJOIxPScZFEEt283zqCvzR5eEmAIMXsdVySJhe1q+LVLMri5d64/E/tBQYddpVJL+I88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770133536177295.492633668708; Tue, 3 Feb 2026 07:45:36 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 3419A41A39; Tue, 3 Feb 2026 10:45:36 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 5F3B343ED3; Tue, 3 Feb 2026 10:41:13 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 94E5641AEE; Tue, 3 Feb 2026 10:41:09 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E628641BB0 for ; Tue, 3 Feb 2026 10:40:09 -0500 (EST) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-zHnl5FsgMNK5or9D8_ah1w-1; Tue, 03 Feb 2026 10:40:08 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4B12519560AA for ; Tue, 3 Feb 2026 15:40:07 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A80F21956053 for ; Tue, 3 Feb 2026 15:40:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mwSAk2iiTN7lujtIGrYNwx6dZjLbiGEOfKVgSYq2yZ4=; b=GxHjSsug2l0BCUz8icYU1uWF69Ahx7EnwEtT14TCB1rs8LAk4LcEMhC37H4BgQhQqzaeXo Z+W89yptMv0aa1+3OTHkkne+rTKlpRUX2i6nFsj0pDQDvwQAZrqgZxuqH2bs9PhJQEER5j KjeFI9pT+yr6S23afxt6bj4sVH+xMNQ= X-MC-Unique: zHnl5FsgMNK5or9D8_ah1w-1 X-Mimecast-MFC-AGG-ID: zHnl5FsgMNK5or9D8_ah1w_1770133207 To: devel@lists.libvirt.org Subject: [PATCH 6/9] bhyvexml2argvtest: Avoid leaking driver caps Date: Tue, 3 Feb 2026 16:39:54 +0100 Message-ID: <5b7079b21376a2c9865d67d6867d91dd5d4d4297.1770133151.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: V8XVVgFr3-qZWVIo9x76tNa7dKkveajlWlL-va6wYtM_1770133207 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QR23ZMZ4NLS4FR56SOTT7GNSJF34OXOF X-Message-ID-Hash: QR23ZMZ4NLS4FR56SOTT7GNSJF34OXOF X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133538393158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Driver capabilities are allocated at the beginning of mymain(), but roughly in the middle the architecture is switched to aarch64 and capabilities are constructed again. Without freeing the old ones. 1,583 (288 direct, 1,295 indirect) bytes in 1 blocks are definitely lost in= loss record 520 of 536 at 0x4888098: calloc (vg_replace_malloc.c:1682) by 0x4EE65CA: g_malloc0 (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x53344B8: g_type_create_instance (in /usr/local/lib/libgobject-2.0.s= o.0.8400.4) by 0x531D263: ??? (in /usr/local/lib/libgobject-2.0.so.0.8400.4) by 0x531C75E: g_object_new (in /usr/local/lib/libgobject-2.0.so.0.8400.4) by 0x4AAC806: virObjectNew (virobject.c:252) by 0x4AF366A: virCapabilitiesNew (capabilities.c:87) by 0x401998B: virBhyveCapsBuild (bhyve_capabilities.c:51) by 0x4013E93: mymain (bhyvexml2argvtest.c:155) by 0x4018882: virTestMain (testutils.c:913) by 0x4013DC6: main (bhyvexml2argvtest.c:351) Signed-off-by: Michal Privoznik Reviewed-by: Roman Bogorodskiy --- tests/bhyvexml2argvtest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index c7c18c3690..51273295b5 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -331,6 +331,7 @@ mymain(void) DO_TEST("bhyveload-timeout"); =20 /* arm64 tests */ + virObjectUnref(driver.caps); virTestSetHostArch(VIR_ARCH_AARCH64); driver.caps =3D virBhyveCapsBuild(); /* bhyve does not support UTC clock on ARM */ --=20 2.52.0 From nobody Sat Feb 7 11:31:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133578; cv=none; d=zohomail.com; s=zohoarc; b=JoblzAcXfOgfQMdSRBerVdOqzYNrWnhZBVi58SEXY0lT5OSy210s6IsYjlwCcOIlWqTAnkdKr4CKXhN1o6jZP77g9NackbuJZkL5CvhnQmcJ8DHN5zr5xKHtOC1diBziP0WgP7019Wy/ukSX5N4dyDXG53+mtE3WDt7qDP6E9cE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133578; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=foeMUW501Zzh9PL+84atxDXLRkwsp8VEJaTinH26ja8=; b=RzsY/5s629Ufk7BNkE1BsuwGjZgnGhghOPeCOKjWDR7TrOVFFfW+bE7OHmzvKVmV90XTRagMBW6tZZmzKQwBUtZgAJaQu0AAZtyf3JnzgvcSuPhwA/m4MtkW6fd77u1vH9M2QWlsxqCD2UStmfjV5+BYodsrWqGxb7+nUxkUDo8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770133578077956.163047894322; Tue, 3 Feb 2026 07:46:18 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 3E72241B70; Tue, 3 Feb 2026 10:46:17 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 7CE8743EE8; Tue, 3 Feb 2026 10:41:57 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 0AE6141ACB; Tue, 3 Feb 2026 10:41:52 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B42B841C80 for ; Tue, 3 Feb 2026 10:40:10 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-phaFsQkVPLCSv-9JykSEvQ-1; Tue, 03 Feb 2026 10:40:09 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4670C180044D for ; Tue, 3 Feb 2026 15:40:08 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A4C721956048 for ; Tue, 3 Feb 2026 15:40:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133210; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=foeMUW501Zzh9PL+84atxDXLRkwsp8VEJaTinH26ja8=; b=biyMBZ1zgWpG44pXDbXLdq8jYg09HUiuMlM+yUzBo83hmNIECpk9ZZpLNAqm+K7CE0WoDp yTSmxoy6ukVBEGgjbcTLCi4/3f0FYX3pXm1BT18+z1+bO4JcVFHtVbsqjp8QzphNDma+9x zHAryt8EuS1chGranw7mrgNL0doK0bw= X-MC-Unique: phaFsQkVPLCSv-9JykSEvQ-1 X-Mimecast-MFC-AGG-ID: phaFsQkVPLCSv-9JykSEvQ_1770133208 To: devel@lists.libvirt.org Subject: [PATCH 7/9] bhyvexml2argvtest: Don't leak parts of driver config Date: Tue, 3 Feb 2026 16:39:55 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6s9jm62EWCirzHG7xdX8w_m8H3K8urS0CuXk3aKMx_U_1770133208 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VQX2W5PQXIYP67PXDVI2XTQDVFSDU7XM X-Message-ID-Hash: VQX2W5PQXIYP67PXDVI2XTQDVFSDU7XM X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133578483158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik At the beginning of mymain() the virBhyveDriverConfigNew() is called which inits driver config with some paths. These are then overwritten to produce stable test output. Well, the old ones should be freed first. 128 bytes in 1 blocks are definitely lost in loss record 453 of 508 at 0x4883224: malloc (vg_replace_malloc.c:451) by 0x506BD16: vasprintf_l (in /lib/libc.so.7) by 0x4F39073: g_vasprintf (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4F01288: g_strdup_printf (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x401F75B: virBhyveDriverConfigNew (bhyve_conf.c:62) by 0x4013FAA: mymain (bhyvexml2argvtest.c:164) by 0x4018892: virTestMain (testutils.c:913) by 0x4013DC6: main (bhyvexml2argvtest.c:352) 25 bytes in 1 blocks are definitely lost in loss record 206 of 508 at 0x4883224: malloc (vg_replace_malloc.c:451) by 0x4EE6562: g_malloc (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4F0100F: g_strdup (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x401F715: g_strdup_inline (gstrfuncs.h:321) by 0x401F715: virBhyveDriverConfigNew (bhyve_conf.c:60) by 0x4013FAA: mymain (bhyvexml2argvtest.c:164) by 0x4018892: virTestMain (testutils.c:913) by 0x4013DC6: main (bhyvexml2argvtest.c:352) Signed-off-by: Michal Privoznik Reviewed-by: Roman Bogorodskiy --- tests/bhyvexml2argvtest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 51273295b5..8f078f9d78 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -164,8 +164,10 @@ mymain(void) if (!(driver.config =3D virBhyveDriverConfigNew())) return EXIT_FAILURE; =20 - driver.config->firmwareDir =3D fakefirmwaredir; - driver.config->nvramDir =3D fakenvramdir; + VIR_FREE(driver.config->firmwareDir); + VIR_FREE(driver.config->nvramDir); + driver.config->firmwareDir =3D g_steal_pointer(&fakefirmwaredir); + driver.config->nvramDir =3D g_steal_pointer(&fakenvramdir); driver.config->bhyveloadTimeout =3D 0; driver.config->bhyveloadTimeoutKill =3D 0; =20 --=20 2.52.0 From nobody Sat Feb 7 11:31:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133617; cv=none; d=zohomail.com; s=zohoarc; b=iATiL0wsOheWlekTaZ1OKo1qViz8H1cDw/vfDBi4EqnHZDodzM/esXqyQs+chZHLts9lOzvD4/QlliX5Pyw5N8RGXOPURZEfD7Nk1ujRhoy8M6XKsaPubhfAek1LtWFeXl10lKlxOIL+gdmhBNKuW5jYNvXQJgtIh8NOXRv29w8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133617; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=0oOgbJ/sAvKw1IbRpCgXSH5BPpGN1jfsdhhPpMvpsxo=; b=ZiS+KpfFzddBDPflmrzBjWvS4FVHtdot3YHOLxbKit0yK/JSemLT0Af8StZWsWnjFn28gsIHXMw/Y/DWtRuxVLyZSfFKddwkixsZDgs+LMDc1IK+l8hVtCtZwcVdRnudLc+iIxarwNpOFJtgK6MA8LvPwOwB5QJnF6lfY93h0jo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770133617401248.05755373274712; Tue, 3 Feb 2026 07:46:57 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id B4E5641ACB; Tue, 3 Feb 2026 10:46:56 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 884E543F0B; Tue, 3 Feb 2026 10:42:31 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 571A441A31; Tue, 3 Feb 2026 10:42:27 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 2964B41989 for ; Tue, 3 Feb 2026 10:40:12 -0500 (EST) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-LekWC4s5PFyFHcAywUME6A-1; Tue, 03 Feb 2026 10:40:10 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4483B195609E for ; Tue, 3 Feb 2026 15:40:09 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A15951956053 for ; Tue, 3 Feb 2026 15:40:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133211; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0oOgbJ/sAvKw1IbRpCgXSH5BPpGN1jfsdhhPpMvpsxo=; b=jLgnDPue9NuC23hEsnGZDBEk+PfPJ9zydvlbP/d1PdTOKe9iqQWb8E5/xIU92JoyEnAZUX PT0umPgG/WbMTYpfSAh9i74uFo2ZQ+F4S1Id3/yqm6uk4Nrt+5vyIcfQ1HZli7Ttj7oVXs Wlcq//1t5Egi4ez9V1KczWexAVO0+ug= X-MC-Unique: LekWC4s5PFyFHcAywUME6A-1 X-Mimecast-MFC-AGG-ID: LekWC4s5PFyFHcAywUME6A_1770133209 To: devel@lists.libvirt.org Subject: [PATCH 8/9] bhyvexml2argvtest: Avoid leaking firmwareDir Date: Tue, 3 Feb 2026 16:39:56 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: u0qoFT8KW2qNLlZf_AsiqZCl98P4qtrPFtPiQ4NP6fk_1770133209 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SVMGFNV2KNYHTUYL223CMNNKVGGVB2ZE X-Message-ID-Hash: SVMGFNV2KNYHTUYL223CMNNKVGGVB2ZE X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133620823154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The firmwareDir member of driver config is set at the beginning of mymain(). But then, roughly in the middle of test cases it is overwritten to fakefirmwareemptydir. But this means the old value must be freed. Or reassigned back to its original variable which is freed automatically. 16 bytes in 1 blocks are definitely lost in loss record 190 of 505 at 0x4883224: malloc (vg_replace_malloc.c:451) by 0x4EE6562: g_malloc (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4F0100F: g_strdup (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x4013E26: g_strdup_inline (gstrfuncs.h:321) by 0x4013E26: mymain (bhyvexml2argvtest.c:151) by 0x40189A2: virTestMain (testutils.c:913) by 0x4013DE6: main (bhyvexml2argvtest.c:354) Signed-off-by: Michal Privoznik Reviewed-by: Roman Bogorodskiy --- tests/bhyvexml2argvtest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 8f078f9d78..ae43445cde 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -249,7 +249,8 @@ mymain(void) DO_TEST("isa-controller"); DO_TEST_FAILURE("isa-multiple-controllers"); DO_TEST("firmware-efi"); - driver.config->firmwareDir =3D fakefirmwareemptydir; + fakefirmwaredir =3D g_steal_pointer(&driver.config->firmwareDir); + driver.config->firmwareDir =3D g_steal_pointer(&fakefirmwareemptydir); DO_TEST_PREPARE_ERROR("firmware-efi"); DO_TEST("fs-9p"); DO_TEST("fs-9p-readonly"); --=20 2.52.0 From nobody Sat Feb 7 11:31:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1770133662; cv=none; d=zohomail.com; s=zohoarc; b=ZBKpbtxrOuzWxGTd4piblpcIqI++x3prAnMc2sFxlQ/57FEwxRGRxhuLGVXht+//5XcrLQ8l5wlYMypjVx1zHDSxr7TuFpWYqJgFVMPA0du9WYOnDB1ufUzgam0u2b/MM27VjF+amdteZSOCfsBBeodcByFNE2zGhtds6dOgadM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770133662; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=2OJueFQCJb3MEzrBmioLy+T45vTGZ0tmjQdMMr7jJGc=; b=bwOA72jJYKNsnZF3iv8yb/vnrQ7u7ZJFMyyBF8A9Duq63wLgcSinvVVhbhzDzIpnyvswkwmd1iuH6j30hBruV/hEoRkuTJLgiQw6jt7qHpG7IvfZQueY5HHlSBzyN0i2fX/r7Og6mM68D6DUjNdGCmaXRafk/B23ksZjEZ+/u1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1770133662469761.548329458417; Tue, 3 Feb 2026 07:47:42 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 0719B41986; Tue, 3 Feb 2026 10:47:42 -0500 (EST) Received: from [172.19.199.6] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 9EA2043F5A; Tue, 3 Feb 2026 10:42:46 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id A0DC23F315; Tue, 3 Feb 2026 10:42:42 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A087C43DD7 for ; Tue, 3 Feb 2026 10:40:12 -0500 (EST) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-167-7-VH-bcePRm1p4gKZ4XWUg-1; Tue, 03 Feb 2026 10:40:11 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4164D180034D for ; Tue, 3 Feb 2026 15:40:10 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9F04B1956048 for ; Tue, 3 Feb 2026 15:40:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770133212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2OJueFQCJb3MEzrBmioLy+T45vTGZ0tmjQdMMr7jJGc=; b=gIigFLSVxSTwfo2SZQBTfk2unzbbwMFlUmkKbx0Nfwc1wFxRj/895Xn2UXRQ5orlX/UdY0 oZYNegtA2ak7cg7qWrVdA8St7j4NFDp6kLyAsmV2AP9A+32QJ0zecacaWuYQ+AyJZyqsUz 0zMtSzNnoDSowHauiH75Et//wA1cE50= X-MC-Unique: 7-VH-bcePRm1p4gKZ4XWUg-1 X-Mimecast-MFC-AGG-ID: 7-VH-bcePRm1p4gKZ4XWUg_1770133210 To: devel@lists.libvirt.org Subject: [PATCH 9/9] bhyvexml2xmltest: Avoid leaking driver caps Date: Tue, 3 Feb 2026 16:39:57 +0100 Message-ID: <7480a2bf3a7ca05275b0070d70aaf8fd60c92bd8.1770133151.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: bkQZ8_BO21wwBTJ7j8J-bjCXKNlzF8NF4DRSMcaMuZA_1770133210 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VFP2X4TWHXSZ5ZW4OXGHFXAGYV65VLK4 X-Message-ID-Hash: VFP2X4TWHXSZ5ZW4OXGHFXAGYV65VLK4 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1770133665475154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik Driver capabilities are allocated at the beginning of mymain(), but roughly in the middle the architecture is switched to aarch64 and capabilities are constructed again. Without freeing the old ones. 704 (288 direct, 416 indirect) bytes in 1 blocks are definitely lost in los= s record 328 of 332 at 0x4885098: calloc (vg_replace_malloc.c:1682) by 0x4EE35CA: g_malloc0 (in /usr/local/lib/libglib-2.0.so.0.8400.4) by 0x53314B8: g_type_create_instance (in /usr/local/lib/libgobject-2.0.s= o.0.8400.4) by 0x531A263: ??? (in /usr/local/lib/libgobject-2.0.so.0.8400.4) by 0x531975E: g_object_new (in /usr/local/lib/libgobject-2.0.so.0.8400.4) by 0x4AA9AB6: virObjectNew (virobject.c:252) by 0x4AF0BBA: virCapabilitiesNew (capabilities.c:87) by 0x401797B: virBhyveCapsBuild (bhyve_capabilities.c:51) by 0x4012F57: mymain (bhyvexml2xmltest.c:60) by 0x4016872: virTestMain (testutils.c:913) Signed-off-by: Michal Privoznik Reviewed-by: Roman Bogorodskiy --- tests/bhyvexml2xmltest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index 5df1f2b6ba..9e3bd6c45f 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -144,6 +144,7 @@ mymain(void) /* USB xhci tablet */ DO_TEST_DIFFERENT("input-xhci-tablet"); =20 + virObjectUnref(driver.caps); virTestSetHostArch(VIR_ARCH_AARCH64); driver.caps =3D virBhyveCapsBuild(); /* bhyve does not support UTC clock on ARM */ --=20 2.52.0