Skip to contentSkip to conversation

integrity: Do not load MOK and MOKx when secure boot be disabled

PATCH In review Lee, Chun-Yi 3 participants 4 messages Dec 18, 2021 – Dec 23, 2021

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

PATCH 1/1 integrity: Do not load MOK and MOKx when secure boot be disabled

The security of Machine Owner Key (MOK) relies on secure boot. When secure boot is disabled, EFI firmware will not verify binary code. Then arbitrary efi binary code can modify MOK when rebooting.

This patch prevents MOK/MOKx be loaded when secure boot be disabled.

---
 security/integrity/platform_certs/load_uefi.c | 5 +++++
 1 file changed, 5 insertions(+)
security/integrity/platform_certs/load_uefi.c +5 -0
index f290f78c3f30..08b6d12f99b4 100644
@@ -6,6 +6,7 @@
 #include <linux/err.h>
 #include <linux/efi.h>
 #include <linux/slab.h>
+#include <linux/ima.h>
 #include <keys/asymmetric-type.h>
 #include <keys/system_keyring.h>
 #include "../integrity.h"
@@ -176,6 +177,10 @@ static int __init load_uefi_certs(void)
 		kfree(dbx);
 	}
 
+	/* the MOK/MOKx can not be trusted when secure boot is disabled */
+	if (!arch_ima_get_secureboot())
+		return 0;
+
 	mokx = get_cert_list(L"MokListXRT", &mok_var, &mokxsize, &status);
 	if (!mokx) {
 		if (status == EFI_NOT_FOUND)
Signature · 1 line
2.26.2
maintainer
#1 lore raw

Hi Joey,

Quoted 7 lines · Chun-Yi

The security of Machine Owner Key (MOK) relies on secure boot. When secure boot is disabled, EFI firmware will not verify binary code. Then arbitrary efi binary code can modify MOK when rebooting.

This patch prevents MOK/MOKx be loaded when secure boot be disabled.

Sorry for the delay in testing this patch. I got the booster Friday and am still suffering from fever spikes, chills, and headaches. The kexec selftest might need to be updated as well.

thanks,

Mimi

Quoted 27 lines
---
 security/integrity/platform_certs/load_uefi.c | 5 +++++
 1 file changed, 5 insertions(+)
security/integrity/platform_certs/load_uefi.c +5 -0
index f290f78c3f30..08b6d12f99b4 100644
@@ -6,6 +6,7 @@
 #include <linux/err.h>
 #include <linux/efi.h>
 #include <linux/slab.h>
+#include <linux/ima.h>
 #include <keys/asymmetric-type.h>
 #include <keys/system_keyring.h>
 #include "../integrity.h"
@@ -176,6 +177,10 @@ static int __init load_uefi_certs(void)
 		kfree(dbx);
 	}
 
+	/* the MOK/MOKx can not be trusted when secure boot is disabled */
+	if (!arch_ima_get_secureboot())
+		return 0;
+
 	mokx = get_cert_list(L"MokListXRT", &mok_var, &mokxsize, &status);
 	if (!mokx) {
 		if (status == EFI_NOT_FOUND)
maintainer
#2 lore raw
In reply to Lee, Chun-Yi
Quoted 7 lines · Chun-Yi

The security of Machine Owner Key (MOK) relies on secure boot. When secure boot is disabled, EFI firmware will not verify binary code. Then arbitrary efi binary code can modify MOK when rebooting.

This patch prevents MOK/MOKx be loaded when secure boot be disabled.

Thanks, Joey!

This patch is now queued in the next-integrity-testing branch waiting further review/tags.

Mimi

#3 lore raw

Hi Mimi,

Quoted 7 lines · Mimi Zohar
Quoted 6 lines · Chun-Yi

The security of Machine Owner Key (MOK) relies on secure boot. When secure boot is disabled, EFI firmware will not verify binary code. Then arbitrary efi binary code can modify MOK when rebooting.

This patch prevents MOK/MOKx be loaded when secure boot be disabled.

Quoted 8 lines
Quoted 1 line

Thanks, Joey!

This patch is now queued in the next-integrity-testing branch waiting further review/tags.

Mimi

Thanks for your review!
Joey Lee