From nobody Wed Apr 24 06:19:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1669121119; cv=none; d=zohomail.com; s=zohoarc; b=RSgJRhoQs3NkbUW2TH3H6xFodTTyexkZoVnhpAFEY+eXwie+LTiu+H6BS0f+mmXMIxoGBZh/7m0k/NI4HN9TebfGqzMKLrF3xJtf9562q696dl/8OUYiGhsVs10k09ZP2HgdL6I+RXwP70q+FvNpOwXXHoWj+E3wuEyiz7bvmzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669121119; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=41M7gW3V2tm0qb9x+7bzFNKsc2+tOAhdxvcEuYgCknY=; b=D7kNYC7iFBGVnuLyfyegVzGTGvYYFQLGPqB+s6Y+l5LgW/R/LmehOSY3XMk3ePmzfq2AeEzVhZH3039y2nf12ZmyfbMWELt5DS8CQAJfT/m9Kw1uYgewP8wYeocx5wB7ob4Zjgb1jHe9R/jtgJJ8yWEfgumWkw0ZYc3FP7QHAfk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1669121119168942.6266985658566; Tue, 22 Nov 2022 04:45:19 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-227-d3SueJNDOd2YBb1h6qlcXQ-1; Tue, 22 Nov 2022 07:45:15 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB0821C05145; Tue, 22 Nov 2022 12:45:12 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5C15C159CD; Tue, 22 Nov 2022 12:45:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B28201946589; Tue, 22 Nov 2022 12:45:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1DA291946587 for ; Tue, 22 Nov 2022 12:45:05 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CEDDD492B2A; Tue, 22 Nov 2022 12:45:05 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7354D492B17 for ; Tue, 22 Nov 2022 12:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669121118; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=41M7gW3V2tm0qb9x+7bzFNKsc2+tOAhdxvcEuYgCknY=; b=bje92T6fxY2FZ4tWVCzTRdj68N/Zdf86GWSwDTBalJW0xm1pkV6vohQl27GcTrrCUTdUFq 4fgXRo3tv1TcnOLDIdWAAWqHlEAtp/bbnYDysYZ0E/XbvdLXpGzumcm/N0P+D4QalU8aYD RozRHyWTD5BatYbPax0aeRw28SCl7rA= X-MC-Unique: d3SueJNDOd2YBb1h6qlcXQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu_tpm: Check for qemuTPMSetupEncryption() errors Date: Tue, 22 Nov 2022 13:45:01 +0100 Message-Id: <68b966e9ef5c60bf5813a40e57c29da473c1df54.1669121101.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669121119767100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Inside of qemuTPMEmulatorBuildCommand() there are two calls to qemuTPMSetupEncryption() which simply ignore returned error. This is suboptimal because then we rely on swtpm binary reporting a generic error (something among invalid arguments) while an error reported by qemuTPMSetupEncryption() is more specific. Signed-off-by: Michal Privoznik --- src/qemu/qemu_tpm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index 15ee7db757..502a77b5b3 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -635,7 +635,12 @@ qemuTPMEmulatorBuildCommand(virDomainTPMDef *tpm, } =20 pwdfile_fd =3D qemuTPMSetupEncryption(tpm->data.emulator.secretuui= d, cmd); + if (pwdfile_fd < 0) + goto error; + migpwdfile_fd =3D qemuTPMSetupEncryption(tpm->data.emulator.secret= uuid, cmd); + if (migpwdfile_fd < 0) + goto error; =20 virCommandAddArg(cmd, "--key"); virCommandAddArgFormat(cmd, "pwdfd=3D%d,mode=3Daes-256-cbc", pwdfi= le_fd); --=20 2.37.4