From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=62.149.156.91 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795010990; b=e7bwdmDAsYkt8Bt5FNmRYzVI8zRqJw1i1ZcPR7odSNNWqzA6QQCtGFwdhu169D5u9ybn 3YFZM+GYT0pkiLFMhRZt/72DjLoOqVsL8+sCv0jrrktF7ZtM62wzQoNtsi3T5ZPeo8/VC FoXeB7dMotDt92Qg9plDW5VQPHoLQNwjQe5uu7bp7ZGD/HzS/YwQzS94ykuir4UWE1DJD n7kppKcZvVDlbXCC5efKEpeuo6wlshDwSE2XR8GMVVwFaeiIsxAeBvLkIWGq86HAY05I1 FsBqAXW2/bdROh+T34GZZ7ISzpYMfuyxhlXuXxbin4IvCgXYsCsQLKb3dEwAgdi05hw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795010990; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-CMAE-Envelope; bh=T1qvRLtkirmgKXEavAQCYElsIkpIGZmynR3Whc+7Ebc=; b=UD1WLVTtUdcpQEEFzSH4icZCdN9wzSTdWI73kfA8BqzrAbWW7En513VIlXo5KHfri16v 6AB5bcIciUmdG4tEgjteHr8M+galRnk0w6HQuYtmjYE01v0HJQ4mMHnaf+RhaKxkIwVVF 46FSJ2IdGjRIPSoGpXq1NBRYfOgPzwhKut0nYvUaf2mzgaopk4cCitQNfN6eT31LhgpDV 8w07PKqurzI1NrJ1L/X3sCbI+g63uge2WtOtP0t3ViaEvIuOxnYoRw14AIwPrC7VMNzK0 mt0nbLlyAwep2NEOKEfs58NZ648xx6L3q2TZhXnjKtKoFIUVf0Jnjre9koD15sfLMUA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=enneenne.com; spf=pass smtp.mailfrom=enneenne.com; dkim=pass header.d=aruba.it header.i=@aruba.it header.a=rsa-sha256 header.s=a1 header.b=MFTygGwd; arc=none smtp.remote-ip=62.149.156.91 Received: from smtpcmd0991.aruba.it (smtpcmd0991.aruba.it [62.149.156.91]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11CE460A382A for ; Wed, 18 Nov 2026 14:09:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 11CE460A382A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enneenne.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=aruba.it header.i=@aruba.it header.a=rsa-sha256 header.s=a1 header.b=MFTygGwd Received: from polimar.tail4f75e6.ts.net ([101.57.122.26]) by Aruba SMTP with ESMTPSA id TgM6xLP476q8sTgM6xc97L; Wed, 18 Nov 2026 15:09:47 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1795010987; bh=XZv05H9A0y4JWx4C2kfVEJYBBhLV1Q9ClegJUUM5OIE=; h=From:To:Subject:Date:MIME-Version; b=MFTygGwdCJZ8dpJvyJST8MwHh46EfjwD8kJhmEijTWLZPxxhase+OwFsh7lq4cxfB LvCzgmBzy5Sj0C+N8g+2EU6Pcu6B9geb94MQEOAaldHnVjX4NbEFpnu9yCVc7RVqVI +/AlMwU46kB64xB6rlOg11YsetCkK56NQCCud9ukyLEjGxv8FI2EFtwtCzI88HVCUM B6NkgyZorcsWSf/nTrtd3tpjpBJsBiLJVblcOmVSQ+xtE2OkhSr6Xp9ZjC4W2kKWsf BdIKUCSta0s0GrqoJrElz2rqMIPfoGeQMGuaO7S4Jm0PYmBD6xJ5cqhofu31zEpuIG sgCvnIdr8afqw== From: Rodolfo Giometti To: David Howells , Jarkko Sakkinen , keyrings@vger.kernel.org Cc: Herbert Xu , "David S. Miller" , Jens Wiklander , Sumit Garg , op-tee@lists.trustedfirmware.org, =?UTF-8?q?Horia=20Geant=C4=83?= , Pankaj Gupta , Sahil Malhotra , Ahmad Fatoum , Richard Weinberger , "Christophe Leroy (CS GROUP)" , Eric Biggers , Demi Marie Obenour , Arnd Bergmann , Paul Moore , James Morris , "Serge E. Hallyn" , Jonathan Corbet , Shuah Khan , Randy Dunlap , linux-crypto@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-api@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Rodolfo Giometti Subject: [RFC PATCH 6/9] KEYS: keycrypt: Add the engine tier Date: Wed, 18 Nov 2026 15:09:42 +0100 Message-ID: <20261118140942.611715-1-giometti@enneenne.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261118140421.584086-1-giometti@enneenne.com> References: <20261118140421.584086-1-giometti@enneenne.com> X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfFtUaTfzPhMStwlKWj88S+iQKFn5wIBaG0bPK9UENjParNezD2h+kZm7q4GYiByZEdzsQH74S0KbPsFg8L7xfVpZZUnjhY3pvc+kJ0BI7LAXIm58qdb9 bmkkzJji62ZNTiCaxMVfpuHS4eJ/IXnFce4WrfNK4ImC4JclA+7r7fNiS6xXF3F9kUC91n5svOz1wzWSghT5q6XEf53LyZNPrrc/noqYJn3OAMFe3Pcb7d+Z lRjzZ3rJpEVlyaE6ZI2Wxa4zh+XsUDK06eYDCydSJelXQvFXJ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p9aQ0= Some crypto engines hold a key so that the kernel never reads it once sealed, yet run whatever operation the kernel asks of it: the CAAM's black keys are of this kind. A key there is better kept than in kernel memory, but its use is no more checked than the kernel tier's. Add the engine tier, 15, between kernel and tee, for such backends: tier=engine and min-tier=engine choose them, accepted-min-tier=engine and KEYCTL_CRYPT_OPEN's accepted_min_tier take them, and CONFIG_KEYCRYPT_SYSTEM_TIER_ENGINE makes it the system tier at boot. The core warns in the kernel log when a backend registers at it, since the protection its name may suggest stops short of the use of the key. No backend in the kernel declares this tier yet; the keycrypt CAAM backend proposed with it does. Signed-off-by: Rodolfo Giometti --- .../admin-guide/kernel-parameters.txt | 2 +- Documentation/security/keys/keycrypt.rst | 42 ++++++++++++------- include/uapi/linux/keycrypt.h | 2 + security/keys/keycrypt/Kconfig | 11 ++++- security/keys/keycrypt/core.c | 4 ++ security/keys/keycrypt/keycrypt.h | 2 + 6 files changed, 46 insertions(+), 17 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 62d44a5225e4..0cacb7d1ca1d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2947,7 +2947,7 @@ Kernel parameters keycrypt.system_tier= [KEYS] Lowest protection tier a keycrypt key may be used at; keys of a lower tier can still be created and loaded. - Format: { kernel | tee | hsm } + Format: { kernel | engine | tee | hsm } Default: the CONFIG_KEYCRYPT_SYSTEM_TIER_* choice, kernel unless set. Can only be raised, here or later through the diff --git a/Documentation/security/keys/keycrypt.rst b/Documentation/security/keys/keycrypt.rst index 17af3b041000..ac393a0bc97d 100644 --- a/Documentation/security/keys/keycrypt.rst +++ b/Documentation/security/keys/keycrypt.rst @@ -26,6 +26,10 @@ The tiers, lowest first: ========== ========================================================= ``kernel`` the key is in clear in kernel memory while loaded; the kernel enforces its use +``engine`` a crypto engine the kernel drives keeps the key, never in + clear in the kernel once sealed; the kernel decides its use + (a secure element that does not check a key's use is an + engine too) ``tee`` a trusted execution environment keeps the key and checks every use against the purpose it bound (an OP-TEE TA) ``hsm`` as ``tee``, in dedicated hardware apart from the CPU running @@ -34,7 +38,9 @@ The tiers, lowest first: policy) ========== ========================================================= -Each tier holds the guarantees of those before it. +Each tier holds the guarantees of those before it. Keys of the ``engine`` +tier, such as the CAAM's protected keys, are used by the kernel, which +cannot read them once sealed. The backends of this document: ``sw``, of tier ``kernel``, where the kernel's own software uses the key (`The sw backend`_); and ``optee``, @@ -55,7 +61,9 @@ sw backend the secret is the trusted master each key names with master (`The sw backend`_). A backend of tier ``tee`` or ``hsm`` also declares that it meets -`Backend requirements`_. +`Backend requirements`_; one that keeps a sealed key out of the kernel's +reading but leaves its use to the kernel is ``engine``. The core says +so in the kernel log when an ``engine`` backend registers. A backend registers with ``keycrypt_register_backend()`` (``include/keys/keycrypt.h``) under a name that is stored in every blob it @@ -96,10 +104,13 @@ itself does what the core has no way to check: A backend declares its own tier at ``keycrypt_register_backend()``; the core stores and compares it wherever a tier is checked, but never confirms that the backend is actually a TEE or hardware rather than -ordinary kernel code claiming to be one. The ``kernel`` tier meets -none of the above: its key material is in clear in kernel memory (`The -sw backend`_), so there every property above is only as strong as the -kernel itself. +ordinary kernel code claiming to be one. The ``engine`` and ``kernel`` +tiers meet none of the above: an ``engine`` backend leaves the key's +use to the kernel, and the kernel tier's key material is in clear in +kernel memory (`The sw backend`_), so there every property above is +only as strong as the kernel itself. What an ``engine`` backend keeps +against a compromised kernel is only that a sealed key is not in clear +in kernel memory, as far as its hardware's own properties hold. Metadata ======== @@ -187,7 +198,7 @@ Any other ``