ipe: allow secondary and platform keyrings to install/update policies
Subsystems (3)
PATCH 1/1 ipe: allow secondary and platform keyrings to install/update policies
From: Luca Boccassi <[email protected]>
The current policy management makes it impossible to use IPE in a general purpose distribution. In such cases the users are not building the kernel, the distribution is, and access to the private key included in the trusted keyring is, for obvious reason, not available.
This means that users have no way to enable IPE, since there will be no built-in generic policy, and no access to the key to sign updates validated by the trusted keyring.
Just as we do for dm-verity, kernel modules and more, allow the secondary and platform keyrings to also validate policies. This allows users enrolling their own keys in UEFI db or MOK to also sign policies, and enroll them. This makes it sensible to enable IPE in general purpose distributions, as it becomes usable by any user wishing to do so. Keys in these keyrings can already load kernels and kernel modules, so there is no security downgrade.
--- security/ipe/policy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
security/ipe/policy.c +7 -1
@@ -169,9 +169,15 @@ struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, goto err; } - rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len,NULL , + rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +VERIFY_USE_SECONDARY_KEYRING ,VERIFYING_UNSPECIFIED_SIGNATURE , set_pkcs7_data, new); +if (rc == -ENOKEY ) + rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +VERIFY_USE_PLATFORM_KEYRING , +VERIFYING_UNSPECIFIED_SIGNATURE , + set_pkcs7_data, new);if (rc) goto err; }else {
Signature · 1 line
2.39.2
Quoted 2 lines · On 9/13/2024 4:48 PM, [email protected] wrote:
From: Luca Boccassi <[email protected]>
...
Quoted 17 lines
Signed-off-by Luca Boccassi <[email protected]>--- security/ipe/policy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)security/ipe/policy.c +2
-1@@ -169,9 +169,15 @@ struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, goto err; } - rc = verify_pkcs7_signature(NULL, 0, new->pkcs7, pkcs7len, NULL, + rc = verify_pkcs7_signature(NULL, 0, new->pkcs7, pkcs7len, + VERIFY_USE_SECONDARY_KEYRING,
security/ipe/policy.c struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, · line 183
Quoted 10 lines
security/ipe/policy.c +5
-0VERIFYING_UNSPECIFIED_SIGNATURE , set_pkcs7_data, new); +if (rc == -ENOKEY ) + rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +VERIFY_USE_PLATFORM_KEYRING , +VERIFYING_UNSPECIFIED_SIGNATURE , + set_pkcs7_data, new);if (rc) goto err; }else {
Hi Luca,
This patch looks good to me. My only thought is, like what we currently have for dm-verity, should we also add two kconfigs to enable to use these two keyrings respectively?
-Fan
PATCH v2 1/1 ipe: allow secondary and platform keyrings to install/update policies
In reply to [email protected]From: Luca Boccassi <[email protected]>
The current policy management makes it impossible to use IPE in a general purpose distribution. In such cases the users are not building the kernel, the distribution is, and access to the private key included in the trusted keyring is, for obvious reason, not available.
This means that users have no way to enable IPE, since there will be no built-in generic policy, and no access to the key to sign updates validated by the trusted keyring.
Just as we do for dm-verity, kernel modules and more, allow the secondary and platform keyrings to also validate policies. This allows users enrolling their own keys in UEFI db or MOK to also sign policies, and enroll them. This makes it sensible to enable IPE in general purpose distributions, as it becomes usable by any user wishing to do so. Keys in these keyrings can already load kernels and kernel modules, so there is no security downgrade.
Add a kconfig each, like dm-verity does, but default to enabled if the dependencies are available.
---
v2: add Kconfig entries following the dm-verity model
update documentation
Documentation/admin-guide/LSM/ipe.rst | 5 ++++- security/ipe/Kconfig | 19 +++++++++++++++++++ security/ipe/policy.c | 14 +++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-)
Documentation/admin-guide/LSM/ipe.rst +4 -1
@@ -223,7 +223,10 @@ are signed through the PKCS#7 message format to enforce some level of authorization of the policies (prohibiting an attacker from gaining unconstrained root, and deploying an "allow all" policy). These policies must be signed by a certificate that chains to the -``SYSTEM_TRUSTED_KEYRING``. With openssl, the policy can be signed by:: +``SYSTEM_TRUSTED_KEYRING``, or to the secondary and/or platform keyrings if +``CONFIG_IPE_POLICY_SIG_SECONDARY_KEYRING`` and/or +``CONFIG_IPE_POLICY_SIG_PLATFORM_KEYRING`` are enabled, respectively. +With openssl, the policy can be signed by:: openssl smime -sign \ -in "$MY_POLICY" \
security/ipe/Kconfig +19 -0
@@ -31,6 +31,25 @@ config IPE_BOOT_POLICY If unsure, leave blank. +config IPE_POLICY_SIG_SECONDARY_KEYRING + bool "IPE policy update verification with secondary keyring" + default y + depends on SECONDARY_TRUSTED_KEYRING + help + Also allow the secondary trusted keyring to verify IPE policy + updates. + + If unsure, answer Y. + +config IPE_POLICY_SIG_PLATFORM_KEYRING + bool "IPE policy update verification with platform keyring" + default y + depends on INTEGRITY_PLATFORM_KEYRING + help + Also allow the platform keyring to verify IPE policy updates. + + If unsure, answer Y. + menu "IPE Trust Providers" config IPE_PROP_DM_VERITY
security/ipe/policy.c +13 -1
@@ -169,9 +169,21 @@ struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, goto err; } - rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len,NULL , + rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +#ifdef CONFIG_IPE_POLICY_SIG_SECONDARY_KEYRING +VERIFY_USE_SECONDARY_KEYRING , +#else +NULL , +#endifVERIFYING_UNSPECIFIED_SIGNATURE , set_pkcs7_data, new); +#ifdef CONFIG_IPE_POLICY_SIG_PLATFORM_KEYRING +if (rc == -ENOKEY ) + rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +VERIFY_USE_PLATFORM_KEYRING , +VERIFYING_UNSPECIFIED_SIGNATURE , + set_pkcs7_data, new); +#endif if (rc) goto err; }else {
Signature · 1 line
2.39.5
Quoted 37 lines · Fan Wu
Quoted 2 lines · On 9/13/2024 4:48 PM, [email protected] wrote:
From: Luca Boccassi <[email protected]>
...
Quoted 17 lines
Signed-off-by Luca Boccassi <[email protected]>--- security/ipe/policy.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)security/ipe/policy.c +2
-1@@ -169,9 +169,15 @@ struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, goto err; } - rc = verify_pkcs7_signature(NULL, 0, new->pkcs7, pkcs7len, NULL, + rc = verify_pkcs7_signature(NULL, 0, new->pkcs7, pkcs7len, + VERIFY_USE_SECONDARY_KEYRING,security/ipe/policy.c struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, · line 183
Quoted 10 lines
security/ipe/policy.c +5
-0VERIFYING_UNSPECIFIED_SIGNATURE , set_pkcs7_data, new); +if (rc == -ENOKEY ) + rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +VERIFY_USE_PLATFORM_KEYRING , +VERIFYING_UNSPECIFIED_SIGNATURE , + set_pkcs7_data, new);if (rc) goto err; }else {Hi Luca,
Quoted 3 lines
This patch looks good to me. My only thought is, like what we currently have for dm-verity, should we also add two kconfigs to enable to use these two keyrings respectively?
Sure no problem, sent v2 with the added kconfigs.
Unlike dm-verity the default is "yes" for both though: it's been quite a pain to get all distributions to enable the dm-verity kconfigs for the keyrings, given they are quite hidden and a niche use case and general distro maintainers don't go and look for these options, but likewise it made signed dm-verity unusable on general purpose distros without them. I'd like to avoid repeating the same plight. This way if one doesn't want them they can disable them, but the default if IPE is enabled is to use them.
Serge E. Hallyn
maintainerQuoted 88 lines · On Sun, Sep 15, 2024 at 11:11:19AM +0200, [email protected] wrote:
From: Luca Boccassi <[email protected]>
The current policy management makes it impossible to use IPE in a general purpose distribution. In such cases the users are not building the kernel, the distribution is, and access to the private key included in the trusted keyring is, for obvious reason, not available.
This means that users have no way to enable IPE, since there will be no built-in generic policy, and no access to the key to sign updates validated by the trusted keyring.Just as we do for dm-verity, kernel modules and more, allow the secondary and platform keyrings to also validate policies. This allows users enrolling their own keys in UEFI db or MOK to also sign policies, and enroll them. This makes it sensible to enable IPE in general purpose distributions, as it becomes usable by any user wishing to do so. Keys in these keyrings can already load kernels and kernel modules, so there is no security downgrade.
Add a kconfig each, like dm-verity does, but default to enabled if the dependencies are available.
Signed-off-by Luca Boccassi <[email protected]>---
v2: addKconfigentries following the dm-verity model
update documentationDocumentation/admin-guide/LSM/ipe.rst | 5 ++++- security/ipe/Kconfig | 19 +++++++++++++++++++ security/ipe/policy.c | 14 +++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-)Documentation/admin-guide/LSM/ipe.rst +4
-1@@ -223,7 +223,10 @@ are signed through the PKCS#7 message format to enforce some level of authorization of the policies (prohibiting an attacker from gaining unconstrained root, and deploying an "allow all" policy). These policies must be signed by a certificate that chains to the -``SYSTEM_TRUSTED_KEYRING``. With openssl, the policy can be signed by:: +``SYSTEM_TRUSTED_KEYRING``, or to the secondary and/or platform keyrings if +``CONFIG_IPE_POLICY_SIG_SECONDARY_KEYRING`` and/or +``CONFIG_IPE_POLICY_SIG_PLATFORM_KEYRING`` are enabled, respectively. +With openssl, the policy can be signed by:: openssl smime -sign \ -in "$MY_POLICY" \security/ipe/Kconfig +19
-0@@ -31,6 +31,25 @@ config IPE_BOOT_POLICY If unsure, leave blank. +config IPE_POLICY_SIG_SECONDARY_KEYRING + bool "IPE policy update verification with secondary keyring" + default y + depends on SECONDARY_TRUSTED_KEYRING + help + Also allow the secondary trusted keyring to verify IPE policy + updates. + + If unsure, answer Y. + +config IPE_POLICY_SIG_PLATFORM_KEYRING + bool "IPE policy update verification with platform keyring" + default y + depends on INTEGRITY_PLATFORM_KEYRING + help + Also allow the platform keyring to verify IPE policy updates. + + If unsure, answer Y. + menu "IPE Trust Providers" config IPE_PROP_DM_VERITYsecurity/ipe/policy.c +0
-1@@ -169,9 +169,21 @@ struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, goto err; } - rc = verify_pkcs7_signature(NULL, 0, new->pkcs7, pkcs7len, NULL,
security/ipe/policy.c struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, · line 181
Quoted 10 lines
security/ipe/policy.c +8
-0+ rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +#ifdef CONFIG_IPE_POLICY_SIG_SECONDARY_KEYRING +VERIFY_USE_SECONDARY_KEYRING , +#else +NULL , +#endifVERIFYING_UNSPECIFIED_SIGNATURE , set_pkcs7_data, new); +#ifdef CONFIG_IPE_POLICY_SIG_PLATFORM_KEYRING +if (rc == -ENOKEY )
If the secondary key *is* there, but returns -EKEYREJECTED, do you want to fall back to trying the platform keyring, or not?
Quoted 11 lines
security/ipe/policy.c +5
-0+ rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +VERIFY_USE_PLATFORM_KEYRING , +VERIFYING_UNSPECIFIED_SIGNATURE , + set_pkcs7_data, new); +#endif if (rc) goto err; }else {Signature · 1 line
2.39.5
Quoted 43 lines · Serge E. Hallyn
Quoted 41 lines · On Sun, Sep 15, 2024 at 11:11:19AM +0200, [email protected] wrote:
From: Luca Boccassi <[email protected]>
The current policy management makes it impossible to use IPE in a general purpose distribution. In such cases the users are not building the kernel, the distribution is, and access to the private key included in the trusted keyring is, for obvious reason, not available.
This means that users have no way to enable IPE, since there will be no built-in generic policy, and no access to the key to sign updates validated by the trusted keyring.Just as we do for dm-verity, kernel modules and more, allow the secondary and platform keyrings to also validate policies. This allows users enrolling their own keys in UEFI db or MOK to also sign policies, and enroll them. This makes it sensible to enable IPE in general purpose distributions, as it becomes usable by any user wishing to do so. Keys in these keyrings can already load kernels and kernel modules, so there is no security downgrade.
Add a kconfig each, like dm-verity does, but default to enabled if the dependencies are available.
Signed-off-by Luca Boccassi <[email protected]>---
v2: addKconfigentries following the dm-verity model
update documentationDocumentation/admin-guide/LSM/ipe.rst | 5 ++++- security/ipe/Kconfig | 19 +++++++++++++++++++ security/ipe/policy.c | 14 +++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-)security/ipe/policy.c +0
-0@@ -169,9 +169,21 @@ struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, goto err; }
Quoted 14 lines
security/ipe/policy.c struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, · line 181
Quoted 11 lines
security/ipe/policy.c +8
-1- rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len,NULL , + rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +#ifdef CONFIG_IPE_POLICY_SIG_SECONDARY_KEYRING +VERIFY_USE_SECONDARY_KEYRING , +#else +NULL , +#endifVERIFYING_UNSPECIFIED_SIGNATURE , set_pkcs7_data, new); +#ifdef CONFIG_IPE_POLICY_SIG_PLATFORM_KEYRING +if (rc == -ENOKEY )If the secondary key *is* there, but returns
-EKEYREJECTED, do you want to fall back to trying the platform keyring, or not?
I like the idea in principle, however for ease of use personally I'd prefer if the behaviour was the same as dm-verity, given the close relationship - maybe we can start with this version, then I can propose the same change in a single series for both components later, so that we either change it in both or neither. Would that work?
Quoted 59 lines · Luca Boccassi
Quoted 43 lines · Serge E. Hallyn
Quoted 41 lines · On Sun, Sep 15, 2024 at 11:11:19AM +0200, [email protected] wrote:
From: Luca Boccassi <[email protected]>
The current policy management makes it impossible to use IPE in a general purpose distribution. In such cases the users are not building the kernel, the distribution is, and access to the private key included in the trusted keyring is, for obvious reason, not available.
This means that users have no way to enable IPE, since there will be no built-in generic policy, and no access to the key to sign updates validated by the trusted keyring.Just as we do for dm-verity, kernel modules and more, allow the secondary and platform keyrings to also validate policies. This allows users enrolling their own keys in UEFI db or MOK to also sign policies, and enroll them. This makes it sensible to enable IPE in general purpose distributions, as it becomes usable by any user wishing to do so. Keys in these keyrings can already load kernels and kernel modules, so there is no security downgrade.
Add a kconfig each, like dm-verity does, but default to enabled if the dependencies are available.
Signed-off-by Luca Boccassi <[email protected]>---
v2: addKconfigentries following the dm-verity model
update documentationDocumentation/admin-guide/LSM/ipe.rst | 5 ++++- security/ipe/Kconfig | 19 +++++++++++++++++++ security/ipe/policy.c | 14 +++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-)security/ipe/policy.c +0
-0@@ -169,9 +169,21 @@ struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, goto err; }Quoted 14 lines
security/ipe/policy.c struct ipe_policy *ipe_new_policy(const char *text, size_t textlen, · line 181
Quoted 11 lines
security/ipe/policy.c +8
-1- rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len,NULL , + rc =verify_pkcs7_signature (NULL ,0 , new->pkcs7, pkcs7len, +#ifdef CONFIG_IPE_POLICY_SIG_SECONDARY_KEYRING +VERIFY_USE_SECONDARY_KEYRING , +#else +NULL , +#endifVERIFYING_UNSPECIFIED_SIGNATURE , set_pkcs7_data, new); +#ifdef CONFIG_IPE_POLICY_SIG_PLATFORM_KEYRING +if (rc == -ENOKEY )If the secondary key *is* there, but returns
-EKEYREJECTED, do you want to fall back to trying the platform keyring, or not?
Quoted 5 lines
I like the idea in principle, however for ease of use personally I'd prefer if the behaviour was the same as dm-verity, given the close relationship - maybe we can start with this version, then I can propose the same change in a single series for both components later, so that we either change it in both or neither. Would that work?
Sounds good, thanks.
-serge