Skip to contentSkip to conversation

x86/ima: Check EFI_RUNTIME_SERVICES before using

PATCH In review Scott Wood 2 participants 2 messages Apr 23, 2019 – Apr 25, 2019

Subsystems (2)
lore
Share & tools
lore

Scott Wood

author
#0 lore raw

PATCH 1/1 x86/ima: Check EFI_RUNTIME_SERVICES before using

Checking efi_enabled(EFI_BOOT) is not sufficient to ensure that EFI runtime services are available, e.g. if efi=noruntime is used.

Without this, I get an oops on a PREEMPT_RT kernel where efi=noruntime is the default.

Fixes 399574c64eaf94e8 ("x86/ima: retry detecting secure boot mode")
---
 arch/x86/kernel/ima_arch.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/x86/kernel/ima_arch.c +5 -0
index e47cd9390ab4..2a2e87717bad 100644
@@ -17,6 +17,11 @@ static enum efi_secureboot_mode get_sb_mode(void)
 
 	size = sizeof(secboot);
 
+	if (!efi_enabled(EFI_RUNTIME_SERVICES)) {
+		pr_info("ima: secureboot mode unknown, no efi\n");
+		return efi_secureboot_mode_unknown;
+	}
+
 	/* Get variable contents into buffer */
 	status = efi.get_variable(efi_SecureBoot_name, &efi_variable_guid,
 				  NULL, &size, &secboot);
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 8 lines · Scott Wood

Checking efi_enabled(EFI_BOOT) is not sufficient to ensure that EFI runtime services are available, e.g. if efi=noruntime is used.

Without this, I get an oops on a PREEMPT_RT kernel where efi=noruntime is the default.

Fixes 399574c64eaf94e8 ("x86/ima: retry detecting secure boot mode")

Thanks!

Quoted 20 lines
---
 arch/x86/kernel/ima_arch.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/x86/kernel/ima_arch.c +5 -0
index e47cd9390ab4..2a2e87717bad 100644
@@ -17,6 +17,11 @@ static enum efi_secureboot_mode get_sb_mode(void)
 
 	size = sizeof(secboot);
 
+	if (!efi_enabled(EFI_RUNTIME_SERVICES)) {
+		pr_info("ima: secureboot mode unknown, no efi\n");
+		return efi_secureboot_mode_unknown;
+	}
+
 	/* Get variable contents into buffer */
 	status = efi.get_variable(efi_SecureBoot_name, &efi_variable_guid,
 				  NULL, &size, &secboot);