Skip to contentSkip to conversation

ima: require signed IMA policy when UEFI secure boot is enabled

PATCH Superseded Coiby Xu 2 participants 6 messages Jul 3, 2023 – Jul 27, 2023

Subsystems (4)
lore
Share & tools
lore

Coiby Xu

author
#0 lore raw

PATCH 1/1 ima: require signed IMA policy when UEFI secure boot is enabled

With the introduction of the .machine keyring for UEFI-based systems, users are able to add custom CAs keys via MOK. This allow users to sign their own IMA polices. For the sake of security, mandate signed IMA policy when UEFI secure boot is enabled.

---
 security/integrity/ima/ima_efi.c | 3 +++
 1 file changed, 3 insertions(+)
security/integrity/ima/ima_efi.c +3 -0
index 9db66fe310d4..bb2881759505 100644
@@ -58,6 +58,9 @@ static const char * const sb_arch_rules[] = {
 #if !IS_ENABLED(CONFIG_MODULE_SIG)
 	"appraise func=MODULE_CHECK appraise_type=imasig",
 #endif
+#if IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) && IS_ENABLED(CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY)
+	"appraise func=POLICY_CHECK appraise_type=imasig",
+#endif /* CONFIG_INTEGRITY_MACHINE_KEYRING && IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY */
 	"measure func=MODULE_CHECK",
 	NULL
 };
Signature · 1 line
2.41.0
maintainer
#1 lore raw
Quoted 16 lines · Coiby Xu

With the introduction of the .machine keyring for UEFI-based systems, users are able to add custom CAs keys via MOK. This allow users to sign their own IMA polices. For the sake of security, mandate signed IMA policy when UEFI secure boot is enabled.

---
 security/integrity/ima/ima_efi.c | 3 +++
 1 file changed, 3 insertions(+)
security/integrity/ima/ima_efi.c +0 -0
index 9db66fe310d4..bb2881759505 100644

security/integrity/ima/ima_efi.c static const char * const sb_arch_rules[] = { · line 66

Quoted 9 lines
security/integrity/ima/ima_efi.c +3 -0
@@ -58,6 +58,9 @@ static const char * const sb_arch_rules[] = {
 #if !IS_ENABLED(CONFIG_MODULE_SIG)
 	"appraise func=MODULE_CHECK appraise_type=imasig",
 #endif
+#if IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) && IS_ENABLED(CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY)
+	"appraise func=POLICY_CHECK appraise_type=imasig",
+#endif /* CONFIG_INTEGRITY_MACHINE_KEYRING && IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY */
 	"measure func=MODULE_CHECK",
 	NULL
 };

Thanks, Coiby.

Using IS_ENABLED() is not wrong, but unnecessary. IS_BUILTIN() suffices.

Signature · 3 lines
thanks,

Mimi
author
#2 lore raw
Quoted 12 lines · Mimi Zohar
Quoted 11 lines · Coiby Xu

With the introduction of the .machine keyring for UEFI-based systems, users are able to add custom CAs keys via MOK. This allow users to sign their own IMA polices. For the sake of security, mandate signed IMA policy when UEFI secure boot is enabled.

---
 security/integrity/ima/ima_efi.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 16 lines
Quoted 5 lines
security/integrity/ima/ima_efi.c +0 -0
index 9db66fe310d4..bb2881759505 100644

security/integrity/ima/ima_efi.c static const char * const sb_arch_rules[] = { · line 66

Quoted 9 lines
security/integrity/ima/ima_efi.c +3 -0
@@ -58,6 +58,9 @@ static const char * const sb_arch_rules[] = {
 #if !IS_ENABLED(CONFIG_MODULE_SIG)
 	"appraise func=MODULE_CHECK appraise_type=imasig",
 #endif
+#if IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) && IS_ENABLED(CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY)
+	"appraise func=POLICY_CHECK appraise_type=imasig",
+#endif /* CONFIG_INTEGRITY_MACHINE_KEYRING && IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY */
 	"measure func=MODULE_CHECK",
 	NULL
 };

Thanks, Coiby.

You are welcome!

Quoted 3 lines

Using IS_ENABLED() is not wrong, but unnecessary. IS_BUILTIN() suffices.

Thanks for the reminding! When I was going to apply this suggestion, I noticed ima_efi.c uses IS_ENABLED for all configuration items i.e. CONFIG_MODULE_SIG and CONFIG_KEXEC_SIG which are all of bool type. Would you like me to switch all IS_ENABLEs to IS_BUILTIN or still use IS_ENABLED? While IS_BUILTIN is exclusively for bool type, it's not as intuitive as IS_ENABLED. So it's not easy for me to make a choice.

Quoted 6 lines
Signature · 4 lines
-- 
thanks,

Mimi
Signature · 2 lines
Best regards,
Coiby
maintainer
#3 lore raw
Quoted 9 lines · Coiby Xu
Quoted 8 lines · Mimi Zohar
Quoted 7 lines · Coiby Xu

With the introduction of the .machine keyring for UEFI-based systems, users are able to add custom CAs keys via MOK. This allow users to sign their own IMA polices. For the sake of security, mandate signed IMA policy when UEFI secure boot is enabled.

With commit 099f26f22f58 ("integrity: machine keyring CA configuration") it is now possible to require signed IMA policies without having to recompile the kernel. Please note this change might affect existing users/tests.

Quoted 27 lines
Quoted 4 lines
Quoted 4 lines
---
 security/integrity/ima/ima_efi.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 16 lines
Quoted 5 lines
security/integrity/ima/ima_efi.c +0 -0
index 9db66fe310d4..bb2881759505 100644

security/integrity/ima/ima_efi.c static const char * const sb_arch_rules[] = { · line 66

Quoted 9 lines
security/integrity/ima/ima_efi.c +3 -0
@@ -58,6 +58,9 @@ static const char * const sb_arch_rules[] = {
 #if !IS_ENABLED(CONFIG_MODULE_SIG)
 	"appraise func=MODULE_CHECK appraise_type=imasig",
 #endif
+#if IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) && IS_ENABLED(CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY)
+	"appraise func=POLICY_CHECK appraise_type=imasig",
+#endif /* CONFIG_INTEGRITY_MACHINE_KEYRING && IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY */
 	"measure func=MODULE_CHECK",
 	NULL
 };

Thanks, Coiby.

You are welcome!

Quoted 3 lines

Using IS_ENABLED() is not wrong, but unnecessary. IS_BUILTIN() suffices.

Quoted 6 lines

Thanks for the reminding! When I was going to apply this suggestion, I noticed ima_efi.c uses IS_ENABLED for all configuration items i.e. CONFIG_MODULE_SIG and CONFIG_KEXEC_SIG which are all of bool type. Would you like me to switch all IS_ENABLEs to IS_BUILTIN or still use IS_ENABLED? While IS_BUILTIN is exclusively for bool type, it's not as intuitive as IS_ENABLED. So it's not easy for me to make a choice.

Sure, for consistency with the other rules IS_ENABLED is fine.

thanks,

Mimi

author
#4 lore raw

PATCH v2 1/1 ima: require signed IMA policy when UEFI secure boot is enabled

In reply to Coiby Xu

With commit 099f26f22f58 ("integrity: machine keyring CA configuration"), users are able to add custom IMA CA keys via MOK. This allows users to sign their own IMA polices without recompiling the kernel. For the sake of security, mandate signed IMA policy when UEFI secure boot is enabled.

Note this change may affect existing users/tests i.e users won't be able to load an unsigned IMA policy when the IMA architecture specific policy is configured and UEFI secure boot is enabled.

---
v2
- improve commit message [Mimi]
- explicitly mention the dependent commit
- add a note that the change will affect user space
- remove "/* CONFIG_INTEGRITY_MACHINE_KEYRING .. */" to improve code readability

---
 security/integrity/ima/ima_efi.c | 3 +++
 1 file changed, 3 insertions(+)
security/integrity/ima/ima_efi.c +3 -0
index 9db66fe310d4..138029bfcce1 100644
@@ -57,6 +57,9 @@ static const char * const sb_arch_rules[] = {
 	"measure func=KEXEC_KERNEL_CHECK",
 #if !IS_ENABLED(CONFIG_MODULE_SIG)
 	"appraise func=MODULE_CHECK appraise_type=imasig",
+#endif
+#if IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) && IS_ENABLED(CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY)
+	"appraise func=POLICY_CHECK appraise_type=imasig",
 #endif
 	"measure func=MODULE_CHECK",
 	NULL
Signature · 1 line
2.41.0
maintainer
#5 lore raw
Quoted 12 lines · Coiby Xu

With commit 099f26f22f58 ("integrity: machine keyring CA configuration"), users are able to add custom IMA CA keys via MOK. This allows users to sign their own IMA polices without recompiling the kernel. For the sake of security, mandate signed IMA policy when UEFI secure boot is enabled.

Note this change may affect existing users/tests i.e users won't be able to load an unsigned IMA policy when the IMA architecture specific policy is configured and UEFI secure boot is enabled.

Quoted 7 lines

---
v2
- improve commit message [Mimi]
- explicitly mention the dependent commit
- add a note that the change will affect user space
- remove "/* CONFIG_INTEGRITY_MACHINE_KEYRING .. */" to improve code readability

Thank you for updating the commit message. The patch is now queued in next-integrity-testing.

Signature · 3 lines
thanks,

Mimi