Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp30991lfe; Fri, 15 Apr 2022 18:01:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPqvJMwFcSk0wh4rj/RJuP8FWCIz7COSG+pvnkT/3l0Y0dgkBP3h7HJ+Pw8yze0jLi6lN7 X-Received: by 2002:a05:6a00:1946:b0:4fe:309f:d612 with SMTP id s6-20020a056a00194600b004fe309fd612mr1662573pfk.10.1650070867551; Fri, 15 Apr 2022 18:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650070867; cv=none; d=google.com; s=arc-20160816; b=vVgehDjeKFSXDgJKD0XszVELSHfwd8fQ+O4q9H+fvg+V/A378/Lz8BL64IDYl7+fI1 xs4B8VKj3b1y0z3G8ecC8Re1dIGLcEnx3UuEJN+mcj0F6fK+/9TNGR7Rs07rN75nzyug cCSPKxICdFWFjJmEiycIFRcFlCNbJSFpHyJOKMjb+pP3oN0070NpukoTrpiJ+w3Qrt6N QS5kKJLPw23NzJbofkDEaPBN9Sland3hJE061k39/O6jTVDjhAb3AUK2HckJbty8QJbv d+m/LxMetVh5DuO2vPzv+XHlKGPy+k3BCXAk4tWkLfDIykHV5Dv1ONW7URtnXXXv0O32 U7sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CylQCggyyBBTzL6rsI/iukrt62yUnQ+NuZrHvZ2iSLg=; b=KPiUgOdGZ0PrtXXgtjamHZHwOIEG8Jiso3hbJe+sBdmeogTM3xs7MDxdDpl+pUUSG+ ouTBNo881BTdL/n6crRo61CIzTn6giMTgJzQzazoNp7Qk6UfjYJUbGEUrx6EgioUt8+B TvXo2btfIOZw1Lg2OGBD4WWuxm+gCnmanbiHUHmSWpYSFDcqMyAtK3KDa5OEqBbiozZA cVcuG2vU1uWUJAaUFQCk7KmFDZnZX2kiZbV4xU8WXfPalssrPoZ1AJjBZT7LtiBsGzSy FUmcbbnddDPjTcgA3rKyBcqaEh6lC889wYPfd8CQsZWyDfYcB/+dPTwIsLMx+Uv6YHMh HK5A== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id nu3-20020a17090b1b0300b001cd3aa47f49si3404246pjb.50.2022.04.15.18.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:01:07 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C2053633F; Fri, 15 Apr 2022 17:44:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347532AbiDOVAj (ORCPT + 99 others); Fri, 15 Apr 2022 17:00:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353008AbiDOVAf (ORCPT ); Fri, 15 Apr 2022 17:00:35 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ABF98AE7E for ; Fri, 15 Apr 2022 13:57:58 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nfT0A-0002iI-VM; Fri, 15 Apr 2022 22:57:11 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1nfT0A-003FIw-CZ; Fri, 15 Apr 2022 22:57:08 +0200 Received: from afa by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nfT07-000C02-E1; Fri, 15 Apr 2022 22:57:07 +0200 From: Ahmad Fatoum To: Jarkko Sakkinen , James Morris , "Serge E. Hallyn" , James Bottomley , Mimi Zohar , Sumit Garg , David Howells , Herbert Xu , "David S. Miller" Cc: kernel@pengutronix.de, Andreas Rammhold , Tim Harvey , Ahmad Fatoum , David Gstir , Richard Weinberger , Matthias Schiffer , Pankaj Gupta , keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org Subject: [PATCH v7 1/6] KEYS: trusted: allow use of TEE as backend without TCG_TPM support Date: Fri, 15 Apr 2022 22:56:42 +0200 Message-Id: <20220415205647.46056-2-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220415205647.46056-1-a.fatoum@pengutronix.de> References: <20220415205647.46056-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: afa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org With recent rework, trusted keys are no longer limited to TPM as trust source. The Kconfig symbol is unchanged however leading to a few issues: - TCG_TPM is required, even if only TEE is to be used - Enabling TCG_TPM, but excluding it from available trusted sources is not possible - TEE=m && TRUSTED_KEYS=y will lead to TEE support being silently dropped, which is not the best user experience Remedy these issues by introducing two new boolean Kconfig symbols: TRUSTED_KEYS_TPM and TRUSTED_KEYS_TEE with the appropriate dependencies. Any new code depending on the TPM trusted key backend in particular or symbols exported by it will now need to explicitly state that it depends on TRUSTED_KEYS && TRUSTED_KEYS_TPM The latter to ensure the dependency is built and the former to ensure it's reachable for module builds. There are no such users yet. Reviewed-by: Sumit Garg Reviewed-by: Jarkko Sakkinen Tested-by: Andreas Rammhold Tested-by: Tim Harvey Signed-off-by: Ahmad Fatoum --- v6 -> v7: - s/Tested-By/Tested-by/ v5 -> v6: - Rebased on asym_tpm removal v4 -> v5: - collected Jarkko's Reviewed-by v3 -> v4: - rebased on top of Andreas' regression fix and pulled it back into series v2 -> v3: - factored this patch out as a fix for backporting v1 -> v2: - Move rest of TPM-related selects from TRUSTED_KEYS to TRUSTED_KEYS_TPM (Sumit) - Remove left-over line in Makefile (Sumit) - added Fixes: tag - adjust commit message to reference the regression reported by Andreas - have ASYMMETRIC_TPM_KEY_SUBTYPE depend on TRUSTED_KEYS_TPM, because it references global symbols that are exported by the trusted key TPM backend. [1]: https://lore.kernel.org/linux-integrity/f8285eb0135ba30c9d846cf9dd395d1f5f8b1efc.1624364386.git-series.a.fatoum@pengutronix.de/ [2]: https://lore.kernel.org/linux-integrity/20210719091335.vwfebcpkf4pag3wm@wrt/T/#t To: Jarkko Sakkinen To: James Morris To: "Serge E. Hallyn" To: James Bottomley To: Mimi Zohar To: Sumit Garg To: David Howells To: Herbert Xu To: "David S. Miller" Cc: David Gstir Cc: Richard Weinberger Cc: Matthias Schiffer Cc: Pankaj Gupta Cc: keyrings@vger.kernel.org Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-security-module@vger.kernel.org Cc: linux-integrity@vger.kernel.org --- security/keys/Kconfig | 18 ++++++-------- security/keys/trusted-keys/Kconfig | 29 +++++++++++++++++++++++ security/keys/trusted-keys/Makefile | 8 +++---- security/keys/trusted-keys/trusted_core.c | 4 ++-- 4 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 security/keys/trusted-keys/Kconfig diff --git a/security/keys/Kconfig b/security/keys/Kconfig index 0e30b361e1c1..abb03a1b2a5c 100644 --- a/security/keys/Kconfig +++ b/security/keys/Kconfig @@ -70,23 +70,19 @@ config BIG_KEYS config TRUSTED_KEYS tristate "TRUSTED KEYS" - depends on KEYS && TCG_TPM - select CRYPTO - select CRYPTO_HMAC - select CRYPTO_SHA1 - select CRYPTO_HASH_INFO - select ASN1_ENCODER - select OID_REGISTRY - select ASN1 + depends on KEYS help This option provides support for creating, sealing, and unsealing keys in the kernel. Trusted keys are random number symmetric keys, - generated and RSA-sealed by the TPM. The TPM only unseals the keys, - if the boot PCRs and other criteria match. Userspace will only ever - see encrypted blobs. + generated and sealed by a trust source selected at kernel boot-time. + Userspace will only ever see encrypted blobs. If you are unsure as to whether this is required, answer N. +if TRUSTED_KEYS +source "security/keys/trusted-keys/Kconfig" +endif + config ENCRYPTED_KEYS tristate "ENCRYPTED KEYS" depends on KEYS diff --git a/security/keys/trusted-keys/Kconfig b/security/keys/trusted-keys/Kconfig new file mode 100644 index 000000000000..fc4abd581abb --- /dev/null +++ b/security/keys/trusted-keys/Kconfig @@ -0,0 +1,29 @@ +config TRUSTED_KEYS_TPM + bool "TPM-based trusted keys" + depends on TCG_TPM >= TRUSTED_KEYS + default y + select CRYPTO + select CRYPTO_HMAC + select CRYPTO_SHA1 + select CRYPTO_HASH_INFO + select ASN1_ENCODER + select OID_REGISTRY + select ASN1 + help + Enable use of the Trusted Platform Module (TPM) as trusted key + backend. Trusted keys are random number symmetric keys, + which will be generated and RSA-sealed by the TPM. + The TPM only unseals the keys, if the boot PCRs and other + criteria match. + +config TRUSTED_KEYS_TEE + bool "TEE-based trusted keys" + depends on TEE >= TRUSTED_KEYS + default y + help + Enable use of the Trusted Execution Environment (TEE) as trusted + key backend. + +if !TRUSTED_KEYS_TPM && !TRUSTED_KEYS_TEE +comment "No trust source selected!" +endif diff --git a/security/keys/trusted-keys/Makefile b/security/keys/trusted-keys/Makefile index feb8b6c3cc79..2e2371eae4d5 100644 --- a/security/keys/trusted-keys/Makefile +++ b/security/keys/trusted-keys/Makefile @@ -5,10 +5,10 @@ obj-$(CONFIG_TRUSTED_KEYS) += trusted.o trusted-y += trusted_core.o -trusted-y += trusted_tpm1.o +trusted-$(CONFIG_TRUSTED_KEYS_TPM) += trusted_tpm1.o $(obj)/trusted_tpm2.o: $(obj)/tpm2key.asn1.h -trusted-y += trusted_tpm2.o -trusted-y += tpm2key.asn1.o +trusted-$(CONFIG_TRUSTED_KEYS_TPM) += trusted_tpm2.o +trusted-$(CONFIG_TRUSTED_KEYS_TPM) += tpm2key.asn1.o -trusted-$(CONFIG_TEE) += trusted_tee.o +trusted-$(CONFIG_TRUSTED_KEYS_TEE) += trusted_tee.o diff --git a/security/keys/trusted-keys/trusted_core.c b/security/keys/trusted-keys/trusted_core.c index 9b9d3ef79cbe..7cdbd16aed30 100644 --- a/security/keys/trusted-keys/trusted_core.c +++ b/security/keys/trusted-keys/trusted_core.c @@ -27,10 +27,10 @@ module_param_named(source, trusted_key_source, charp, 0); MODULE_PARM_DESC(source, "Select trusted keys source (tpm or tee)"); static const struct trusted_key_source trusted_key_sources[] = { -#if IS_REACHABLE(CONFIG_TCG_TPM) +#if defined(CONFIG_TRUSTED_KEYS_TPM) { "tpm", &trusted_key_tpm_ops }, #endif -#if IS_REACHABLE(CONFIG_TEE) +#if defined(CONFIG_TRUSTED_KEYS_TEE) { "tee", &trusted_key_tee_ops }, #endif }; -- 2.30.2