From nobody Tue May 7 13:34:46 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com 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 1635566533386400.5274223527033; Fri, 29 Oct 2021 21:02:13 -0700 (PDT) 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-233-WpUZyCJSMrWTaIf1Et5LCA-1; Sat, 30 Oct 2021 00:02:10 -0400 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 7B06410A8E00; Sat, 30 Oct 2021 04:02:03 +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 2774B60854; Sat, 30 Oct 2021 04:02:01 +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 CC7744A703; Sat, 30 Oct 2021 04:01:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19U41s6G015105 for ; Sat, 30 Oct 2021 00:01:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id ECFCA51DD; Sat, 30 Oct 2021 04:01:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E56E951DC for ; Sat, 30 Oct 2021 04:01:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 12126185A79C for ; Sat, 30 Oct 2021 04:01:51 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-TPMLZmyfMv-G5s7e28ifNg-1; Sat, 30 Oct 2021 00:01:45 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19U3MuMC007165; Sat, 30 Oct 2021 04:01:44 GMT Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 3c0x3g0cpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 30 Oct 2021 04:01:44 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19U3wDtv022797; Sat, 30 Oct 2021 04:01:41 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma01wdc.us.ibm.com with ESMTP id 3c0wp90f5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 30 Oct 2021 04:01:41 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19U41eAV34734528 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 30 Oct 2021 04:01:40 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0298DB206A; Sat, 30 Oct 2021 04:01:40 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E997CB2064; Sat, 30 Oct 2021 04:01:39 +0000 (GMT) Received: from sbct-2.pok.ibm.com (unknown [9.47.158.152]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Sat, 30 Oct 2021 04:01:39 +0000 (GMT) X-MC-Unique: WpUZyCJSMrWTaIf1Et5LCA-1 X-MC-Unique: TPMLZmyfMv-G5s7e28ifNg-1 From: Stefan Berger To: libvir-list@redhat.com Subject: [PATCH] qemu: tpm: Enable creation of certs for TPM 1.2 in non-privileged mode Date: Sat, 30 Oct 2021 00:01:37 -0400 Message-Id: <20211030040137.2475844-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: p5XwdJAGMWyFlWaSKvtgp49AzDR52e3Y X-Proofpoint-GUID: p5XwdJAGMWyFlWaSKvtgp49AzDR52e3Y X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1, Aquarius:18.0.790, Hydra:6.0.425, FMLib:17.0.607.475 definitions=2021-10-30_01,2021-10-29_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 phishscore=0 priorityscore=1501 mlxlogscore=822 impostorscore=0 spamscore=0 adultscore=0 clxscore=1015 suspectscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2110300019 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: marcandre.lureau@redhat.com, Stefan Berger 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-ZM-MESSAGEID: 1635566535056100001 Content-Type: text/plain; charset="utf-8" When 'swtpm_setup --print-capabilities' shows the 'tpm12-not-need-root' flag, then it is possible to create certificates for the TPM 1.2 also in non-privileged mode since swtpm_setup doesn't need tcsd anymore. Check for this flag and create the certificates if this flag is found. Signed-off-by: Stefan Berger Reviewed-by: Michal Privoznik --- src/qemu/qemu_tpm.c | 5 ++++- src/util/virtpm.c | 1 + src/util/virtpm.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index e1b08a66c5..91e21ae646 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -463,11 +463,14 @@ qemuTPMEmulatorRunSetup(const char *storagepath, if (!swtpm_setup) return -1; =20 - if (!privileged && tpmversion =3D=3D VIR_DOMAIN_TPM_VERSION_1_2) + if (!privileged && tpmversion =3D=3D VIR_DOMAIN_TPM_VERSION_1_2 && + !virTPMSwtpmSetupCapsGet( + VIR_TPM_SWTPM_SETUP_FEATURE_TPM12_NOT_NEED_ROOT)) { return virFileWriteStr(logfile, _("Did not create EK and certificates since= " "this requires privileged mode for a " "TPM 1.2\n"), 0600); + } =20 if (!privileged && qemuTPMCreateConfigFiles(swtpm_setup) < 0) return -1; diff --git a/src/util/virtpm.c b/src/util/virtpm.c index 0f50de866c..40d9272e66 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -46,6 +46,7 @@ VIR_ENUM_IMPL(virTPMSwtpmSetupFeature, VIR_TPM_SWTPM_SETUP_FEATURE_LAST, "cmdarg-pwdfile-fd", "cmdarg-create-config-files", + "tpm12-not-need-root", ); =20 /** diff --git a/src/util/virtpm.h b/src/util/virtpm.h index 3bb03b3b33..b75eb84f31 100644 --- a/src/util/virtpm.h +++ b/src/util/virtpm.h @@ -39,6 +39,7 @@ typedef enum { typedef enum { VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_PWDFILE_FD, VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_CREATE_CONFIG_FILES, + VIR_TPM_SWTPM_SETUP_FEATURE_TPM12_NOT_NEED_ROOT, =20 VIR_TPM_SWTPM_SETUP_FEATURE_LAST } virTPMSwtpmSetupFeature; --=20 2.31.1