Skip to contentSkip to conversation

KEYS: trusted: Fix trusted key backends when building as module

PATCH In review Andreas Rammhold 4 participants 12 messages Jul 30, 2021 – Oct 11, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 KEYS: trusted: Fix trusted key backends when building as module

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")

---

v3:
* Fixed patch formatting

v2:
* Fixed commit message
* Switched from IS_DEFINED() to IS_REACHABLE()

 security/keys/trusted-keys/trusted_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/trusted-keys/trusted_core.c +2 -2
index d5c891d8d353..5b35f1b87644 100644
@@ -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 defined(CONFIG_TCG_TPM)
+#if IS_REACHABLE(CONFIG_TCG_TPM)
 	{ "tpm", &trusted_key_tpm_ops },
 #endif
-#if defined(CONFIG_TEE)
+#if IS_REACHABLE(CONFIG_TEE)
 	{ "tee", &trusted_key_tee_ops },
 #endif
 };
Signature · 1 line
2.32.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 19 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")

---

v3:
* Fixed patch formatting

Quoted 7 lines

v2:
* Fixed commit message
* Switched from IS_DEFINED() to IS_REACHABLE()

 security/keys/trusted-keys/trusted_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

LGTM.

-Sumit

Quoted 20 lines
security/keys/trusted-keys/trusted_core.c +2 -3
index d5c891d8d353..5b35f1b87644 100644
@@ -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 defined(CONFIG_TCG_TPM)
+#if IS_REACHABLE(CONFIG_TCG_TPM)
        { "tpm", &trusted_key_tpm_ops },
 #endif
-#if defined(CONFIG_TEE)
+#if IS_REACHABLE(CONFIG_TEE)
        { "tee", &trusted_key_tee_ops },
 #endif
 };
--

2.32.0

Reviewed-by on v3 1/1
#2 lore raw
In reply to Andreas Rammhold
Quoted 5 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

Quoted 7 lines

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Quoted 31 lines

---

v3:
* Fixed patch formatting

v2:
* Fixed commit message
* Switched from IS_DEFINED() to IS_REACHABLE()

 security/keys/trusted-keys/trusted_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/trusted-keys/trusted_core.c +2 -2
index d5c891d8d353..5b35f1b87644 100644
@@ -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 defined(CONFIG_TCG_TPM)
+#if IS_REACHABLE(CONFIG_TCG_TPM)
 	{ "tpm", &trusted_key_tpm_ops },
 #endif
-#if defined(CONFIG_TEE)
+#if IS_REACHABLE(CONFIG_TEE)
 	{ "tee", &trusted_key_tee_ops },
 #endif
 };
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#3 lore raw
In reply to Andreas Rammhold

Dear trusted key maintainers,

Quoted 5 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

Quoted 7 lines

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")

Does anyone intend to pick this up?

Cheers,
Ahmad

Quoted 31 lines

---

v3:
* Fixed patch formatting

v2:
* Fixed commit message
* Switched from IS_DEFINED() to IS_REACHABLE()

 security/keys/trusted-keys/trusted_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/trusted-keys/trusted_core.c +2 -2
index d5c891d8d353..5b35f1b87644 100644
@@ -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 defined(CONFIG_TCG_TPM)
+#if IS_REACHABLE(CONFIG_TCG_TPM)
 	{ "tpm", &trusted_key_tpm_ops },
 #endif
-#if defined(CONFIG_TEE)
+#if IS_REACHABLE(CONFIG_TEE)
 	{ "tee", &trusted_key_tee_ops },
 #endif
 };
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#4 lore raw
Quoted 8 lines · Ahmad Fatoum

Dear trusted key maintainers,

Quoted 5 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

Quoted 8 lines
Quoted 7 lines

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")

Does anyone intend to pick this up?

Did this end up in any tree by now? I am wondering if I should resend the patch instead. Perhaps it was just overlooked?

Andi

maintainer
#5 lore raw
Quoted 13 lines · Andreas Rammhold
Quoted 12 lines · Ahmad Fatoum

Dear trusted key maintainers,

Quoted 9 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")

Does anyone intend to pick this up?

Did this end up in any tree by now? I am wondering if I should resend the patch instead. Perhaps it was just overlooked?

For EVM environments only using trusted and encrypted keys, not file signatures, the trusted key is needed to decrypt the "master" key in order to verify kernel modules.

Mimi

#6 lore raw
Quoted 17 lines · Mimi Zohar
Quoted 16 lines · Andreas Rammhold
Quoted 15 lines · Ahmad Fatoum

Dear trusted key maintainers,

Quoted 12 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Does anyone intend to pick this up?

Did this end up in any tree by now? I am wondering if I should resend the patch instead. Perhaps it was just overlooked?

For EVM environments only using trusted and encrypted keys, not file signatures, the trusted key is needed to decrypt the "master" key in order to verify kernel modules.

So what you are saying is that right now (before this patch & after this patch) you could compile a kernel that wouldn't be able to load any modules when the trusted keychain part is built as module?

Andi

maintainer
#7 lore raw
Quoted 23 lines · Andreas Rammhold
Quoted 22 lines · Mimi Zohar
Quoted 20 lines · Andreas Rammhold
Quoted 8 lines · Ahmad Fatoum

Dear trusted key maintainers,

Quoted 5 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

Quoted 8 lines
Quoted 7 lines

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")

Does anyone intend to pick this up?

Did this end up in any tree by now? I am wondering if I should resend the patch instead. Perhaps it was just overlooked?

Quoted 7 lines
Quoted 3 lines

For EVM environments only using trusted and encrypted keys, not file signatures, the trusted key is needed to decrypt the "master" key in order to verify kernel modules.

So what you are saying is that right now (before this patch & after this patch) you could compile a kernel that wouldn't be able to load any modules when the trusted keychain part is built as module?

Before this patch, trusted and encrypted keys are builtin, so verifying kernel modules with security.evm containing an EVM hmac would succeed. Afterwards it would fail, as there's a dependency on the trusted key to verify the integrity of the trusted key module.

Mimi

#8 lore raw
Quoted 28 lines · Mimi Zohar
Quoted 27 lines · Andreas Rammhold
Quoted 25 lines · Mimi Zohar
Quoted 13 lines · Andreas Rammhold
Quoted 12 lines · Ahmad Fatoum

Dear trusted key maintainers,

Quoted 9 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")

Does anyone intend to pick this up?

Did this end up in any tree by now? I am wondering if I should resend the patch instead. Perhaps it was just overlooked?

For EVM environments only using trusted and encrypted keys, not file signatures, the trusted key is needed to decrypt the "master" key in order to verify kernel modules.

Quoted 8 lines
Quoted 3 lines

So what you are saying is that right now (before this patch & after this patch) you could compile a kernel that wouldn't be able to load any modules when the trusted keychain part is built as module?

Before this patch, trusted and encrypted keys are builtin, so verifying kernel modules with security.evm containing an EVM hmac would succeed. Afterwards it would fail, as there's a dependency on the trusted key to verify the integrity of the trusted key module.

But building with =m was a valid configuration which is the original reason for me submitting the patch. So perhaps this should not be allowed to be a module then?

maintainer
#9 lore raw
Quoted 33 lines · Andreas Rammhold
Quoted 32 lines · Mimi Zohar
Quoted 30 lines · Andreas Rammhold
Quoted 17 lines · Mimi Zohar
Quoted 16 lines · Andreas Rammhold
Quoted 15 lines · Ahmad Fatoum

Dear trusted key maintainers,

Quoted 12 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Does anyone intend to pick this up?

Did this end up in any tree by now? I am wondering if I should resend the patch instead. Perhaps it was just overlooked?

For EVM environments only using trusted and encrypted keys, not file signatures, the trusted key is needed to decrypt the "master" key in order to verify kernel modules.

So what you are saying is that right now (before this patch & after this patch) you could compile a kernel that wouldn't be able to load any modules when the trusted keychain part is built as module?

Quoted 8 lines
Quoted 4 lines

Before this patch, trusted and encrypted keys are builtin, so verifying kernel modules with security.evm containing an EVM hmac would succeed. Afterwards it would fail, as there's a dependency on the trusted key to verify the integrity of the trusted key module.

But building with =m was a valid configuration which is the original reason for me submitting the patch. So perhaps this should not be allowed to be a module then?

My mistake. Trusted and encrypted key types have always been defined as tristate. Only when EVM selects encrypted keys, and by extension trusted keys, are they builtin.

Mimi

#10 lore raw
Quoted 39 lines · Mimi Zohar
Quoted 38 lines · Andreas Rammhold
Quoted 36 lines · Mimi Zohar
Quoted 23 lines · Andreas Rammhold
Quoted 22 lines · Mimi Zohar
Quoted 20 lines · Andreas Rammhold
Quoted 8 lines · Ahmad Fatoum

Dear trusted key maintainers,

Quoted 5 lines · Andreas Rammhold

Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.

Quoted 8 lines
Quoted 7 lines

When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.

Fixes 5d0682be3189 ("KEYS: trusted: Add generic trusted keys framework")

Does anyone intend to pick this up?

Did this end up in any tree by now? I am wondering if I should resend the patch instead. Perhaps it was just overlooked?

Quoted 7 lines
Quoted 3 lines

For EVM environments only using trusted and encrypted keys, not file signatures, the trusted key is needed to decrypt the "master" key in order to verify kernel modules.

So what you are saying is that right now (before this patch & after this patch) you could compile a kernel that wouldn't be able to load any modules when the trusted keychain part is built as module?

Before this patch, trusted and encrypted keys are builtin, so verifying kernel modules with security.evm containing an EVM hmac would succeed. Afterwards it would fail, as there's a dependency on the trusted key to verify the integrity of the trusted key module.

Quoted 7 lines
Quoted 3 lines

But building with =m was a valid configuration which is the original reason for me submitting the patch. So perhaps this should not be allowed to be a module then?

My mistake. Trusted and encrypted key types have always been defined as tristate. Only when EVM selects encrypted keys, and by extension trusted keys, are they builtin.

So how do we go about this patch? Building the TPM support as module has broken actually using the trusted backend. This patch fixes that while still allowing it to be a builtin. If there is some configuration there a module isn't acceptable I am sure that is handled within Kconfig?

Andi

#11 lore raw

Hello Mimi, David, Jarkko and James,

Quoted 8 lines · Andreas Rammhold
Quoted 3 lines

My mistake. Trusted and encrypted key types have always been defined as tristate. Only when EVM selects encrypted keys, and by extension trusted keys, are they builtin.

So how do we go about this patch? Building the TPM support as module has broken actually using the trusted backend. This patch fixes that while still allowing it to be a builtin. If there is some configuration there a module isn't acceptable I am sure that is handled within Kconfig?

Can anyone of you four pick this up? Andreas' regression fix has had Jarkko's Reviewed-by for close to two months and a half now.

Thanks,
Ahmad

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |