From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612284989; cv=none; d=zohomail.com; s=zohoarc; b=LJ8BWFjJu7srdbAqRwCqdAQ/pEVQ19wcgYNtfjhSF8zV/8JNgSyRO2mtnAbCVzJ0jCIn4AEd1AQlKCwHK8Wkrr+mfXYm6L1rq4jjohxEbkVafSY0suPsWiBrrqtFQDZfWjNM8273r6iOxXEFTVnJah/OaGZOI/+0hw3HctVsSC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612284989; 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=Jdu8bhj8xxBmSvppmxp+BoqCVTNNBW/2LZZac2oA5QQ=; b=KrUpLVrmW9+HSk8OfdWtaXkrJHXGrFhYMTIFURIOmQcIXXVScgxPDHXiRZsysVV69qQ3oyaUlMPHT/enSl/J5Fyh9MxVIWjZA609JvsQwreizvLNlbst1Lb+GJppSCogNhLOGvfPkm0UL3BIqRMilEdMiSOmS4by37KOYNyp4BA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612284989211666.6140186526977; Tue, 2 Feb 2021 08:56:29 -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-124-QoC7IcBYMl20uiG6ONU0SA-1; Tue, 02 Feb 2021 11:56:25 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A1E8106B3AE; Tue, 2 Feb 2021 16:56:18 +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 9B3315D9DE; Tue, 2 Feb 2021 16:56:17 +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 0AE4D50038; Tue, 2 Feb 2021 16:56:17 +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 112GuFJC014870 for ; Tue, 2 Feb 2021 11:56:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id CFB9460862; Tue, 2 Feb 2021 16:56:15 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 312146EF46 for ; Tue, 2 Feb 2021 16:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612284987; 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=Jdu8bhj8xxBmSvppmxp+BoqCVTNNBW/2LZZac2oA5QQ=; b=UFtUg6epMMIxGbAXSlUr7WEGSyvEVrICfQCllQ14MmZqC24fmbp5oQWJFOoh0fiulmeFLF +nMUjfpk2n6yDONhWzek9NCFW44zs9+3B3WSSv6gRIYBaX3QEJpoLfwjK0xcXpTsQLUdpE wybqHHN91B5Uflbq2QewVUTUfASfNRc= X-MC-Unique: QoC7IcBYMl20uiG6ONU0SA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 01/27] hypervFreeInvokeParams: Don't use VIR_DISPOSE_N for freeing 'params' Date: Tue, 2 Feb 2021 17:55:38 +0100 Message-Id: <2f611d3d873aa1a85ad865eb050f05ce66cede91.1612284661.git.pkrempa@redhat.com> 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.14 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" The struct doesn't contain any secrets to clear before freeing and even if it did VIR_DISPOSE_N wouldn't help as the struct contains only pointers thus the actual memory pointing to isn't sanitized. Just free the params array pointer and then the struct itself. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/hyperv/hyperv_wmi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index c14ff0e64a..8bb6f591f1 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -184,8 +184,8 @@ hypervFreeInvokeParams(hypervInvokeParamsListPtr params) } } - VIR_DISPOSE_N(params->params, params->nbAvailParams); - VIR_FREE(params); + g_free(params->params); + g_free(params); } --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285038; cv=none; d=zohomail.com; s=zohoarc; b=SCKdKn5F8tdW1wZGXqwYLR+zrdM746oDHG5gI9Ku9zwaHXTUjazdOICQLFx25T+Xuk7Uo1EQcQ+UuexszxfwefU2kyFledqqxAmRsT9KX70XZzHj57F91k0niTtUBZoqPMBNSufo+9ZvEiTLNJ5ndPUXscJS9sgFE5z5F09n4xU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285038; 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=UizPWiL3MsSp1hXNWDzUCWsB3exVQQmqnCWl2FjbW0E=; b=f18RWLrA6v9XwQzdaecmJ9tj0XdmLFJebuc1xoDPT2PxHH3CZjcGv6Tmnstas09bjv0trsgk27Mzefku8i0SyrmTU7NjZIXknsTf0H3Jt4oRaoLHkpZN6KFTXbh3o/qVpNFlpuSnSFZ08A8T7rQHT7J4m5g4BHRoCUvPNwI8R5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612285038291558.645639725442; Tue, 2 Feb 2021 08:57:18 -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-378-60sKzMyyN_yEIvqD7B4EPA-1; Tue, 02 Feb 2021 11:56:31 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 825ED10CE785; Tue, 2 Feb 2021 16:56:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F9AD5C72F; Tue, 2 Feb 2021 16:56:26 +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 DFCAD18095CE; Tue, 2 Feb 2021 16:56:25 +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 112GuGMK014876 for ; Tue, 2 Feb 2021 11:56:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id D7D866E510; Tue, 2 Feb 2021 16:56:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EA9E60862 for ; Tue, 2 Feb 2021 16:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285037; 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=UizPWiL3MsSp1hXNWDzUCWsB3exVQQmqnCWl2FjbW0E=; b=WQgQ2M3AgY/NEWo+LmywOYm+g40cLfARMVhRfLVCAa22Z7nD3v1yzJwpOmDt+z8Fuw3N3W 1rr4D797RuvVY5GNmuIEEOipvbvpqiKtmKv44JMB7fVy/gBreTm6z3t0U5NjDOek3FO+yn FedQqjQf5mBWuYqeR1R+WcyNUUjUyNQ= X-MC-Unique: 60sKzMyyN_yEIvqD7B4EPA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 02/27] libxlMakeDomBuildInfo: Don't use VIR_DISPOSE_N for USB device list Date: Tue, 2 Feb 2021 17:55:39 +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.16 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" The list isn't secret which would need being disposed of. Just expand the array and return failure when adding the NULL terminator similarly to how we expand the list for adding devices in a loop. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libxl/libxl_conf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 6a8ae27f54..cb1fd7df7d 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -686,7 +686,6 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, /* NULL-terminate usbdevice_list */ if (nusbdevice > 0 && VIR_EXPAND_N(b_info->u.hvm.usbdevice_list, nusbdevice, 1) < 0)= { - VIR_DISPOSE_N(b_info->u.hvm.usbdevice_list, nusbdevice); return -1; } #endif --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612284998; cv=none; d=zohomail.com; s=zohoarc; b=njQ7e4Y/d6NgMRPATRMvyMH1avnWJCxRNdnmf3ZnTNJUy/VmJx8XUaYl3+fbqpchYT4zywgmspSf8WchXu6s17nuuNtqUjXcfjF9Svx1IBwpcxq8gUuKyucjcmL74bUNpKyulO2/kzwx/65Egqg5135I4MR92+cLWb8l1Yxl7bY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612284998; 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=nDvBmCwhIM7K7rGLABqa7+gchn/yPOAcpkmL7NigqA8=; b=ezwqXbTuHcx2SoP6p0p48NNCsKw+Hc9LldJU6vTrC4EeJlM6lVZO2s8+218tT2Zc7Gv69uSshiX8p/OoVTZ86posGeHuz3U8Muz2oDQPu1mfnoGGhAdIEiYdblvyySxjuWkVCqieeR41hRA+bNma3dGzPi8O4/+EMoNQpEYJbE4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612284998193330.3121194864891; Tue, 2 Feb 2021 08:56:38 -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-188-jx1W8Ou5P_SBliIFOBQYWQ-1; Tue, 02 Feb 2021 11:56:34 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4008910CE782; Tue, 2 Feb 2021 16:56:29 +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 1984A10016DB; Tue, 2 Feb 2021 16:56:29 +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 D45F450040; Tue, 2 Feb 2021 16:56:28 +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 112GuHTQ014884 for ; Tue, 2 Feb 2021 11:56:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id E73EA6E510; Tue, 2 Feb 2021 16:56:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4940560862 for ; Tue, 2 Feb 2021 16:56:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612284997; 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=nDvBmCwhIM7K7rGLABqa7+gchn/yPOAcpkmL7NigqA8=; b=R2FeelR30cTjUO1w518ldtQc/KvqXeyQR56PFttFL4l9MxmSXtLoll0S4bmKO/bK9zN3rI VK3nfhf04bHI3zzB6K+/DGRt/dMw7hUMSAzYw7ysZyOyjyFKeaG+9qXRfyS1M1etMgOUgT BBepovrn5U6qz3kQwOIBfFxLneIvVHc= X-MC-Unique: jx1W8Ou5P_SBliIFOBQYWQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 03/27] qemuDomainMasterKeyCreate: Don't use VIR_DISPOSE_N on failure Date: Tue, 2 Feb 2021 17:55:40 +0100 Message-Id: <140ebdffd46cfa13107cd263b393fd0a68ab242e.1612284661.git.pkrempa@redhat.com> 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.84 on 10.5.11.22 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" When virRandomBytes fails we don't get any random bytes and even if we did they don't have to be treated as secret as they weren't used in any way. Add a temporary variable with automatic freeing for the secret buffer and assign it only on success. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_domain.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0c078a9388..2c34307c82 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -562,18 +562,19 @@ int qemuDomainMasterKeyCreate(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + g_autofree uint8_t *key =3D NULL; /* If we don't have the capability, then do nothing. */ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET)) return 0; - priv->masterKey =3D g_new0(uint8_t, QEMU_DOMAIN_MASTER_KEY_LEN); - priv->masterKeyLen =3D QEMU_DOMAIN_MASTER_KEY_LEN; + key =3D g_new0(uint8_t, QEMU_DOMAIN_MASTER_KEY_LEN); - if (virRandomBytes(priv->masterKey, priv->masterKeyLen) < 0) { - VIR_DISPOSE_N(priv->masterKey, priv->masterKeyLen); + if (virRandomBytes(key, QEMU_DOMAIN_MASTER_KEY_LEN) < 0) return -1; - } + + priv->masterKey =3D g_steal_pointer(&key); + priv->masterKeyLen =3D QEMU_DOMAIN_MASTER_KEY_LEN; return 0; } --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285085; cv=none; d=zohomail.com; s=zohoarc; b=fYErnpJ1Jkw8vQZO7/1lJPIj7vDeYrP+0fINnRCjxcaHkhDIIw9kFnu6g8aq9TJRhYowDhLAqa3HRgpZUa+S6sAa3wgZgUXeM6hVF8Gj97SKI3Tn7RBYWr80PVDuUodnG7Ju9KAIbH2u1cB65O3uwKIJatCSL+x4ieON8U2BtLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285085; 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=R4rwiMdFXr7UYxZURDFo4AyF5SexOi7Kk9T8OmFFtTY=; b=aoGL/aFwTQhYhISCwCcJyWlCBrZaG6TYFGkc8pNqX55i3y1xlJ8aenihhAxYohfeZpJD6T468qJXum2BHtlVf2cVemf/Y+Wo1V8TSbBeW84hgEmomiTz7u9eXUoohRQahqRV0ffA0WPjnoSulWbbnK+bllMY+aFpA9tEllnAieg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612285085564829.7705991213764; Tue, 2 Feb 2021 08:58:05 -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-352-_JCYB-8qM3SmwnTz8JA-7g-1; Tue, 02 Feb 2021 11:56:39 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20008195D56B; Tue, 2 Feb 2021 16:56:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F18096F442; Tue, 2 Feb 2021 16:56:31 +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 BA1BF18089C9; Tue, 2 Feb 2021 16:56:31 +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 112GuIhP014892 for ; Tue, 2 Feb 2021 11:56:18 -0500 Received: by smtp.corp.redhat.com (Postfix) id EA0336E510; Tue, 2 Feb 2021 16:56:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56CCE60862 for ; Tue, 2 Feb 2021 16:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285084; 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=R4rwiMdFXr7UYxZURDFo4AyF5SexOi7Kk9T8OmFFtTY=; b=KrpGMUT7SMzLGKrLfwkSrBDCB+CbauZAxPRWjlMs0DG99aey/R292Am22ftuUnk7cMaKmd jWvedqNVK8BDuHOGE9SGNi7rVzDuTXEAcQhMU0ZJWb9dGNbcTmaK7jtD0gJIzG6UrpROby x38j+hMSfItTu8eBOkh2STDwV5craO8= X-MC-Unique: _JCYB-8qM3SmwnTz8JA-7g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 04/27] cmdSecretSetValue: Make it obvious that --file, --base64 and --interactive are exlcusive Date: Tue, 2 Feb 2021 17:55:41 +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.11 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" Convert the conditions to else if so that it's obvious that only one of the cases will ever be used. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- tools/virsh-secret.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 16accc8ad2..5d656151e8 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -225,16 +225,10 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "file", &filename) < 0) return false; - if (!base64 && !filename && !interactive) { - vshError(ctl, _("Input secret value is missing")); - return false; - } - - /* warn users that the --base64 option passed from command line is wro= ng */ - if (base64) + if (base64) { + /* warn users that the --base64 option passed from command line is= wrong */ vshError(ctl, _("Passing secret value as command-line argument is = insecure!")); - - if (filename) { + } else if (filename) { ssize_t read_ret; if ((read_ret =3D virFileReadAll(filename, 1024, &file_buf)) < 0) { vshSaveLibvirtError(); @@ -243,9 +237,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) file_len =3D read_ret; base64 =3D file_buf; - } - - if (interactive) { + } else if (interactive) { vshPrint(ctl, "%s", _("Enter new value for secret:")); fflush(stdout); @@ -255,6 +247,9 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) } file_len =3D strlen(file_buf); plain =3D true; + } else { + vshError(ctl, _("Input secret value is missing")); + return false; } if (plain) { --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612284992; cv=none; d=zohomail.com; s=zohoarc; b=fJj2fQsJMBRIldtPtTRk8HbLrTmsYXJjD6KTaGobdedkN6gFTpYNhbFhkOwQJ/l02Ax+3DGlMMyO6F6fswwteQQ5hLXYOrdJ7R7F0cTF7ORY52RE9YHCGTyvvorpSOXzO36aZshJJt+yXRtukrN1YpuZN6xLiuiMdViBkYfPpjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612284992; 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=1oaNLbsmnmgEDaOsBOjwNEAy3Aq3N9aZYkWUK583H68=; b=bxBMCqNNqU7dRoHr6w1RNeVfTOvlVVNhjGXA+nn93pGytsp1bYx0xirnXOuvEiKEPVXpPaRn9szVmb6VY9skazUfJNhVpA7t+oLnZwNFUS115bS/tFTW3e53kdO3n/TzbqWQKGYBOJr+nz4qXJ/9fVb0l9EwlA9mRkBDWiYtFl8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612284992890746.9386258386131; Tue, 2 Feb 2021 08:56:32 -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-491-axN_jVX9Os25fnEyeZv6hA-1; Tue, 02 Feb 2021 11:56:28 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 502828710F6; Tue, 2 Feb 2021 16:56:22 +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 220E654564; Tue, 2 Feb 2021 16:56:22 +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 DDFDE5003E; Tue, 2 Feb 2021 16:56:21 +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 112GuKIM014897 for ; Tue, 2 Feb 2021 11:56:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 03F716E510; Tue, 2 Feb 2021 16:56:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B9DC60862 for ; Tue, 2 Feb 2021 16:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612284991; 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=1oaNLbsmnmgEDaOsBOjwNEAy3Aq3N9aZYkWUK583H68=; b=KL1P/6dQYRxxw6lEjIkGO82JW+EjqQrcDl5ccwtSLIm8Sr6zzuuTXzd1r0FA+81x3Zfn9i gudrQcEdMy7MJ11vixHLhBjW49uTAb1BMY8dndml9SMyMQy//b3EsQJI1ulJVVyByhOhL6 U2/5eeOLLmK7TdgqtO+FFMlbfALFcz4= X-MC-Unique: axN_jVX9Os25fnEyeZv6hA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 05/27] virNetLibsshSessionAuthAddPrivKeyAuth: Don't unlock unlocked 'sess' on error Date: Tue, 2 Feb 2021 17:55:42 +0100 Message-Id: <81a0c902a458c03296c9c9005a2171050b874b66.1612284661.git.pkrempa@redhat.com> 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.15 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" The check whether @keyfile is non-NULL is before locking @sess, but uses the 'error' label which unlocks '@sess'. While touching the error path, update the error message to be on one line. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/rpc/virnetlibsshsession.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 959a16a6a9..ed697c7ce4 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -1020,10 +1020,8 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSe= ssionPtr sess, if (!keyfile) { virReportError(VIR_ERR_LIBSSH, "%s", - _("Key file path must be provided " - "for private key authentication")); - ret =3D -1; - goto error; + _("Key file path must be provided for private key a= uthentication")); + return -1; } virObjectLock(sess); --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285006; cv=none; d=zohomail.com; s=zohoarc; b=Hj1jWicRisuAXBC5ot+6oKHg9ptNH76A/phwLNsNZ8r/bQcECBRZXrK2GzoNlf6HtTLcXJanH8iRIYZ3Ij7GMOqBvly8p41zByBx6bGn/gX0kq3+H7WL8XM/zMiJ6guTkPW2sMul09FeRKbBh4YPkdEXwQ/0OXVMCp4WS8yDxG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285006; 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=oi9jb9auUd5bchyD22SAxZEBtXIkVxjEBPAKu0WTTno=; b=G7JlR68fZSBGsBt6RfEteRMfd82lr0inENy3J2evTFo+dRHz+oBmbKRmXf0ZLmGyRJ0Tgbnl1tZAWlnTaGxTcEfv7nACss17HXN7ULrFZQ3HwB4Q9LwP8PUCJm9bz1finNG06rrjdqK1Joq4NOtnlw3z6IZ3t/h7T4H76fobAUw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612285006933618.6397878822141; Tue, 2 Feb 2021 08:56:46 -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-45-ax2HE-NIOiaYuW4RVGMT1Q-1; Tue, 02 Feb 2021 11:56:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB191107ACFA; Tue, 2 Feb 2021 16:56:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B87245D722; Tue, 2 Feb 2021 16:56:34 +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 81B111809C92; Tue, 2 Feb 2021 16:56:34 +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 112GuL26014917 for ; Tue, 2 Feb 2021 11:56:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 16C5460862; Tue, 2 Feb 2021 16:56:21 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B7786EF45 for ; Tue, 2 Feb 2021 16:56:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285005; 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=oi9jb9auUd5bchyD22SAxZEBtXIkVxjEBPAKu0WTTno=; b=LTSfDpV1JlSCtIswGEQXtXZn26cg/PpaugGNOzthA5ioT2p5opxyU/DIWzmognjp4u2AUI zXeEhKz8JkpjmnbG8VzBJvP9U2rY2uVGZ76bFG0GIdc/OZVlaYnuoxt3PlI7uIcnoa1vtn j7i7IGtlWHQYb3fgdo7sD8h3KStIQI4= X-MC-Unique: ax2HE-NIOiaYuW4RVGMT1Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 06/27] virNetLibsshSessionAuthAddPrivKeyAuth: Refactor cleanup Date: Tue, 2 Feb 2021 17:55:43 +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.15 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" Shuffle the code around to remove the need for temporary variables and labels for cleaning them. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/rpc/virnetlibsshsession.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index ed697c7ce4..9671a0f98d 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -1013,10 +1013,7 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshSe= ssionPtr sess, const char *keyfile, const char *password) { - int ret; virNetLibsshAuthMethodPtr auth; - VIR_AUTODISPOSE_STR pass =3D NULL; - char *file =3D NULL; if (!keyfile) { virReportError(VIR_ERR_LIBSSH, "%s", @@ -1026,28 +1023,18 @@ virNetLibsshSessionAuthAddPrivKeyAuth(virNetLibsshS= essionPtr sess, virObjectLock(sess); - file =3D g_strdup(keyfile); - pass =3D g_strdup(password); - if (!(auth =3D virNetLibsshSessionAuthMethodNew(sess))) { - ret =3D -1; - goto error; + virObjectUnlock(sess); + return -1; } - auth->password =3D g_steal_pointer(&pass); - auth->filename =3D file; + auth->password =3D g_strdup(password); + auth->filename =3D g_strdup(keyfile); auth->method =3D VIR_NET_LIBSSH_AUTH_PRIVKEY; auth->ssh_flags =3D SSH_AUTH_METHOD_PUBLICKEY; - ret =3D 0; - - cleanup: virObjectUnlock(sess); - return ret; - - error: - VIR_FREE(file); - goto cleanup; + return 0; } int --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285149; cv=none; d=zohomail.com; s=zohoarc; b=i81obVfFpChmxxI1oABzR7zezKGsrmXNvdDYjGCqnfnetrXBu8nUWvvFlDPsqZ1d64sjYrcQOf5T7nGv1JF4b/Cnfh+eNeu4dsbBmFoRnoHkM97QVpUlH3C1KLjc7h7USVIXb1gwMOXGDl48UbRnpDEq9TN/SjxEvS9S0mHRHFE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285149; 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=kd8eU1mM55dLH5zyNC8CbUdvvHxPVgVWu1t6A1tXES8=; b=F53OzAG8QklyHY5RwhJGuhn4b9veJKk7fQpdBSTNU6lb3Kt6ymkoBzBl3ZlauQXwzVTXFCuFp/4BA1GiMqvvk1JgsvYiVCz9KvWsPJAjcUIADeUL9JPeOx2XVyPJSFcSf+OiVg/MHTcuVuCQscvqpvc2SXdDNcR7hYH2BdfqY+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 161228514963569.4558020054152; Tue, 2 Feb 2021 08:59:09 -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-355-TrRotNG0N7aeQ5XgKfJyIw-1; Tue, 02 Feb 2021 11:56:44 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B8C78CE642; Tue, 2 Feb 2021 16:56:37 +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 9606D5D749; Tue, 2 Feb 2021 16:56:37 +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 5E4055003D; Tue, 2 Feb 2021 16:56:37 +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 112GuOsb014932 for ; Tue, 2 Feb 2021 11:56:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 636186EF41; Tue, 2 Feb 2021 16:56:24 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id C007F6E510 for ; Tue, 2 Feb 2021 16:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285148; 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=kd8eU1mM55dLH5zyNC8CbUdvvHxPVgVWu1t6A1tXES8=; b=Ufge0RB5WLhKPhNBa/g3SKQJEf4kxfCoNqJQGDBzmi3hJyQNepjDxwZbh7VENQWWKfof4+ h+Q1v8YCdxoppwoG4H/pAbHeLLLrBkVCHyre4/Zs/fq/mhbD3seoLfu2/bI+kJBbaBb48t ekSI95AiaTMAfYBs45VbVcZ+REJDFOg= X-MC-Unique: TrRotNG0N7aeQ5XgKfJyIw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 07/27] util: Introduce virsecureerase module Date: Tue, 2 Feb 2021 17:55:44 +0100 Message-Id: <7a1864a4c10d1f5b97f957483095695ba42c6ada.1612284661.git.pkrempa@redhat.com> 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.15 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" The module will provide functions for disposing secrets stored in memory. Note that for now it's implemented using memset, which is not really secure. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libvirt_private.syms | 4 ++++ src/util/meson.build | 1 + src/util/virsecureerase.c | 44 +++++++++++++++++++++++++++++++++++++++ src/util/virsecureerase.h | 25 ++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 src/util/virsecureerase.c create mode 100644 src/util/virsecureerase.h diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8138780237..fa0c0887e9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3175,6 +3175,10 @@ virSecretLookupFormatSecret; virSecretLookupParseSecret; +# util/virsecureerase.h +virSecureErase; + + # util/virsocket.h virSocketRecvFD; virSocketSendFD; diff --git a/src/util/meson.build b/src/util/meson.build index c077c5cc99..e89d32c33d 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -86,6 +86,7 @@ util_sources =3D [ 'virscsivhost.c', 'virseclabel.c', 'virsecret.c', + 'virsecureerase.c', 'virsocket.c', 'virsocketaddr.c', 'virstoragefile.c', diff --git a/src/util/virsecureerase.c b/src/util/virsecureerase.c new file mode 100644 index 0000000000..1dc3bb476a --- /dev/null +++ b/src/util/virsecureerase.c @@ -0,0 +1,44 @@ +/* + * virsecureerase.c: Secure clearing of memory + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#include + +#include "virsecureerase.h" + +/** + * virSecureErase: + * @ptr: pointer to memory to clear + * @size: size of memory to clear + * + * Clear @size bytes of memory at @ptr. + * + * Note that for now this is implemented using memset which is not secure = as + * it can be optimized out. + * + * Also note that there are possible leftover direct uses of memset. + */ +void +virSecureErase(void *ptr, + size_t size) +{ + if (!ptr || size =3D=3D 0) + return; + + memset(ptr, 0, size); +} diff --git a/src/util/virsecureerase.h b/src/util/virsecureerase.h new file mode 100644 index 0000000000..66d7e28e8a --- /dev/null +++ b/src/util/virsecureerase.h @@ -0,0 +1,25 @@ +/* + * virsecureerase.h: Secure clearing of memory + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + */ + +#pragma once + +#include "internal.h" + +void +virSecureErase(void *ptr, size_t size); --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612284998; cv=none; d=zohomail.com; s=zohoarc; b=RrDTTPuYBIJBuHm0ao5rOsW6zrMJmplAM2nDIzr4Cffbw2UojsIyqI3vPHaM/qysW+9r3bPXDBo0hqZUlB7v0As0KtnSprLCW6pntdRxLvwGSVDSAexujPP3yLtyNUTROlU5rtZMGS66Ze7Oftp/9+vEnRh6ZPtgNXstmD4Z3HY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612284998; 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=CjUGsDhE1uku7K+6FZPycOh1shlCNn4t8BHDRdwztN8=; b=geUtgWz3sgUey23ryvXiVp7nbaD5u9m+Mk8RZCCXfJaXeD5wZTsZYuKqSfQfQN4ObB+3WyEG9ySwzWBpO74pk6Xxe/AZh5YMm41LXwA1T6RHphDCEQPLwcNpDnlj0CO8/XbRUpiVGv06+kY16vtcFFbQnGkGstG1ZMaRqmiAjUU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 16122849987991002.1309082884434; Tue, 2 Feb 2021 08:56:38 -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-294-YGcMj3M4PwCfL787Yvg_lQ-1; Tue, 02 Feb 2021 11:56:35 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73B96CE646; Tue, 2 Feb 2021 16:56:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 295B55D749; Tue, 2 Feb 2021 16:56:29 +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 E24A11809C90; Tue, 2 Feb 2021 16:56:28 +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 112GuRZ8014943 for ; Tue, 2 Feb 2021 11:56:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id C2CB26EF41; Tue, 2 Feb 2021 16:56:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEE8E6E510 for ; Tue, 2 Feb 2021 16:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612284997; 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=CjUGsDhE1uku7K+6FZPycOh1shlCNn4t8BHDRdwztN8=; b=B8rCm6JimMCHZSo/tvKyuaqdX3xM0TXFG1wpEzK5+WYKXBH+QW1SFE4OtsEi6HOpS4uunl lIRTpMR6+6/D/kx9a2r2oMIM8wlaRKEwm34oKZT5Na0WWLnRH9xFnoXjNd78sEHAHzCccq ZCPXxMHGbQR/d4kWy/iAJ8OqG9SiGeU= X-MC-Unique: YGcMj3M4PwCfL787Yvg_lQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 08/27] virsh: cmdSecretSetValue: Rework handling of the secret value Date: Tue, 2 Feb 2021 17:55:45 +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.15 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" Use a single buffer for the secret to make it easier to follow it's lifecycle. For base64 decoding use a local temporary buffer which will be cleared right away. This also uses virSecureErase for clearing the bufer instead of VIR_DISPOSE_N which is being phased out. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- tools/virsh-secret.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 5d656151e8..e413af893f 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -31,6 +31,7 @@ #include "virtime.h" #include "vsh-table.h" #include "virenum.h" +#include "virsecureerase.h" static virSecretPtr virshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **nam= e) @@ -202,10 +203,8 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshSecret) secret =3D NULL; const char *base64 =3D NULL; const char *filename =3D NULL; - char *file_buf =3D NULL; - size_t file_len =3D 0; - unsigned char *value; - size_t value_size; + g_autofree char *secret_val =3D NULL; + size_t secret_len =3D 0; bool plain =3D vshCommandOptBool(cmd, "plain"); bool interactive =3D vshCommandOptBool(cmd, "interactive"); int res; @@ -228,41 +227,41 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd) if (base64) { /* warn users that the --base64 option passed from command line is= wrong */ vshError(ctl, _("Passing secret value as command-line argument is = insecure!")); + secret_val =3D g_strdup(base64); + secret_len =3D strlen(secret_val); } else if (filename) { ssize_t read_ret; - if ((read_ret =3D virFileReadAll(filename, 1024, &file_buf)) < 0) { + if ((read_ret =3D virFileReadAll(filename, 1024, &secret_val)) < 0= ) { vshSaveLibvirtError(); return false; } - file_len =3D read_ret; - base64 =3D file_buf; + secret_len =3D read_ret; } else if (interactive) { vshPrint(ctl, "%s", _("Enter new value for secret:")); fflush(stdout); - if (!(file_buf =3D virGetPassword())) { + if (!(secret_val =3D virGetPassword())) { vshError(ctl, "%s", _("Failed to read secret")); return false; } - file_len =3D strlen(file_buf); + secret_len =3D strlen(secret_val); plain =3D true; } else { vshError(ctl, _("Input secret value is missing")); return false; } - if (plain) { - value =3D g_steal_pointer(&file_buf); - value_size =3D file_len; - file_len =3D 0; - } else { - value =3D g_base64_decode(base64, &value_size); + if (!plain) { + g_autofree char *tmp =3D g_steal_pointer(&secret_val); + size_t tmp_len =3D secret_len; + + secret_val =3D (char *) g_base64_decode(tmp, &secret_len); + virSecureErase(tmp, tmp_len); } - res =3D virSecretSetValue(secret, value, value_size, 0); - VIR_DISPOSE_N(value, value_size); - VIR_DISPOSE_N(file_buf, file_len); + res =3D virSecretSetValue(secret, (unsigned char *) secret_val, secret= _len, 0); + virSecureErase(secret_val, secret_len); if (res !=3D 0) { vshError(ctl, "%s", _("Failed to set secret value")); --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 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=1612285027; cv=none; d=zohomail.com; s=zohoarc; b=E/MZ1FJxSFhPc7o2JLs1JErH31ERcwkLkf9ayWW2SAQlBihu6/hgS2I7E2EqpZ8B5wArStVKDZZ8X5wXcyTZ+vvU/aRrRiyf860FOh9pmUmtQFh3jexvPTCWWMoaWjVKzELPbYKBNrn/WswPOpKs8eNqxYpV8fE/yRPiccYWSKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285027; 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=jKc6wQ/94Wvi07bxmPn9XGfQpGluWWgwqtlrdh0L82E=; b=oHWmPZoSHL5aK0woKgiGwfsvC2g3iQ7dzTsGCx3ZIaSvQA5RggUag4Kdo7VJpXzXmMm4SbFQnttSCajThsKbVeX4jk7p2898jt9aD8lSsx8ddrqOOqgL0nZvy4maP7sJZjB6+UzAGx1cq51Ixx+tiFk2oWC5cDljNkrAXwyveZc= 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 161228502718422.22232387228462; Tue, 2 Feb 2021 08:57:07 -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-418-hSo5wxc2OeSz4JI1L53NWw-1; Tue, 02 Feb 2021 11:56:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7FC6E107ACF5; Tue, 2 Feb 2021 16:56:36 +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 587076EF46; Tue, 2 Feb 2021 16:56:36 +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 E623450043; Tue, 2 Feb 2021 16:56:35 +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 112GuZu7014970 for ; Tue, 2 Feb 2021 11:56:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3963B6EF53; Tue, 2 Feb 2021 16:56:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00F0E6EF46 for ; Tue, 2 Feb 2021 16:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285026; 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=jKc6wQ/94Wvi07bxmPn9XGfQpGluWWgwqtlrdh0L82E=; b=ex5wMVPb+4i9H7brY+R4jd2SquCJaEnbYXleBDLx35Yac8KtbfsPf7qbxnC21tFQcsz46W 0sFIhTzwRpQZNdY1Gczs0BGer62c/H887K70AcmhrrWsSFPYx//HDd/kZCurVRyLJsUE7R jtVoEQOmEzDFzXBUrrIipFqzDbKtrDE= X-MC-Unique: hSo5wxc2OeSz4JI1L53NWw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 09/27] storage_backend_iscsi(_direct): Properly clear secrets Date: Tue, 2 Feb 2021 17:55:46 +0100 Message-Id: <7952da880f9836e35040f0fd4790522e6b7ed479.1612284661.git.pkrempa@redhat.com> 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.13 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" The code pretends that it cares about clearing the secret values, but passes the secret value to a realloc, which may copy the value somewhere else and doesn't sanitize the original location when it does so. Since we want to construct a string from the value, let's copy it to a new piece of memory which has the space for the 'NUL' byte ourselves, to prevent a random realloc keeping the data around. While at it, use virSecureErase instead of VIR_DISPOSE_N since it's being phased out. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_backend_iscsi.c | 16 +++++++++------- src/storage/storage_backend_iscsi_direct.c | 17 +++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index 45167e4490..9127d663b1 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -41,6 +41,7 @@ #include "virsecret.h" #include "storage_util.h" #include "virutil.h" +#include "virsecureerase.h" #define VIR_FROM_THIS VIR_FROM_STORAGE @@ -256,8 +257,9 @@ static int virStorageBackendISCSISetAuth(const char *portal, virStoragePoolSourcePtr source) { - unsigned char *secret_value =3D NULL; + g_autofree unsigned char *secret_value =3D NULL; size_t secret_size; + g_autofree char *secret_str =3D NULL; virStorageAuthDefPtr authdef =3D source->auth; int ret =3D -1; virConnectPtr conn =3D NULL; @@ -282,10 +284,10 @@ virStorageBackendISCSISetAuth(const char *portal, &secret_value, &secret_size) < 0) goto cleanup; - if (VIR_REALLOC_N(secret_value, secret_size + 1) < 0) - goto cleanup; - - secret_value[secret_size] =3D '\0'; + secret_str =3D g_new0(char, secret_size + 1); + memcpy(secret_str, secret_value, secret_size); + virSecureErase(secret_value, secret_size); + secret_str[secret_size] =3D '\0'; if (virISCSINodeUpdate(portal, source->devices[0].path, @@ -298,13 +300,13 @@ virStorageBackendISCSISetAuth(const char *portal, virISCSINodeUpdate(portal, source->devices[0].path, "node.session.auth.password", - (const char *)secret_value) < 0) + secret_str) < 0) goto cleanup; ret =3D 0; cleanup: - VIR_DISPOSE_N(secret_value, secret_size); + virSecureErase(secret_str, secret_size); virObjectUnref(conn); return ret; } diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/stora= ge_backend_iscsi_direct.c index 12b075db0b..78b12f057f 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -87,8 +87,9 @@ static int virStorageBackendISCSIDirectSetAuth(struct iscsi_context *iscsi, virStoragePoolSourcePtr source) { - unsigned char *secret_value =3D NULL; + g_autofree unsigned char *secret_value =3D NULL; size_t secret_size; + g_autofree char *secret_str =3D NULL; virStorageAuthDefPtr authdef =3D source->auth; int ret =3D -1; virConnectPtr conn =3D NULL; @@ -113,14 +114,13 @@ virStorageBackendISCSIDirectSetAuth(struct iscsi_cont= ext *iscsi, &secret_value, &secret_size) < 0) goto cleanup; - if (VIR_REALLOC_N(secret_value, secret_size + 1) < 0) - goto cleanup; - - secret_value[secret_size] =3D '\0'; + secret_str =3D g_new0(char, secret_size + 1); + memcpy(secret_str, secret_value, secret_size); + memset(secret_value, 0, secret_size); + secret_str[secret_size] =3D '\0'; if (iscsi_set_initiator_username_pwd(iscsi, - authdef->username, - (const char *)secret_value) < 0) { + authdef->username, secret_str) < = 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to set credential: %s"), iscsi_get_error(iscsi)); @@ -129,7 +129,8 @@ virStorageBackendISCSIDirectSetAuth(struct iscsi_contex= t *iscsi, ret =3D 0; cleanup: - VIR_DISPOSE_N(secret_value, secret_size); + if (secret_str) + memset(secret_str, 0, secret_size); virObjectUnref(conn); return ret; } --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285150; cv=none; d=zohomail.com; s=zohoarc; b=TyDGfzADramoqO7F3v+IsvXdzo51g5XatI68+/wPd0Be1ZqFDKyTWO7jQNieqIlqnSBAY6lkX+w53xWa1Zx3OSsLxUkdPbjejilvdDxG0aG6md2wZkTp5j1sn35s1US2qYvmBkzjxwV7fPAO4rheD64EZ4ESAaqx9IE9PRsf1mY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285150; 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=J8kpIPE5d+tOerHbDqqldAcuuZ7vDUNGzFxIkzzps6Y=; b=Jp9D9ah+yLTJv1rKal8+nfdr/HTVk1AQ+LQcT2xyPT6gOUQ55F+7CeWAXHzFd1LbBilmsXsFX6a9PmblJJXxi3V94X7k9lS8XuErQQiLrw1oHytDF+zFlpUJn/SrC89hGvZbxQyCHY+g9t4TujPwGH7RZmml4yXELVV7a9qcky4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612285150272707.0146148106526; Tue, 2 Feb 2021 08:59:10 -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-23-GX-MSjIjPx20MNwenyqepQ-1; Tue, 02 Feb 2021 11:56:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7D731800D50; Tue, 2 Feb 2021 16:56:41 +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 8635D6E510; Tue, 2 Feb 2021 16:56:41 +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 4D84850040; Tue, 2 Feb 2021 16:56:41 +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 112GueqY015007 for ; Tue, 2 Feb 2021 11:56:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 45A316EF50; Tue, 2 Feb 2021 16:56:40 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C2706E510 for ; Tue, 2 Feb 2021 16:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285149; 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=J8kpIPE5d+tOerHbDqqldAcuuZ7vDUNGzFxIkzzps6Y=; b=HBPMbIu0qA2yLRjvy2dMyEY0lH0EVbAUosccyELCbWcxpu4yuoT+pK2Os+8A/BDdiDTzM2 WpU8iexbw8NvIszAOFMtStME91kWCGSVOGQaG/JklhckvfH+6Ct8mIE7ZVV2H6lSH2SIPz 5TjexX8+X4Hg/p/aIMbey6450KAfpVU= X-MC-Unique: GX-MSjIjPx20MNwenyqepQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 10/27] libxlMakeNetworkDiskSrc: Avoid use of VIR_DISPOSE_N Date: Tue, 2 Feb 2021 17:55:47 +0100 Message-Id: <5dcd97a624b06a93518ba467a2b0bed0791d98e0.1612284661.git.pkrempa@redhat.com> 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.13 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" Clear the secret right after use with virSecureErase. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libxl/libxl_conf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index cb1fd7df7d..694192e1c3 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -46,6 +46,7 @@ #include "xen_xl.h" #include "virnetdevvportprofile.h" #include "virenum.h" +#include "virsecureerase.h" #define VIR_FROM_THIS VIR_FROM_LIBXL @@ -998,14 +999,15 @@ static int libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr) { virConnectPtr conn =3D NULL; - uint8_t *secret =3D NULL; VIR_AUTODISPOSE_STR base64secret =3D NULL; - size_t secretlen =3D 0; char *username =3D NULL; int ret =3D -1; *srcstr =3D NULL; if (src->auth && src->protocol =3D=3D VIR_STORAGE_NET_PROTOCOL_RBD) { + g_autofree uint8_t *secret =3D NULL; + size_t secretlen =3D 0; + username =3D src->auth->username; if (!(conn =3D virConnectOpen("xen:///system"))) goto cleanup; @@ -1017,6 +1019,7 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char= **srcstr) /* RBD expects an encoded secret */ base64secret =3D g_base64_encode(secret, secretlen); + virSecureErase(secret, secretlen); } if (!(*srcstr =3D libxlMakeNetworkDiskSrcStr(src, username, base64secr= et))) @@ -1025,7 +1028,6 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char= **srcstr) ret =3D 0; cleanup: - VIR_DISPOSE_N(secret, secretlen); virObjectUnref(conn); return ret; } --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 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 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285017; cv=none; d=zohomail.com; s=zohoarc; b=JYe4BmYuqll6g/mnJJBqgbUWhK/hHDTEvvKeAUAN7GjRstw5/vS0/GAP6SHP9kRFw+dDUyvD8N6dtM3K/4ntT+65G00VXkrQoOwNkFgOWUjKrPCJHyHgbkaLLMwsKVRNlYJf+V40EIfz+Sg4CbCCLK2PgpSWvLPeB1jV1GyeQxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285017; 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=QaJL6dIU2D2mq00uPDASaW69HcspYQ3BwdEuptxgZoo=; b=IHRpinrnrCf3gc7z0gqfRqOievi3ArHDFQbg8PHnB6Hrw4DBGat3FEVG8TiRVfKGydHin0fgoiAKXpjpRdXksF3B8XbPPCB+0qAFDkWIKZ2x+bXlHVRKHwNmsxS05LRwCWVg5SJMGv+JM7vG2Pba9Qpde1RJipputmFJeQVSjYA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612285017892423.418643777645; Tue, 2 Feb 2021 08:56:57 -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-149-RfAgSsenNc6N6YR--yBI5w-1; Tue, 02 Feb 2021 11:56:54 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62A968712E3; Tue, 2 Feb 2021 16:56:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DDE15D722; Tue, 2 Feb 2021 16:56:48 +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 0627918089C9; Tue, 2 Feb 2021 16:56:48 +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 112GukKu015058 for ; Tue, 2 Feb 2021 11:56:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5C1806EF41; Tue, 2 Feb 2021 16:56:46 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 466316E510 for ; Tue, 2 Feb 2021 16:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285016; 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=QaJL6dIU2D2mq00uPDASaW69HcspYQ3BwdEuptxgZoo=; b=ajgJ41NCx/SLVnqOtiOVUfSb6L6cmKuHqjJaBhE02Ud0D5UyYQPLxFLLRYkHz+Pv0+qFWo fVw09hyXPg+avOuYVN2DyBg+2OSbmcJgSjbt++M202CGkzj8G7rKDkRqlM70NW0+CxCNuB i3hNzvz5otuUW+tqILA7BvEj4LejcKE= X-MC-Unique: RfAgSsenNc6N6YR--yBI5w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 12/27] virsh: cmdSecretGetValue: Use virSecureErase instead of VIR_DISPOSE_N Date: Tue, 2 Feb 2021 17:55:49 +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.15 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" Switch the secret value to 'g_autofree' for handling of the memory and clear it out using virSecureErase. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- tools/virsh-secret.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index e413af893f..de32f25d64 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -303,7 +303,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshSecret) secret =3D NULL; VIR_AUTODISPOSE_STR base64 =3D NULL; - unsigned char *value; + g_autofree unsigned char *value =3D NULL; size_t value_size; bool plain =3D vshCommandOptBool(cmd, "plain"); @@ -315,7 +315,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) if (plain) { if (fwrite(value, 1, value_size, stdout) !=3D value_size) { - VIR_DISPOSE_N(value, value_size); + virSecureErase(value, value_size); vshError(ctl, "failed to write secret"); return false; } @@ -325,7 +325,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%s", base64); } - VIR_DISPOSE_N(value, value_size); + virSecureErase(value, value_size); return true; } --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285111; cv=none; d=zohomail.com; s=zohoarc; b=FccwPVlfMYB2ZzV02Gmu50sW8zRlvvAujXNkGdYUVW9gZ9m2rwQuOEQE3s+IZ/2BrOoOC5NWSP4FCNog6zPqIne97imMDrOPfI6iSGS6vsUe6x+aRuW7S2PwAu4DglI6dunjdaa1uEjBpPYWr6odgmrpZ2QwGjkBwadms5xCtGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285111; 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=PhAJ0IuqxTV6hwCUNDQf5jReWU/tZGf1DxWSUFXTt/Y=; b=SPbVfPn7fOyvNreKnGjDEaAJp1kht9UeTGhp79Va633CqGmhsAF9Xajz6YIq7SJEzlFxKX27uc0dMhg8NmcFJczMX/aJaSDWMFJvNAXQyeHsB8gOajQvtOwNzk3WyBSaDYNQzjGbCvaq7K4/uxzpSIq7Z52jbl989ew2fbHBhE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612285111526228.50355709193866; Tue, 2 Feb 2021 08:58:31 -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-514-Oe1e9-iKOU6wkUNcJfURjg-1; Tue, 02 Feb 2021 11:57:01 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E7C1100A633; Tue, 2 Feb 2021 16:56:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1824977711; Tue, 2 Feb 2021 16:56:54 +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 D236918089D2; Tue, 2 Feb 2021 16:56:53 +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 112GuqYg015095 for ; Tue, 2 Feb 2021 11:56:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id C96B46EF41; Tue, 2 Feb 2021 16:56:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 596AF6E510 for ; Tue, 2 Feb 2021 16:56:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285110; 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=PhAJ0IuqxTV6hwCUNDQf5jReWU/tZGf1DxWSUFXTt/Y=; b=RBldcaPRhmqYRpOENPI5hI5MEuiPt38xPvEkV3B1wqQ7BQrIj9Y6ZH9+UrqXYMaYMrkqAA be2PdSfsT5BSiYvE1UBUvk6a0vfs2BCf7SI9P5IHocyo0jmpcNhKb8JZ55MprvzFp68c4v zQ58ALHWqC93lTS/yVXIwLlBdXuWWh0= X-MC-Unique: Oe1e9-iKOU6wkUNcJfURjg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 13/27] virStorageBackendRBDOpenRADOSConn: Use virSecureErase instead of VIR_DISPOSE_N Date: Tue, 2 Feb 2021 17:55:50 +0100 Message-Id: <72d4b3c080a82afd3fda1a23ac0335f79a27b791.1612284661.git.pkrempa@redhat.com> 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.13 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" Switch the secret value to 'g_autofree' for handling of the memory and clear it out using virSecureErase. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_backend_rbd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 22f5c78591..1f83205dfa 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -35,6 +35,7 @@ #include "rbd/librbd.h" #include "virsecret.h" #include "storage_util.h" +#include "virsecureerase.h" #define VIR_FROM_THIS VIR_FROM_STORAGE @@ -185,7 +186,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, int ret =3D -1; virStoragePoolSourcePtr source =3D &def->source; virStorageAuthDefPtr authdef =3D source->auth; - unsigned char *secret_value =3D NULL; + g_autofree unsigned char *secret_value =3D NULL; size_t secret_value_size =3D 0; VIR_AUTODISPOSE_STR rados_key =3D NULL; g_auto(virBuffer) mon_host =3D VIR_BUFFER_INITIALIZER; @@ -215,6 +216,7 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, goto cleanup; rados_key =3D g_base64_encode(secret_value, secret_value_size); + virSecureErase(secret_value, secret_value_size); if (virStorageBackendRBDRADOSConfSet(ptr->cluster, "key", rados_key) < 0) @@ -325,8 +327,6 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, ret =3D 0; cleanup: - VIR_DISPOSE_N(secret_value, secret_value_size); - virObjectUnref(conn); return ret; } --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285027; cv=none; d=zohomail.com; s=zohoarc; b=lPjA9Rjo4Ai5FAAoeloD0RnzxDn2hOBw40x0+gHFUTXnt7Qxou0ZQMuwmchlzVfxv7aKSvonW+bAZIf2mnTl56DZK2wVCnMI6SbwPWMFM6+TL7DQ4PXcQF7BlN8q7/lGufuzYBTE/AblRXeZAcr36dvZwW6oMM8BVdlI7Ffn+yA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285027; 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=NtcKgp2C+dYJAMCUEuUfLZIBnbXfkNRMJaoqWyntntM=; b=NnVVoPOaQtG1vX0VvSdZsUADhX8fgBgSHWeCFeXjO8wAsYlSY83sARby9GtZsvACU1xXkmBqCDlftLSWs0duMEeqdS9eMDpaAJpeTSD+EThPcslRpqKina+J6/Y18HYz106yM37st8NnlApmrOXmc5E6Lk2yro4D1pQOrrJp5OI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612285027112671.6173576353019; Tue, 2 Feb 2021 08:57:07 -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-428-P8S0zhF2MBmZY__4dufxEA-1; Tue, 02 Feb 2021 11:57:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 43962102C7E9; Tue, 2 Feb 2021 16:56:58 +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 1DBCF62A02; Tue, 2 Feb 2021 16:56:58 +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 D9FD35003E; Tue, 2 Feb 2021 16:56:57 +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 112GuuGf015122 for ; Tue, 2 Feb 2021 11:56:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 46B966E510; Tue, 2 Feb 2021 16:56:56 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C90B779D0 for ; Tue, 2 Feb 2021 16:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285026; 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=NtcKgp2C+dYJAMCUEuUfLZIBnbXfkNRMJaoqWyntntM=; b=hThUGGQgEGrKUIS/35tZvijrZ9+TWropCyIIQcBKqX4MqB4NenAF88cMdyYJkUBh6vcH+h z2k1bVzKyacci/jSA3nXxw9cFyzJ/YlMEcwWNVPSXNvI7TVYRJD7glZlTCSBq6DvtIjBWm IeJ1vWb+7NAFfnoWUZ8fX7FQoUSV+Yc= X-MC-Unique: P8S0zhF2MBmZY__4dufxEA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 14/27] virCryptoEncryptDataAESgnutls: Use virSecureErase instead of VIR_DISPOSE_N Date: Tue, 2 Feb 2021 17:55:51 +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.15 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" Clear out the value using virSecureErase and free it with g_free so that VIR_DISPOSE_N can be phased out. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/vircrypto.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c index c4874550af..d2a42d83e2 100644 --- a/src/util/vircrypto.c +++ b/src/util/vircrypto.c @@ -25,6 +25,7 @@ #include "virerror.h" #include "viralloc.h" #include "virrandom.h" +#include "virsecureerase.h" #include #include @@ -206,7 +207,8 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t= gnutls_enc_alg, return 0; error: - VIR_DISPOSE_N(ciphertext, ciphertextlen); + virSecureErase(ciphertext, ciphertextlen); + g_free(ciphertext); memset(&enc_key, 0, sizeof(gnutls_datum_t)); memset(&iv_buf, 0, sizeof(gnutls_datum_t)); return -1; --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285033; cv=none; d=zohomail.com; s=zohoarc; b=Yu8SBIW+SjoQHPUd1R8F4QIBFbtRoxwxh+4uNAYkkWBrjGK7VwOkxMaac5CYZUOASZmLNp6N0pd5L1isMKymNEaw4aca/Vblz9YZuesU+/OQzPRDPo+9xaVCEVaH8UXD/oBvOuJ6YMH5uVNfCL3YkBEUcd51RrAK4gHmqwa0Td8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285033; 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=DM+jqvi/tLI4n1M0pAcZkdKdZcLftad7rJQVn0MhPqw=; b=EjDUT/aew9lRTOFGwAuX1D4zU0ZCKr+6a+bd+nxiFgIRUquOCHQoR4g2pPlax6D7Fazx991s5uNHphF//0Og6Fo8DYT1ZqJERPrmzLIGuQ/1XC66FCkjCpdBbnboOEPu1x9Bf40FitcYhOth7Jws0j4LA5IeINJgKoRxJ11HI1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612285033039628.6469131965483; Tue, 2 Feb 2021 08:57:13 -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-225-3IMuR8WmPU6QhprveeSyow-1; Tue, 02 Feb 2021 11:57:08 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47737DBBF; Tue, 2 Feb 2021 16:57:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25FED5D9C6; Tue, 2 Feb 2021 16:57:02 +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 E564618089D9; Tue, 2 Feb 2021 16:57:01 +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 112Gv03C015135 for ; Tue, 2 Feb 2021 11:57:00 -0500 Received: by smtp.corp.redhat.com (Postfix) id 18C346EF50; Tue, 2 Feb 2021 16:57:00 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFF0C6EF46 for ; Tue, 2 Feb 2021 16:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285032; 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=DM+jqvi/tLI4n1M0pAcZkdKdZcLftad7rJQVn0MhPqw=; b=eKLLh0oBP2Ebt/hXGg0E+8qr1wTwyx48kfk4csy7dDzv0DEpM3FX77nXl11FR6fBsGN1pw mWzoS9PbFKu57MzEXQtzf7Iyy1fjfbQD4YF8z/gkYuNb8+hFBdXFgFfP4uXkXNQ3WJMmcs kqmqPW/DRC4J2E57aYujDu+YTnYU8mM= X-MC-Unique: 3IMuR8WmPU6QhprveeSyow-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 15/27] virCryptoEncryptDataAESgnutls: Use virSecureErase instead of memset Date: Tue, 2 Feb 2021 17:55:52 +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.14 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" Clear the key and IV structs using virSecureErase. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/vircrypto.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c index d2a42d83e2..78689721c3 100644 --- a/src/util/vircrypto.c +++ b/src/util/vircrypto.c @@ -193,8 +193,8 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t= gnutls_enc_alg, /* Encrypt the data and free the memory for cipher operations */ rc =3D gnutls_cipher_encrypt(handle, ciphertext, ciphertextlen); gnutls_cipher_deinit(handle); - memset(&enc_key, 0, sizeof(gnutls_datum_t)); - memset(&iv_buf, 0, sizeof(gnutls_datum_t)); + virSecureErase(&enc_key, sizeof(gnutls_datum_t)); + virSecureErase(&iv_buf, sizeof(gnutls_datum_t)); if (rc < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to encrypt the data: '%s'"), @@ -209,8 +209,8 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t= gnutls_enc_alg, error: virSecureErase(ciphertext, ciphertextlen); g_free(ciphertext); - memset(&enc_key, 0, sizeof(gnutls_datum_t)); - memset(&iv_buf, 0, sizeof(gnutls_datum_t)); + virSecureErase(&enc_key, sizeof(gnutls_datum_t)); + virSecureErase(&iv_buf, sizeof(gnutls_datum_t)); return -1; } --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285111; cv=none; d=zohomail.com; s=zohoarc; b=ZxTq0rkA8N2FhYGujmb08iJZVqb6fPbaAeWlrHxeL9PKvaUmIVsF3TEN+dLfOlNUoRXepkNFuffQfwhgfOwHhaFiinVPtGJFrGfBEID6HqiqISE/aMkN1g7Q6RP7cbjE7y1O1kQbELvPuv3pn4bdSKaE40sxZEKpIvoh1tDGeJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285111; 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=D4KBq2PZbSqrzG8ICyTAy9ebmtfMTV6icX1rV40K3B0=; b=X+VOcB28lkxwuZfNakWKHjF7C46OrLXeo4EBDMjoPhs5VjD98eUXj11MN20QVMMdqwUXHdl5xAYq1Jcgg0rrPhUKOA2/Q+Q/YMVkg6rrsrReEaNDFFqYb4GPB7Ql4P5ix+H86nm0NE5Fiu8L24xSpurZH7ibF1MCMoluBLjZTv8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612285111738804.016865918892; Tue, 2 Feb 2021 08:58:31 -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-285-3sDA-8yzP2CKROEimdVrXQ-1; Tue, 02 Feb 2021 11:57:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2EA1F107ACF5; Tue, 2 Feb 2021 16:57:05 +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 0AF405C237; Tue, 2 Feb 2021 16:57:05 +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 C54085004B; Tue, 2 Feb 2021 16:57:04 +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 112Gv3nr015199 for ; Tue, 2 Feb 2021 11:57:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 024056EF45; Tue, 2 Feb 2021 16:57:03 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09F7F6E510 for ; Tue, 2 Feb 2021 16:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285110; 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=D4KBq2PZbSqrzG8ICyTAy9ebmtfMTV6icX1rV40K3B0=; b=NibQBBiMBSHSHv5aVyzzI/VlPTNi65YEkpH8Msyqt+nSDvs3Nfb+3FwYWpnXFP/T+9lfT7 d4YyI2t6jGo+KX2oPK3FYaoPGq027OBH0/KaxKJgpMjyiUQkSX0nf/FXE6F0LWtAjjeouc 8rtfm3Ek8YztsUckXD1joB2IhoQjsNY= X-MC-Unique: 3sDA-8yzP2CKROEimdVrXQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 16/27] storageBackendCreateQemuImgSecretPath: Use virSecureErase instead of VIR_DISPOSE_N Date: Tue, 2 Feb 2021 17:55:53 +0100 Message-Id: <676b46a85177f0b986afcdf201239a6f2a3e2cb7.1612284661.git.pkrempa@redhat.com> 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.16 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" Clear out the value using virSecureErase and free it with g_free so that VIR_DISPOSE_N can be phased out. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 3d8de16341..b5adb05826 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -74,6 +74,7 @@ #include "virxml.h" #include "virfdstream.h" #include "virutil.h" +#include "virsecureerase.h" #define VIR_FROM_THIS VIR_FROM_STORAGE @@ -1314,7 +1315,8 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolO= bjPtr pool, cleanup: virObjectUnref(conn); - VIR_DISPOSE_N(secret, secretlen); + virSecureErase(secret, secretlen); + g_free(secret); return secretPath; --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285040; cv=none; d=zohomail.com; s=zohoarc; b=i4bEvfweBp2m3Qv1S7PjA+Xh1yY8ebGNvp/iAIegXkeaVnjV2djWp1Fg8ueda55l90Z1naMYwxI0Tb8vwe/lB2sf5ixZbvF1NqR+Nr7Uz/f56Z9eoadYSO+ebS+0pBJNHVft9uj3R+xKlsmh/vL8u3AstLghl3Tsx4CGi4zJ7yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285040; 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=we28aF3xUCZKzj4r+oQUWGF3a5//Z602phOEy8Nl+dU=; b=Zxa8sDTsvy5lrV/32l4k3wfvsoz+Jx1vmHtqDiOewTEoGvDRmIe/QHN7amlqCf3H8mw9VU0ot4scv2x4atsgE4m6FCrB4xEgR3AoJMHikTqM8HoTeSBYc7WF9Wwm5ltk18MUxIIXdPQ8lJk6xdwJyAYPwR81vCLzCtZ62BflG9c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612285040633568.8369882684624; Tue, 2 Feb 2021 08:57:20 -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-36-0GbYMSRpNbGAZAEiN2apqw-1; Tue, 02 Feb 2021 11:57:15 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2447E100CC85; Tue, 2 Feb 2021 16:57:08 +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 028E95B4B2; Tue, 2 Feb 2021 16:57:08 +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 BC2C55004F; Tue, 2 Feb 2021 16:57:07 +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 112Gv6YW015282 for ; Tue, 2 Feb 2021 11:57:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 326926EF5A; Tue, 2 Feb 2021 16:57:06 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CAE66EF46 for ; Tue, 2 Feb 2021 16:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285039; 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=we28aF3xUCZKzj4r+oQUWGF3a5//Z602phOEy8Nl+dU=; b=cXcLXZNc3TwbZW7n1w2uwu8Wjq5QTLTCQzDagWzgrvFUnjrZRgSfJ1PJIZfyF7KyeA9PYt w15citP+sOiQeNvA3aAOXdIjFbwVZ2u6V3IiO1dsDnVER/h9/f9KpEaKGoyWlXQCBTiqcp yWeyeetPkygHZ3BJ2pXuMvUTxzE0PK8= X-MC-Unique: 0GbYMSRpNbGAZAEiN2apqw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 17/27] tests: viralloc: Remove testDispose case Date: Tue, 2 Feb 2021 17:55:54 +0100 Message-Id: <178c6076edef134ba2e89383301d25e84685c40d.1612284661.git.pkrempa@redhat.com> 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.11 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" The VIR_DISPOSE* APIs will be phased out. Additionally the test isn't really doing useful work in ensuring that the values are indeed cleared thus there's no point in keeping it around. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/viralloctest.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/tests/viralloctest.c b/tests/viralloctest.c index 8ea98b8eca..0867be8ce1 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -312,38 +312,6 @@ testInsertArray(const void *opaque G_GNUC_UNUSED) } -static int -testDispose(const void *opaque G_GNUC_UNUSED) -{ - int *num =3D NULL; - int *nums =3D NULL; - size_t nnums =3D 0; - char *str =3D NULL; - - VIR_DISPOSE(num); - VIR_DISPOSE_N(nums, nnums); - VIR_DISPOSE_STRING(str); - - nnums =3D 10; - VIR_DISPOSE_N(nums, nnums); - - num =3D g_new0(int, 1); - - VIR_DISPOSE(num); - - nnums =3D 10; - nums =3D g_new0(int, nnums); - - VIR_DISPOSE_N(nums, nnums); - - str =3D g_strdup("test"); - - VIR_DISPOSE_STRING(str); - - return 0; -} - - static int mymain(void) { @@ -357,8 +325,6 @@ mymain(void) ret =3D -1; if (virTestRun("insert array", testInsertArray, NULL) < 0) ret =3D -1; - if (virTestRun("dispose tests", testDispose, NULL) < 0) - ret =3D -1; return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285045; cv=none; d=zohomail.com; s=zohoarc; b=hNOUtcopncR8awp2zeAzCmP9vbet5C3OxZWqrConj1XqOvMQGM9BLunPGZmvt9Qi7wDslw2nTznMrQKMAPHD0UMPBQPoK0kGNSk2lRCqImh9YS1V0uGE8Qqwo4vLx+97qhJApmiv9yGdnGMRhN4H54+/8qjPk7e4Kb2uf1k1Rx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285045; 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=qXv6vaTIKQ8tR/ANhs8Qi9PYbppufY4KFVugxPEaU/s=; b=LKXzyrDehbuIw5yMIYn2XaSoV940/LO1rURtlqqtglmmEmjx24k+cp/veR0qS+BzcIycHZfdolSoWXNVEpIhh4EOYhlsAym9EPCWflQ2YCtp/NF9Ua60zIOWHTXpryWr2GVKa/ryf3kUm3wT7dNrIFIhPh21KzcPakIYruv0lIs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612285045002393.79881591923447; Tue, 2 Feb 2021 08:57:25 -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-556-r2DK21HjOS2qpRzC_bKCfA-1; Tue, 02 Feb 2021 11:57:22 -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 A2D6A874984; Tue, 2 Feb 2021 16:57:15 +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 7EA1260C6E; Tue, 2 Feb 2021 16:57:15 +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 4467F50046; Tue, 2 Feb 2021 16:57:15 +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 112GvEpU015316 for ; Tue, 2 Feb 2021 11:57:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0A32A6EF45; Tue, 2 Feb 2021 16:57:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0680A6E510 for ; Tue, 2 Feb 2021 16:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285044; 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=qXv6vaTIKQ8tR/ANhs8Qi9PYbppufY4KFVugxPEaU/s=; b=MwDwb0rxn++ESEvUIULkblH4pjP38d2b3+T9kjFXqUP5r0779ds4Kku9ltMdo1KZ9TSCj/ LLf7l6ngZrhD/W1jh9eF6PjT4bc1sxAL1s59fiKgfUDi2hwVAI0sumNiy1bfDjAP/WWCts U3lNdoKuAZuDRfA42/fQO1VLNB59ayk= X-MC-Unique: r2DK21HjOS2qpRzC_bKCfA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 18/27] util: viralloc: Remove VIR_DISPOSE(_N) Date: Tue, 2 Feb 2021 17:55:55 +0100 Message-Id: <6b2d949598586ab22feb2fdba3607bdb1266e759.1612284661.git.pkrempa@redhat.com> 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" The macros are unused now and callers who care about clearing the memory they use should use memset() appropriately. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libvirt_private.syms | 1 - src/util/viralloc.c | 39 ++------------------------------------- src/util/viralloc.h | 27 --------------------------- 3 files changed, 2 insertions(+), 65 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fa0c0887e9..62a7b8f7b9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1726,7 +1726,6 @@ vir_g_strdup_vprintf; # util/viralloc.h virAllocVar; virDeleteElementsN; -virDispose; virDisposeString; virExpandN; virInsertElementsN; diff --git a/src/util/viralloc.c b/src/util/viralloc.c index 0360b8a8aa..036007cb53 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -295,42 +295,6 @@ int virAllocVar(void *ptrptr, } -/** - * virDispose: - * @ptrptr: pointer to pointer for address of memory to be sanitized and f= reed - * @count: count of elements in the array to dispose - * @element_size: size of one element - * @countptr: pointer to the count variable to clear (may be NULL) - * - * Clear and release the chunk of memory in the pointer pointed to by 'prt= ptr'. - * - * If @countptr is provided, it's value is used instead of @count and it's= set - * to 0 after clearing and freeing the memory. - * - * After release, 'ptrptr' will be updated to point to NULL. - */ -void virDispose(void *ptrptr, - size_t count, - size_t element_size, - size_t *countptr) -{ - int save_errno =3D errno; - - if (countptr) - count =3D *countptr; - - if (*(void**)ptrptr && count > 0) - memset(*(void **)ptrptr, 0, count * element_size); - - g_free(*(void**)ptrptr); - *(void**)ptrptr =3D NULL; - - if (countptr) - *countptr =3D 0; - errno =3D save_errno; -} - - /** * virDisposeString: * @ptrptr: pointer to pointer for a string which should be sanitized and = cleared @@ -343,5 +307,6 @@ virDisposeString(char **strptr) if (!*strptr) return; - virDispose(strptr, strlen(*strptr), sizeof(char), NULL); + memset(*strptr, 0, strlen(*strptr)); + g_clear_pointer(strptr, g_free); } diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 1abd94fac4..0173107b87 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -52,8 +52,6 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_t = at, size_t *countptr, int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, siz= e_t count) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); -void virDispose(void *ptrptr, size_t count, size_t element_size, size_t *c= ountptr) - ATTRIBUTE_NONNULL(1); void virDisposeString(char **strptr) ATTRIBUTE_NONNULL(1); @@ -342,20 +340,6 @@ void virDisposeString(char **strptr) #define VIR_FREE(ptr) g_clear_pointer(&(ptr), g_free) -/** - * VIR_DISPOSE_N: - * @ptr: pointer holding address to be cleared and freed - * @count: count of elements in @ptr - * - * Clear the memory of the array of elements pointed to by 'ptr' of 'count' - * elements and free it. Update the pointer/count to NULL/0. - * - * This macro is safe to use on arguments with side effects. - */ -#define VIR_DISPOSE_N(ptr, count) virDispose(1 ? (void *) &(ptr) : (ptr), = 0, \ - sizeof(*(ptr)), &(count)) - - /** * VIR_DISPOSE_STRING: * @ptr: pointer to a string to be cleared and freed @@ -375,14 +359,3 @@ void virDisposeString(char **strptr) */ #define VIR_AUTODISPOSE_STR \ __attribute__((cleanup(virDisposeString))) char * - -/** - * VIR_DISPOSE: - * @ptr: pointer to memory to be cleared and freed - * - * Clears and frees the corresponding memory. - * - * This macro is safe to be used on arguments with side effects. - */ -#define VIR_DISPOSE(ptr) virDispose(1 ? (void *) &(ptr) : (ptr), 1, \ - sizeof(*(ptr)), NULL) --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285049; cv=none; d=zohomail.com; s=zohoarc; b=Yo/zlIhT198rTBXqUO4Ex2XB7On1hlkuCapQw5S0KL4WpucVBIZxT+awO+2ZeajqIAhe2qE2hRe4Wya+L7cRUCSMoYwqrqZ0o5o3nHc/K/D5t0OD8L+SnHp+asKEXAljjUotdbIWdFDmGICT6UjqH7A0I/NPvp+1z9TfRlLgZIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285049; 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=rdS21HuHN4ngUFSDEvhb7v3Fi651DSCIbWIeM8dMdPE=; b=XYGYnup7R6z4Wi6O24CPsnuczqVTsv5Py/mOz3zf3pSVLXG/rIkYrXjuBNf4iAqzOAKPsLp4GyU95+bUR+DCOcz2v21z4n1V9eiC/kwbBUDcCe4IwooqCfBDK//7AY4IvVjZLJVsgFLNfMWeGrdc/+kLo/ao0Yf2axmNLg21qK8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612285049642791.937738725111; Tue, 2 Feb 2021 08:57:29 -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-362-jm5Dh28pOcmJfI2rC6EkhA-1; Tue, 02 Feb 2021 11:57:25 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CBAC7107ACE3; Tue, 2 Feb 2021 16:57:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA0385D9E8; Tue, 2 Feb 2021 16:57:19 +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 728171809C90; Tue, 2 Feb 2021 16:57:19 +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 112GvHWW015353 for ; Tue, 2 Feb 2021 11:57:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id C36D26EF41; Tue, 2 Feb 2021 16:57:17 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7AC36E510 for ; Tue, 2 Feb 2021 16:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285047; 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=rdS21HuHN4ngUFSDEvhb7v3Fi651DSCIbWIeM8dMdPE=; b=MSkGbsBZCn8gSqlHWcH7lMTBW3hCgQ0uOqNX9+I6xpH8TthlUL9VkkgJTEufwZ7erqV35P CxwB4MabJYD6RhWhX6Kkl0dN6lC/hcke7z7H/JfCFUHmOdcMmbP4GNV0QT7eloqOWNcCn/ TLKx8wh2vpwzXZ2VhPqc5P9SrsgZRzw= X-MC-Unique: jm5Dh28pOcmJfI2rC6EkhA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 19/27] util: virsecureerase: Introduce virSecureEraseString Date: Tue, 2 Feb 2021 17:55:56 +0100 Message-Id: <13cc388c0f6d1dbe012a81e5dadfb7c436c86463.1612284661.git.pkrempa@redhat.com> 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.14 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" Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libvirt_private.syms | 1 + src/util/virsecureerase.c | 13 +++++++++++++ src/util/virsecureerase.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 62a7b8f7b9..845e749bdf 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3176,6 +3176,7 @@ virSecretLookupParseSecret; # util/virsecureerase.h virSecureErase; +virSecureEraseString; # util/virsocket.h diff --git a/src/util/virsecureerase.c b/src/util/virsecureerase.c index 1dc3bb476a..ead12803da 100644 --- a/src/util/virsecureerase.c +++ b/src/util/virsecureerase.c @@ -42,3 +42,16 @@ virSecureErase(void *ptr, memset(ptr, 0, size); } + +/** + * virSecureEraseString: + * @str: String to securely erase + */ +void +virSecureEraseString(char *str) +{ + if (!str) + return; + + virSecureErase(str, strlen(str)); +} diff --git a/src/util/virsecureerase.h b/src/util/virsecureerase.h index 66d7e28e8a..7aa2f970f7 100644 --- a/src/util/virsecureerase.h +++ b/src/util/virsecureerase.h @@ -23,3 +23,6 @@ void virSecureErase(void *ptr, size_t size); + +void +virSecureEraseString(char *str); --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285052; cv=none; d=zohomail.com; s=zohoarc; b=j+DrSAvOYe5N/2Z5e8jPYsCb1m4vAt7V6XT/inG2M8UJBE+fi5WGqwLrFuzA67TGyxhhc9ogQx09NqOlejQkIvmE1B6BaL1K2/D9iGZv3S7F4W6zAf5qawBXzJjRHFf0IrKJcwRLkN37VQdB0yrzdK4rT8LsYpZzPfTwmkvxQ/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285052; 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=Ete/hxZp+xSXC3Jd9oBr+/AZkOBz91yXVyFxKLQIkc8=; b=BRY2RmS273BpAHEaOZUgtjO2Wgaxv2xmf+KFVg2VZXRUQbtJc1o7WS8YVYZJW/VLOGgkCi7ewlVxBIUFP2nXq4nnhcvBRbusUyahmJpHObOd36piO+RDEYH4/SnUnB1STctLS6BVltQLHdWtmlOZF2eWCDZMFlOYJqM9e2sX5Sk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 161228505285584.58725070232106; Tue, 2 Feb 2021 08:57:32 -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-458-das976NaPn2UZkDB9dhs4g-1; Tue, 02 Feb 2021 11:57:28 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F45C803620; Tue, 2 Feb 2021 16:57:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D931E7EA92; Tue, 2 Feb 2021 16:57:22 +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 9F6AD180881C; Tue, 2 Feb 2021 16:57:22 +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 112GvLDt015390 for ; Tue, 2 Feb 2021 11:57:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id D06416EF41; Tue, 2 Feb 2021 16:57:21 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC1286E510 for ; Tue, 2 Feb 2021 16:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285051; 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=Ete/hxZp+xSXC3Jd9oBr+/AZkOBz91yXVyFxKLQIkc8=; b=e1lkGd0xKkre64Ol6JTQdkF8JLv1Fz9vRnnFK1e0tPlP5L1EUEA87tYUGkFgtrA+hKHF42 HYvaTY48MmR05zcbQ4fNi9YArIxSKcfHKB2jBBzT23SuOtHP3OLMgHiOujmuv59JckkwDJ I9WxuWWG/NmN+24xK86I2VD6EAClgRw= X-MC-Unique: das976NaPn2UZkDB9dhs4g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 20/27] libxlMakeNetworkDiskSrc: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR Date: Tue, 2 Feb 2021 17:55:57 +0100 Message-Id: <3e9ccb40a8c95ffd9592cc04abcfca5987cb47fa.1612284661.git.pkrempa@redhat.com> 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.15 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" Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libxl/libxl_conf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 694192e1c3..de0fd66842 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -999,7 +999,7 @@ static int libxlMakeNetworkDiskSrc(virStorageSourcePtr src, char **srcstr) { virConnectPtr conn =3D NULL; - VIR_AUTODISPOSE_STR base64secret =3D NULL; + g_autofree char *base64secret =3D NULL; char *username =3D NULL; int ret =3D -1; @@ -1022,7 +1022,10 @@ libxlMakeNetworkDiskSrc(virStorageSourcePtr src, cha= r **srcstr) virSecureErase(secret, secretlen); } - if (!(*srcstr =3D libxlMakeNetworkDiskSrcStr(src, username, base64secr= et))) + *srcstr =3D libxlMakeNetworkDiskSrcStr(src, username, base64secret); + virSecureEraseString(base64secret); + + if (!*srcstr) goto cleanup; ret =3D 0; --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285205; cv=none; d=zohomail.com; s=zohoarc; b=f+H8Qb5HeTYb4Pnx8zrDgiBushUMmR+DZ5Z8P+WqXhtDNz4UhLFYrT3CDz2UneMi5LONhw9h2N9ZIeoIz3Fy+zb9ihUNgMUquysLeTM1pxnuk8LC7bmXDQePdXFz+o3+RgFri3HR2x24bmshN9nRoRlgCA2dEY0iB+oe5h0uQ+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285205; 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=DpEd9XS2XzPr6EzKlnakLCJgmJpHP0dPyutVsNIyAr8=; b=aaaCvFo+y1Z9A4oU3+G4lPM1QuO1WfecoEG2qkQRVS82K5MKD2cpnrXNX2hwJd38CPnRFnIvzBbgNfxt8E0esO/2b8WQv/JqaJUxL2ZZ0rGH8CdiSaIS/mizb/WrVHb6HD1H8+wsosEVqC+nOiXIqf8UBgHWN3a2RYFosk33iGI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 161228520588580.00409973170247; Tue, 2 Feb 2021 09:00:05 -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-409-CISVDXGgPMK7lAb05nEtpQ-1; Tue, 02 Feb 2021 11:57:35 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D598C2AE; Tue, 2 Feb 2021 16:57:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DC8261D33; Tue, 2 Feb 2021 16:57:27 +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 D7F7F18077C0; Tue, 2 Feb 2021 16:57:26 +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 112GvQvD015436 for ; Tue, 2 Feb 2021 11:57:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2012E6EF53; Tue, 2 Feb 2021 16:57:26 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EE846EF50 for ; Tue, 2 Feb 2021 16:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285204; 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=DpEd9XS2XzPr6EzKlnakLCJgmJpHP0dPyutVsNIyAr8=; b=W23AGHpyX5blzFVTW45QaKXqhJfSQgNZSWLGwQ2Xzqo2miymY+fwfrpQ0siuUfQ6ErCzGX 51vroeEvUakifXvR2ng6scJWKAC28Wn1Z1l3nTFLT1VfNDtSUPGcPI1a5LGRmXrqPC2uYv f5nsvHxKcjb6yOfiMaUtzPPl5LpSmVU= X-MC-Unique: CISVDXGgPMK7lAb05nEtpQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 21/27] qemuBuildRBDSecinfoURI: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR Date: Tue, 2 Feb 2021 17:55:58 +0100 Message-Id: <28951c7134696015658575c7fb4e92ffe9096a6a.1612284661.git.pkrempa@redhat.com> 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.16 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" In this instance attempting to be correct is really pointless since the secret is formatted into another string which is not erased securely and then put on the commandline. Keep the secure handling for correctness. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f613aa0201..0320011ced 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -66,6 +66,7 @@ #include "logging/log_manager.h" #include "logging/log_protocol.h" #include "virutil.h" +#include "virsecureerase.h" #include #include @@ -776,7 +777,7 @@ static int qemuBuildRBDSecinfoURI(virBufferPtr buf, qemuDomainSecretInfoPtr secinfo) { - VIR_AUTODISPOSE_STR base64secret =3D NULL; + g_autofree char *base64secret =3D NULL; if (!secinfo) { virBufferAddLit(buf, ":auth_supported=3Dnone"); @@ -791,6 +792,7 @@ qemuBuildRBDSecinfoURI(virBufferPtr buf, virBufferEscape(buf, '\\', ":", ":key=3D%s:auth_supported=3Dcephx\\;none", base64secret); + virSecureEraseString(base64secret); break; case VIR_DOMAIN_SECRET_INFO_TYPE_AES: --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285086; cv=none; d=zohomail.com; s=zohoarc; b=ZKqkMkEm72O16yCv7aCPW7RYxLrWiz6YLTbhwpRHcaBXeAGP+4eFUSycwm1piov+nRh20YkeJyshWXP6QM0Oid93Luu1OCfGjOEk6oHEb2KExyAllj14pQlWDnWdEYDD2NCRjrQYLWsl3pKCay/zx+3Dp2jKF5YEx99h59dnjYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285086; 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=lOViJf+Bcvn8C6lU+3OGoMIHCMK+NLST2dV+sxiZwMA=; b=fM9BOr2n+8gOfbgP6Jmhn82Qxs/krqoDkDCVkkMNLz0Jyive7/S0g2hoER682n6P49/VrYmAvd5vo8Funf7SMcMfOJHd+AkBX6A7mSZT2J0XWVo465ZdhQzY6SP5Oeg/tuLUqmMr2qON7WCUtySm+yf/gJXnkffkufLcSC6BSWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612285086540150.71776411148926; Tue, 2 Feb 2021 08:58:06 -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-312-Caju-_KVOfCwKJEEXzOsRA-1; Tue, 02 Feb 2021 11:57:43 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 472608749A6; Tue, 2 Feb 2021 16:57:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07B1B7216C; Tue, 2 Feb 2021 16:57:37 +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 B51281809C90; Tue, 2 Feb 2021 16:57:36 +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 112Gvaij015516 for ; Tue, 2 Feb 2021 11:57:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 444396EF50; Tue, 2 Feb 2021 16:57:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A6656EF46 for ; Tue, 2 Feb 2021 16:57:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285085; 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=lOViJf+Bcvn8C6lU+3OGoMIHCMK+NLST2dV+sxiZwMA=; b=H2fhW5buTo79RMm6tbdhlTyWrH5ZyRU09BeACmdrN+ihc6mkGC485yhuhYnUN7Xu5poMGZ sZsXm4Qw7asPgGMyfBHK5/ODtcKE7RIFfF1YyKUmrv86YAF3o68vJ0pnsHOx5Cl/vKO2uc gc/tOVd7r4aClEXsjQcZJxAjoOoPK/I= X-MC-Unique: Caju-_KVOfCwKJEEXzOsRA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 22/27] virStorageBackendRBDOpenRADOSConn: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR Date: Tue, 2 Feb 2021 17:55:59 +0100 Message-Id: <6dda768742bc7a763ec6da9c4ec39db4ed5d7b80.1612284661.git.pkrempa@redhat.com> 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.11 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" Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/storage/storage_backend_rbd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 1f83205dfa..007c53f7ac 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -188,7 +188,6 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, virStorageAuthDefPtr authdef =3D source->auth; g_autofree unsigned char *secret_value =3D NULL; size_t secret_value_size =3D 0; - VIR_AUTODISPOSE_STR rados_key =3D NULL; g_auto(virBuffer) mon_host =3D VIR_BUFFER_INITIALIZER; size_t i; const char *client_mount_timeout =3D "30"; @@ -199,6 +198,9 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, g_autofree char *mon_buff =3D NULL; if (authdef) { + g_autofree char *rados_key =3D NULL; + int rc; + VIR_DEBUG("Using cephx authorization, username: %s", authdef->user= name); if (rados_create(&ptr->cluster, authdef->username) < 0) { @@ -218,8 +220,10 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBD= StatePtr ptr, rados_key =3D g_base64_encode(secret_value, secret_value_size); virSecureErase(secret_value, secret_value_size); - if (virStorageBackendRBDRADOSConfSet(ptr->cluster, - "key", rados_key) < 0) + rc =3D virStorageBackendRBDRADOSConfSet(ptr->cluster, "key", rados= _key); + virSecureEraseString(rados_key); + + if (rc < 0) goto cleanup; if (virStorageBackendRBDRADOSConfSet(ptr->cluster, --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285146; cv=none; d=zohomail.com; s=zohoarc; b=QFAUOkFS9U4jpCV0AAjX4eckHQCaMjtaCuuqECNQItzQPVthO/kgVrzyaFApkAW3XYeU6R/G2cbQdbFCwrekQAbV4GZwixC2UuizjdVG0g6C2BNUeETxXduL3Uddy8fTdWR4JY4sN4al7x3zOnN//jkCkHNtr0lGgOS+naN5Jss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285146; 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=AOf3OFTt33r+Ts/w5rFjyVvBxB1fkPerQYjuX73it3c=; b=j6hWWQmFGGMZSA5xtHeIukU8eLr77sbLXEtogDLOs1TxxkbBMXNkdPG5/QQatFLIc8PLQ73M7WVCGNwUg0K9DUAAZw4V4g8pHIItWlK7bNKGkEvaxsZtFuiUKoC/oY82RM34O9CO0igONaujCOVUZBmnEU1ure3+H0A0ps1DHxQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612285146949316.24307561357216; Tue, 2 Feb 2021 08:59:06 -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-443-MadTGbOTNJGKLBpxl8le3g-1; Tue, 02 Feb 2021 11:57:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B23415720; Tue, 2 Feb 2021 16:57:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC6EE5C22B; Tue, 2 Feb 2021 16:57:40 +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 A3CE618095CC; Tue, 2 Feb 2021 16:57:40 +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 112Gvd2B015531 for ; Tue, 2 Feb 2021 11:57:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A82360862; Tue, 2 Feb 2021 16:57:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 681916EF46 for ; Tue, 2 Feb 2021 16:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285145; 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=AOf3OFTt33r+Ts/w5rFjyVvBxB1fkPerQYjuX73it3c=; b=WIuuMBuacnI/vuQW2TnoXlkCtIdF1PruVMM3Au/i8VJN8CVNmdV+E84/pOOhLi0cZqMQUQ DS/ufP7BhphAuCHIyFUtpL9Oe0VP1iWjZy9ldYRnKnzh5zuGyD71k+ogLi22tauHK9L41E lV1AwH2mIa1kYgqQJ+tkSxLwhvvdixM= X-MC-Unique: MadTGbOTNJGKLBpxl8le3g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 23/27] cmdSecretGetValue: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR Date: Tue, 2 Feb 2021 17:56:00 +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.16 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" Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- tools/virsh-secret.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index de32f25d64..fcfbe5fe9e 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -302,7 +302,6 @@ static bool cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshSecret) secret =3D NULL; - VIR_AUTODISPOSE_STR base64 =3D NULL; g_autofree unsigned char *value =3D NULL; size_t value_size; bool plain =3D vshCommandOptBool(cmd, "plain"); @@ -320,9 +319,10 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd) return false; } } else { - base64 =3D g_base64_encode(value, value_size); + g_autofree char *base64 =3D g_base64_encode(value, value_size); vshPrint(ctl, "%s", base64); + virSecureEraseString(base64); } virSecureErase(value, value_size); --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1612285077; cv=none; d=zohomail.com; s=zohoarc; b=RjZwbFxFaHp6aas884KkP+305VukY9eH+G1vdz+OrWLX4/cghXVL6RdS0q/pYTdz2cQustbARliJGLpnT6IILPUQoYwsGcCC9E9TCKzCVXt5jKtN4mN3i7XzQg7qW4d3dRxT8WZQ1e0Dny4CdYsZUZMMzNb2Nj2onEuJrDUeVO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285077; 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=mzN9VFkTgaLRdZMzstqbpZHx/21Xc8i8Md2Nw9MZ+Uc=; b=cQi7lImafgi38xvIw199ea4QmCYH5VBqofywfpHaO3HY3rsMAmvgxSwlE48f3RvHOak35VTkRVSgkHWMeUxmhnKiKHP9TFmLORkIqrjk62BPqPlQn0Mtol7MgbvukA3IuNTxCNpdyiVS8/ufS0xnbgMXsGWvODZHXluWXZF2hVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 16122850770691010.9521485655212; Tue, 2 Feb 2021 08:57:57 -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-434-vDtqG4WlNFWhdIWYToiNhw-1; Tue, 02 Feb 2021 11:57:52 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 49D911800D50; Tue, 2 Feb 2021 16:57:47 +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 26D355C1CF; Tue, 2 Feb 2021 16:57:47 +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 E138C5003C; Tue, 2 Feb 2021 16:57:46 +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 112GvjMb015570 for ; Tue, 2 Feb 2021 11:57:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8279C6EF46; Tue, 2 Feb 2021 16:57:45 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C69D6EF61 for ; Tue, 2 Feb 2021 16:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285075; 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=mzN9VFkTgaLRdZMzstqbpZHx/21Xc8i8Md2Nw9MZ+Uc=; b=eC/W3c7TyU6q6wCwV+qLej5mGptYT3d+oIYc4I2qX0pkNhzrkTwD77WORAaYkeeeOVpJZt EtgBBkQzGHcqeacVloTRMnAF84PRafODaG4DPvRvHbalvU3mIg9k8CcJfq6cbTz3RdkLTd 1kgp1tb3xz0Dp4Bis6YGy4Z2Fkme/Ro= X-MC-Unique: vDtqG4WlNFWhdIWYToiNhw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 24/27] virNetLibsshAuthenticatePassword: Use virSecureEraseString instead of VIR_AUTODISPOSE_STR Date: Tue, 2 Feb 2021 17:56:01 +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.16 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" Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/rpc/virnetlibsshsession.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 9671a0f98d..73f5e998fc 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -31,6 +31,7 @@ #include "virstring.h" #include "virauth.h" #include "virbuffer.h" +#include "virsecureerase.h" #define VIR_FROM_THIS VIR_FROM_LIBSSH @@ -613,7 +614,7 @@ virNetLibsshAuthenticatePassword(virNetLibsshSessionPtr= sess, /* Try the authenticating the set amount of times. The server brea= ks the * connection if maximum number of bad auth tries is exceeded */ while (true) { - VIR_AUTODISPOSE_STR password =3D NULL; + g_autofree char *password =3D NULL; if (!(password =3D virAuthGetPasswordPath(sess->authPath, sess= ->cred, "ssh", sess->username, @@ -621,11 +622,12 @@ virNetLibsshAuthenticatePassword(virNetLibsshSessionP= tr sess, return SSH_AUTH_ERROR; /* tunnelled password authentication */ - if ((rc =3D ssh_userauth_password(sess->session, NULL, - password)) =3D=3D 0) - return SSH_AUTH_SUCCESS; + rc =3D ssh_userauth_password(sess->session, NULL, password); + virSecureEraseString(password); - if (rc !=3D SSH_AUTH_DENIED) + if (rc =3D=3D 0) + return SSH_AUTH_SUCCESS; + else if (rc !=3D SSH_AUTH_DENIED) break; } } --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285081; cv=none; d=zohomail.com; s=zohoarc; b=dn2pZJ6a8IA8zsvr3eobuvz3hTTM3GiVBVh3lpcasmE3ruU1FP9KqgLjDzVgeTycU/+iKFd7nf+PwVvmVvhNhnSKMTsNo2JuQ+2VqOp+eYvag5RoobNf6yODKLLfsAI/xBjvqINDNdT5QqjKioMZ08w5io6YjWZr9pXY47wgtm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285081; 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=OKyykQn5CiTLO51j7YqJjHPjqHtSdpK0m31Z7IHS5TQ=; b=OHxNTA5vdtCC6dk0ki0GmxieCsLyVcEHDbQDNcscV1eJ/J7Ov/EIGDGqxiBVQf7nYOwMRftjWCRoOCzM8fgS5jeMFQaTLXyoZ6HamAl1OlejWD4QLG4VwvW7zyXHtdhfoNNI1A+sG2HktvrSUdJfqhC5mF+yN9yn//VTRtaK7hk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612285081380603.0706685301393; Tue, 2 Feb 2021 08:58:01 -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-373--vuJcucsMYugqOqec2vLcQ-1; Tue, 02 Feb 2021 11:57:57 -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 600BC19611C3; Tue, 2 Feb 2021 16:57:51 +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 CDDC760C6C; Tue, 2 Feb 2021 16:57:50 +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 989BB50052; Tue, 2 Feb 2021 16:57:50 +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 112GvmJv015592 for ; Tue, 2 Feb 2021 11:57:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id A7D656EF5A; Tue, 2 Feb 2021 16:57:48 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id A76406F139 for ; Tue, 2 Feb 2021 16:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285080; 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=OKyykQn5CiTLO51j7YqJjHPjqHtSdpK0m31Z7IHS5TQ=; b=C2Im45ULuT61uUrTvIW8OvC8YTRxGmfb2tMOLIeD+1ZokqxxLtoEYPhHwSavq5m5BbY6lH F1AbOP/2nc/supfy6znXsvxnpkXV23YPaEYzTUFpOBcltL4qPyR7Rj7FNhN7xxIpYLlWqL KKC0PZV+0xZiWSAPzKVGwyimUXI1pJo= X-MC-Unique: -vuJcucsMYugqOqec2vLcQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 25/27] util: alloc: Remove VIR_AUTODISPOSE_STR Date: Tue, 2 Feb 2021 17:56:02 +0100 Message-Id: <4f92a68bf9133883c4afad96426b13e68ff8e277.1612284661.git.pkrempa@redhat.com> 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" There are no users any more. The replacement is to use g_auto and virSecureEraseString explicitly. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/viralloc.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 0173107b87..f9387a00f9 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -349,13 +349,3 @@ void virDisposeString(char **strptr) * This macro is not safe to be used on arguments with side effects. */ #define VIR_DISPOSE_STRING(ptr) virDisposeString(&(ptr)) - -/** - * VIR_AUTODISPOSE_STR: - * - * Macro to automatically free and clear the memory allocated to - * the string variable declared with it by calling virDisposeString - * when the variable goes out of scope. - */ -#define VIR_AUTODISPOSE_STR \ - __attribute__((cleanup(virDisposeString))) char * --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285083; cv=none; d=zohomail.com; s=zohoarc; b=Ng9eKJ9JhrYnXK51jLpb3ac7vONb76yQH2DGvU5wjq/1+0Rvh9avFp05mPtLPj3/OKYRFnA4zaPRjoeOg9fFII8+ZTZw/WDzm13L/6H3H69ChygA/I/afecCXfrEYQxyYUko1WynmU4Ng74TlKks6ByT88APC/V9KGWA7smBlfQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285083; 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=RQTT9J08ztETcLLoLgFbm6qBlA09vA2rfrVHJ4mgVgs=; b=bXxlrf2aZCLfKwp6a0UYBfToFwr2eQQRhbguV2swxMtnVbxrwKRfLabxTTQn6Vzwh22vJ2GzPnP57MTcUf7I0zp+jLLtnlbZtoYg3BjbNlRSoFPEv+hYBXjGfoyUze/BVVnQ5/lXmm8oPqbDV/f5RzCKANGtvSI6uguwS8jxue4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 161228508332956.906594929928815; Tue, 2 Feb 2021 08:58:03 -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-45-X6RuSG0VNcCA1JShvNe3gw-1; Tue, 02 Feb 2021 11:57:59 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B000119611A3; Tue, 2 Feb 2021 16:57:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85EDA10016F5; Tue, 2 Feb 2021 16:57:53 +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 4F82A18089D3; Tue, 2 Feb 2021 16:57:53 +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 112Gvon1015605 for ; Tue, 2 Feb 2021 11:57:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8A7AC60862; Tue, 2 Feb 2021 16:57:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 753406F12D for ; Tue, 2 Feb 2021 16:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285082; 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=RQTT9J08ztETcLLoLgFbm6qBlA09vA2rfrVHJ4mgVgs=; b=hhkkYGykPnsCMD+Cttm49AXvVV48hwbI9E3Xte7IMtTrkoWjwQFZInXHOEjD96dfJjvt/v aJbjUocT4AHnDzalBcdJctx/qz/eKyro1ziCmAurqv1LS5lT4Gn+/Io6CqgeIX4x/+SDha QoLNxYN79yhnTM2FKp/lsaWf96kCY7g= X-MC-Unique: X6RuSG0VNcCA1JShvNe3gw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 26/27] virnetlibsshsession: Replace VIR_DISPOSE_STRING with virSecureEraseString Date: Tue, 2 Feb 2021 17:56:03 +0100 Message-Id: <222ce825522d2f063e047e3f9c6360b37db7f954.1612284661.git.pkrempa@redhat.com> 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.84 on 10.5.11.22 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" Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/rpc/virnetlibsshsession.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rpc/virnetlibsshsession.c b/src/rpc/virnetlibsshsession.c index 73f5e998fc..76934c7c0b 100644 --- a/src/rpc/virnetlibsshsession.c +++ b/src/rpc/virnetlibsshsession.c @@ -114,7 +114,8 @@ virNetLibsshSessionAuthMethodsFree(virNetLibsshSessionP= tr sess) size_t i; for (i =3D 0; i < sess->nauths; i++) { - VIR_DISPOSE_STRING(sess->auths[i]->password); + virSecureEraseString(sess->auths[i]->password); + g_free(sess->auths[i]->password); VIR_FREE(sess->auths[i]->filename); VIR_FREE(sess->auths[i]); } @@ -445,7 +446,8 @@ virNetLibsshAuthenticatePrivkeyCb(const char *prompt, p =3D virStrncpy(buf, retr_passphrase.result, retr_passphrase.resultlen, len); - VIR_DISPOSE_STRING(retr_passphrase.result); + virSecureEraseString(retr_passphrase.result); + g_free(retr_passphrase.result); if (p < 0) { virReportError(VIR_ERR_LIBSSH, "%s", _("passphrase is too long for the buffer")); @@ -739,7 +741,8 @@ virNetLibsshAuthenticateKeyboardInteractive(virNetLibss= hSessionPtr sess, ret =3D ssh_userauth_kbdint_setanswer(sess->session, iprompt, retr_passphrase.result); - VIR_DISPOSE_STRING(retr_passphrase.result); + virSecureEraseString(retr_passphrase.result); + g_free(retr_passphrase.result); if (ret < 0) { errmsg =3D ssh_get_error(sess->session); virReportError(VIR_ERR_AUTH_FAILED, --=20 2.29.2 From nobody Fri May 3 11:25:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612285086; cv=none; d=zohomail.com; s=zohoarc; b=XiW4jRZwKIZ4vlw5ejYmceHy8SEJBwNJiWrnso4ozAuFwasNJm1ugkLSt9jKh53XI562smOZXCLuC3eK1giD+2zC3QMyLgqu/4do6nzr6VyyCxiodaXzJugENPHs5EniVsSNR7MxL2Dp1FpZg7MFZC8KtViNUt8dIaC4vGjCcH4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612285086; 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=bxkHz3hNyXcMGROP0ZZQJApVGvAp8dEbgc8VUe5yo8g=; b=QTa4vbz9GKhBZDsCRIIWoBUPHYKWDOijk8/jWRgRxGhhS9zWya5TJ7tjyYVKAzUQmYfZ2liV+09Ksld49jYznMYb3a2B3xUOojfHvMJ9PuMXnIygzzSlmZgm0XBNo4f2vZ4kRm2pzzI8lF9TnDBKmvTIfEV04gDm7LAH1liezgw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1612285086809806.5787405992714; Tue, 2 Feb 2021 08:58:06 -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-395-K3AA9GCkPB-gUjdkdwmLyA-1; Tue, 02 Feb 2021 11:58:03 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AEDE6803623; Tue, 2 Feb 2021 16:57:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C7666EF50; Tue, 2 Feb 2021 16:57:56 +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 4E350180881C; Tue, 2 Feb 2021 16:57:56 +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 112GvttD015616 for ; Tue, 2 Feb 2021 11:57:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5114E60862; Tue, 2 Feb 2021 16:57:55 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C9F06EF41 for ; Tue, 2 Feb 2021 16:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612285085; 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=bxkHz3hNyXcMGROP0ZZQJApVGvAp8dEbgc8VUe5yo8g=; b=CM0ieKSnC9eFUvKIQZoaFpHeRpgGvVFbaOSghEedJiHCBq0xgEzmFATT2XB/a+g3N2hEpp 6hvXutotsVtT7Nnu7OICwk9NA3jXORlKxnH2M0AQsjT6F46pw4jaW6IKAMNJ5dU1USpMT/ 3+Hmyof6N7zSbvm0VMGkgArEHTOO15k= X-MC-Unique: K3AA9GCkPB-gUjdkdwmLyA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 27/27] util: alloc: Remove VIR_DISPOSE_STRING Date: Tue, 2 Feb 2021 17:56:04 +0100 Message-Id: <771542ca07350d744c8f35bf497887d8e244a975.1612284661.git.pkrempa@redhat.com> 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.13 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" Users were replaced with virSecureEraseString with explicit freeing of the memory. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrang=C3=A9 --- src/libvirt_private.syms | 1 - src/util/viralloc.c | 17 ----------------- src/util/viralloc.h | 14 -------------- 3 files changed, 32 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 845e749bdf..30589c08ac 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1726,7 +1726,6 @@ vir_g_strdup_vprintf; # util/viralloc.h virAllocVar; virDeleteElementsN; -virDisposeString; virExpandN; virInsertElementsN; virReallocN; diff --git a/src/util/viralloc.c b/src/util/viralloc.c index 036007cb53..e4dc13b776 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -293,20 +293,3 @@ int virAllocVar(void *ptrptr, *(void **)ptrptr =3D g_malloc0(alloc_size); return 0; } - - -/** - * virDisposeString: - * @ptrptr: pointer to pointer for a string which should be sanitized and = cleared - * - * See virDispose. - */ -void -virDisposeString(char **strptr) -{ - if (!*strptr) - return; - - memset(*strptr, 0, strlen(*strptr)); - g_clear_pointer(strptr, g_free); -} diff --git a/src/util/viralloc.h b/src/util/viralloc.h index f9387a00f9..29e3224818 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -52,9 +52,6 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_t = at, size_t *countptr, int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, siz= e_t count) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); -void virDisposeString(char **strptr) - ATTRIBUTE_NONNULL(1); - /** * VIR_REALLOC_N: * @ptr: pointer to hold address of allocated memory @@ -338,14 +335,3 @@ void virDisposeString(char **strptr) * This macro is safe to use on arguments with side effects. */ #define VIR_FREE(ptr) g_clear_pointer(&(ptr), g_free) - - -/** - * VIR_DISPOSE_STRING: - * @ptr: pointer to a string to be cleared and freed - * - * Clears the string and frees the corresponding memory. - * - * This macro is not safe to be used on arguments with side effects. - */ -#define VIR_DISPOSE_STRING(ptr) virDisposeString(&(ptr)) --=20 2.29.2