From nobody Mon Feb 9 00:30:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612285018; cv=none; d=zohomail.com; s=zohoarc; b=KL2wk7pwRgEFL4F+sez1nNymnpKsgPOUYwsJa2g1/iLpv2OXwbzdW/y5eT2FqaBn/kB8d8NLJhHdQoJIbRF6nEYBOastzYdNiwsG5C+UgmInZaBcCZTKCqzIYdzIbtTgHXLx8v1HoOe6B5OYH9DAr0j1UnlpF/pjSH1c2cla1E8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285018; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2SAQEo4Tsn0hcEKRhtdKYQuosBXRBTAsIoHEhkSat7A=; b=QSNhcvQSa2B+wExX7UF/QN4wx144KstACG26hlfqnMNhrSyID+Ru+ILoSuQTTVA+GgcKH31FXdwG85eMG5Nt/l41ozzNPeZUY1tOarEpXKurf2uawfdL8m7Oza8w2vV9f0YmcWszOYLI7i+NJvj1aSbDKbQ3hYkiNV/A3qXNqRU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1612285018336911.7949776894009; Tue, 2 Feb 2021 08:56:58 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-WWstnN7oNLWgvDItqy-Gag-1; Tue, 02 Feb 2021 11:56:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75642871241; Tue, 2 Feb 2021 16:56:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53ED660C5F; Tue, 2 Feb 2021 16:56:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1A15050049; Tue, 2 Feb 2021 16:56:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 112GuhV5015032 for ; Tue, 2 Feb 2021 11:56:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id D0AA26EF50; Tue, 2 Feb 2021 16:56:43 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4872E6E510 for ; Tue, 2 Feb 2021 16:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285017; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2SAQEo4Tsn0hcEKRhtdKYQuosBXRBTAsIoHEhkSat7A=; b=hM9iniR/0EIhwfMxwM8JoE8qztprkVJDUWZHQGnMMN5eONQbcjKILsmpnKsDAsdKTp2nX8 4iIssxua54NTLQB+nswVZY7FgN3n021EJecbVCaHmN+8VfP0+h07t20p7OELO3cmOPfFOK N0T9T1R3ItkjaJ9pyGz39CSmqv1gDx0= X-MC-Unique: WWstnN7oNLWgvDItqy-Gag-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 11/27] qemu: domain: Use virSecureErase for clearing secrets instead of VIR_DISPOSE_N Date: Tue, 2 Feb 2021 17:55:48 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Phase out use of VIR_DISPOSE_N from the qemu driver. Use memset in the appropriate cases. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_domain.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2c34307c82..e60f814e36 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -67,6 +67,7 @@ #include "backup_conf.h" #include "virutil.h" #include "virqemu.h" +#include "virsecureerase.h" #include #include @@ -443,7 +444,8 @@ qemuDomainMasterKeyFree(qemuDomainObjPrivatePtr priv) if (!priv->masterKey) return; - VIR_DISPOSE_N(priv->masterKey, priv->masterKeyLen); + virSecureErase(priv->masterKey, priv->masterKeyLen); + g_clear_pointer(&priv->masterKey, g_free); } /* qemuDomainMasterKeyReadFile: @@ -584,7 +586,8 @@ static void qemuDomainSecretPlainClear(qemuDomainSecretPlainPtr secret) { VIR_FREE(secret->username); - VIR_DISPOSE_N(secret->secret, secret->secretlen); + virSecureErase(secret->secret, secret->secretlen); + g_clear_pointer(&secret->secret, g_free); } @@ -1131,7 +1134,7 @@ qemuDomainSecretAESSetupFromSecret(qemuDomainObjPriva= tePtr priv, g_autoptr(virConnect) conn =3D virGetConnectSecret(); qemuDomainSecretInfoPtr secinfo; g_autofree char *alias =3D qemuAliasForSecret(srcalias, secretuse); - uint8_t *secret =3D NULL; + g_autofree uint8_t *secret =3D NULL; size_t secretlen =3D 0; if (!conn) @@ -1143,7 +1146,7 @@ qemuDomainSecretAESSetupFromSecret(qemuDomainObjPriva= tePtr priv, secinfo =3D qemuDomainSecretAESSetup(priv, alias, username, secret, se= cretlen); - VIR_DISPOSE_N(secret, secretlen); + virSecureErase(secret, secretlen); return secinfo; } --=20 2.29.2