From: Ahmad Fatoum <a.fatoum@pengutronix.de> Date: 2021-07-21 16:05:20
Since commit 5d0682be3189 ("KEYS: trusted: Add generic trusted keys
framework"), trusted.ko built with CONFIG_TCG_TPM=CONFIG_TRUSTED_KEYS=m
will not register the TPM trusted key type at runtime.
This is because, after that rework, CONFIG_DEPENDENCY of the TPM
and TEE backends were checked with #ifdef, but that's only true
when they're built-in.
Fix this by introducing two new boolean Kconfig symbols:
TRUSTED_KEYS_TPM and TRUSTED_KEYS_TEE with the appropriate
dependencies and use them to check which backends are available.
This also has a positive effect on user experience:
- It's now possible to use TEE trusted keys without CONFIG_TCG_TPM
- It's now possible to enable CONFIG_TCG_TPM, but exclude TPM from
available trust sources
- TEE=m && TRUSTED_KEYS=y no longer leads to TEE support
being silently dropped
Any code depending on the TPM trusted key backend 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. This currently only affects
CONFIG_ASYMMETRIC_TPM_KEY_SUBTYPE, so it's fixed up here as well.
Reported-by: Andreas Rammhold <redacted>
Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
(Implicit) v1 was as a preparatory patch for CAAM trusted keys[1] with the
goal of fixing the Kconfig inflexibility after the TEE trusted key rework.
Unbeknownst to me, it also fixes a regression, which was later
reported by Andreas[2] along with a patch.
I split out the fix from the CAAM series and adjusted the commit
message to explain the regression.
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 <jarkko@kernel.org>
To: James Morris <jmorris@namei.org>
To: "Serge E. Hallyn" <serge@hallyn.com>
To: James Bottomley <redacted>
To: Mimi Zohar <zohar@linux.ibm.com>
To: Sumit Garg <redacted>
To: David Howells <dhowells@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
To: "David S. Miller" <davem@davemloft.net>
Cc: David Gstir <david@sigma-star.at>
Cc: Richard Weinberger <richard@nod.at>
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
---
crypto/asymmetric_keys/Kconfig | 2 +-
security/keys/Kconfig | 18 ++++++--------
security/keys/trusted-keys/Kconfig | 29 +++++++++++++++++++++++
security/keys/trusted-keys/Makefile | 8 +++----
security/keys/trusted-keys/trusted_core.c | 4 ++--
5 files changed, 43 insertions(+), 18 deletions(-)
create mode 100644 security/keys/trusted-keys/Kconfig
From: Andreas Rammhold <hidden> Date: 2021-07-21 20:17:38
On 18:02 21.07.21, Ahmad Fatoum wrote:
quoted hunk
Since commit 5d0682be3189 ("KEYS: trusted: Add generic trusted keys
framework"), trusted.ko built with CONFIG_TCG_TPM=CONFIG_TRUSTED_KEYS=m
will not register the TPM trusted key type at runtime.
This is because, after that rework, CONFIG_DEPENDENCY of the TPM
and TEE backends were checked with #ifdef, but that's only true
when they're built-in.
Fix this by introducing two new boolean Kconfig symbols:
TRUSTED_KEYS_TPM and TRUSTED_KEYS_TEE with the appropriate
dependencies and use them to check which backends are available.
This also has a positive effect on user experience:
- It's now possible to use TEE trusted keys without CONFIG_TCG_TPM
- It's now possible to enable CONFIG_TCG_TPM, but exclude TPM from
available trust sources
- TEE=m && TRUSTED_KEYS=y no longer leads to TEE support
being silently dropped
Any code depending on the TPM trusted key backend 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. This currently only affects
CONFIG_ASYMMETRIC_TPM_KEY_SUBTYPE, so it's fixed up here as well.
Reported-by: Andreas Rammhold <redacted>
Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
(Implicit) v1 was as a preparatory patch for CAAM trusted keys[1] with the
goal of fixing the Kconfig inflexibility after the TEE trusted key rework.
Unbeknownst to me, it also fixes a regression, which was later
reported by Andreas[2] along with a patch.
I split out the fix from the CAAM series and adjusted the commit
message to explain the regression.
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 <jarkko@kernel.org>
To: James Morris <jmorris@namei.org>
To: "Serge E. Hallyn" <serge@hallyn.com>
To: James Bottomley <redacted>
To: Mimi Zohar <zohar@linux.ibm.com>
To: Sumit Garg <redacted>
To: David Howells <dhowells@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
To: "David S. Miller" <davem@davemloft.net>
Cc: David Gstir <david@sigma-star.at>
Cc: Richard Weinberger <richard@nod.at>
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
---
crypto/asymmetric_keys/Kconfig | 2 +-
security/keys/Kconfig | 18 ++++++--------
security/keys/trusted-keys/Kconfig | 29 +++++++++++++++++++++++
security/keys/trusted-keys/Makefile | 8 +++----
security/keys/trusted-keys/trusted_core.c | 4 ++--
5 files changed, 43 insertions(+), 18 deletions(-)
create mode 100644 security/keys/trusted-keys/Kconfig
Works like a charm here. The key type was registered even thought I
built the kernel with CONFIG_TRUSTED_KEYS=m.
I've not actually tested if that key type works (as I've not progressed
that far in my toy project just yet).
Feel free to add my Test-By.
Tested-By: Andreas Rammhold <redacted>
On Wed, 21 Jul 2021 at 21:34, Ahmad Fatoum [off-list ref] wrote:
Since commit 5d0682be3189 ("KEYS: trusted: Add generic trusted keys
framework"), trusted.ko built with CONFIG_TCG_TPM=CONFIG_TRUSTED_KEYS=m
will not register the TPM trusted key type at runtime.
This is because, after that rework, CONFIG_DEPENDENCY of the TPM
and TEE backends were checked with #ifdef, but that's only true
when they're built-in.
Fix this by introducing two new boolean Kconfig symbols:
TRUSTED_KEYS_TPM and TRUSTED_KEYS_TEE with the appropriate
dependencies and use them to check which backends are available.
This also has a positive effect on user experience:
- It's now possible to use TEE trusted keys without CONFIG_TCG_TPM
- It's now possible to enable CONFIG_TCG_TPM, but exclude TPM from
available trust sources
- TEE=m && TRUSTED_KEYS=y no longer leads to TEE support
being silently dropped
Any code depending on the TPM trusted key backend 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. This currently only affects
CONFIG_ASYMMETRIC_TPM_KEY_SUBTYPE, so it's fixed up here as well.
Reported-by: Andreas Rammhold <redacted>
Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
(Implicit) v1 was as a preparatory patch for CAAM trusted keys[1] with the
goal of fixing the Kconfig inflexibility after the TEE trusted key rework.
Unbeknownst to me, it also fixes a regression, which was later
reported by Andreas[2] along with a patch.
I split out the fix from the CAAM series and adjusted the commit
message to explain the regression.
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 <jarkko@kernel.org>
To: James Morris <jmorris@namei.org>
To: "Serge E. Hallyn" <serge@hallyn.com>
To: James Bottomley <redacted>
To: Mimi Zohar <zohar@linux.ibm.com>
To: Sumit Garg <redacted>
To: David Howells <dhowells@redhat.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
To: "David S. Miller" <davem@davemloft.net>
Cc: David Gstir <david@sigma-star.at>
Cc: Richard Weinberger <richard@nod.at>
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
---
crypto/asymmetric_keys/Kconfig | 2 +-
security/keys/Kconfig | 18 ++++++--------
security/keys/trusted-keys/Kconfig | 29 +++++++++++++++++++++++
security/keys/trusted-keys/Makefile | 8 +++----
security/keys/trusted-keys/trusted_core.c | 4 ++--
5 files changed, 43 insertions(+), 18 deletions(-)
create mode 100644 security/keys/trusted-keys/Kconfig
Looks good to me apart from the minor comment below. With that fixed:
Reviewed-by: Sumit Garg <redacted>
+ 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
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2021-07-27 03:04:39
On Wed, Jul 21, 2021 at 06:02:59PM +0200, Ahmad Fatoum wrote:
Since commit 5d0682be3189 ("KEYS: trusted: Add generic trusted keys
framework"), trusted.ko built with CONFIG_TCG_TPM=CONFIG_TRUSTED_KEYS=m
will not register the TPM trusted key type at runtime.
This is because, after that rework, CONFIG_DEPENDENCY of the TPM
and TEE backends were checked with #ifdef, but that's only true
when they're built-in.
Fix this by introducing two new boolean Kconfig symbols:
TRUSTED_KEYS_TPM and TRUSTED_KEYS_TEE with the appropriate
dependencies and use them to check which backends are available.
This also has a positive effect on user experience:
- It's now possible to use TEE trusted keys without CONFIG_TCG_TPM
- It's now possible to enable CONFIG_TCG_TPM, but exclude TPM from
available trust sources
- TEE=m && TRUSTED_KEYS=y no longer leads to TEE support
being silently dropped
Any code depending on the TPM trusted key backend 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. This currently only affects
CONFIG_ASYMMETRIC_TPM_KEY_SUBTYPE, so it's fixed up here as well.
Reported-by: Andreas Rammhold <redacted>
Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Is it absolutely need to do all this *just* to fix the bug?
For a pure bug fix the most essential thing is to be able the backport
it to stable kernels.
I don't really care at all about extra niceties ("it's now possible
stuff).
This looks like a bug fix and improvements bundle into a single patch.
/Jarkko
From: Ahmad Fatoum <a.fatoum@pengutronix.de> Date: 2021-07-27 04:25:08
On 27.07.21 05:04, Jarkko Sakkinen wrote:
quoted
Reported-by: Andreas Rammhold <redacted>
Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Is it absolutely need to do all this *just* to fix the bug?
For a pure bug fix the most essential thing is to be able the backport
it to stable kernels.
Not much happened in-between, so a backport should be trivial.
I can provide these if needed.
I don't really care at all about extra niceties ("it's now possible
stuff).
This looks like a bug fix and improvements bundle into a single patch.
You can replace the #ifdefs with #if IS_REACHABLE in trusted_core.c to fix the
intermediate breakage and then throw that away again to fix the remaining
dependency of trusted keys on TCG_TPM.
If you prefer that, Andreas perhaps could respin his series with
s/IS_ENABLED/IS_REACHABLE/?
Cheers,
Ahmad
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2021-07-28 21:52:06
On Tue, Jul 27, 2021 at 06:24:49AM +0200, Ahmad Fatoum wrote:
On 27.07.21 05:04, Jarkko Sakkinen wrote:
quoted
quoted
Reported-by: Andreas Rammhold <redacted>
Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Is it absolutely need to do all this *just* to fix the bug?
For a pure bug fix the most essential thing is to be able the backport
it to stable kernels.
Not much happened in-between, so a backport should be trivial.
I can provide these if needed.
"not much" is not good enough. It should be "not anything".
/Jarkko
From: Ahmad Fatoum <a.fatoum@pengutronix.de> Date: 2021-07-28 22:29:49
On 28.07.21 23:52, Jarkko Sakkinen wrote:
On Tue, Jul 27, 2021 at 06:24:49AM +0200, Ahmad Fatoum wrote:
quoted
On 27.07.21 05:04, Jarkko Sakkinen wrote:
quoted
quoted
Reported-by: Andreas Rammhold <redacted>
Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Is it absolutely need to do all this *just* to fix the bug?
For a pure bug fix the most essential thing is to be able the backport
it to stable kernels.
Not much happened in-between, so a backport should be trivial.
I can provide these if needed.
"not much" is not good enough. It should be "not anything".
"Not much" [code that could conflict was added in-between].
I just checked and it applies cleanly on v5.13. On the off chance
that this patch conflicts with another stable backport by the time
it's backported, I'll get a friendly automated email and send out
a rebased patch.
Cheers,
Ahmad
From: Jarkko Sakkinen <jarkko@kernel.org> Date: 2021-07-30 00:31:25
On Thu, Jul 29, 2021 at 12:29:38AM +0200, Ahmad Fatoum wrote:
On 28.07.21 23:52, Jarkko Sakkinen wrote:
quoted
On Tue, Jul 27, 2021 at 06:24:49AM +0200, Ahmad Fatoum wrote:
quoted
On 27.07.21 05:04, Jarkko Sakkinen wrote:
quoted
quoted
Reported-by: Andreas Rammhold <redacted>
Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Is it absolutely need to do all this *just* to fix the bug?
For a pure bug fix the most essential thing is to be able the backport
it to stable kernels.
Not much happened in-between, so a backport should be trivial.
I can provide these if needed.
"not much" is not good enough. It should be "not anything".
"Not much" [code that could conflict was added in-between].
I just checked and it applies cleanly on v5.13. On the off chance
that this patch conflicts with another stable backport by the time
it's backported, I'll get a friendly automated email and send out
a rebased patch.
What you should do is to split this into patch that exactly
fixes the issue, and to one that adds the "niceties".
/Jarkko
From: Ahmad Fatoum <a.fatoum@pengutronix.de> Date: 2021-07-30 06:22:07
On 30.07.21 02:31, Jarkko Sakkinen wrote:
On Thu, Jul 29, 2021 at 12:29:38AM +0200, Ahmad Fatoum wrote:
quoted
On 28.07.21 23:52, Jarkko Sakkinen wrote:
quoted
On Tue, Jul 27, 2021 at 06:24:49AM +0200, Ahmad Fatoum wrote:
quoted
On 27.07.21 05:04, Jarkko Sakkinen wrote:
quoted
quoted
Reported-by: Andreas Rammhold <redacted>
Fixes: 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Is it absolutely need to do all this *just* to fix the bug?
For a pure bug fix the most essential thing is to be able the backport
it to stable kernels.
Not much happened in-between, so a backport should be trivial.
I can provide these if needed.
"not much" is not good enough. It should be "not anything".
"Not much" [code that could conflict was added in-between].
I just checked and it applies cleanly on v5.13. On the off chance
that this patch conflicts with another stable backport by the time
it's backported, I'll get a friendly automated email and send out
a rebased patch.
What you should do is to split this into patch that exactly
fixes the issue, and to one that adds the "niceties".
I'd rather not send out patches I believe to be incomplete, sorry.
If you want to fix the regression's root cause of insufficient
Kconfig description, that here is what it takes.
You can take Andreas' regression fix for stable and replace it with my patch later.
I'll send out a new version removing references that it fixes a regression.
Cheers,
Ahmad