arrfab / rpms / shim

Forked from rpms/shim 5 years ago
Clone
9cb50d
From 9a2dd0a945720634b9f3608c3b3dfb99fafd4465 Mon Sep 17 00:00:00 2001
9cb50d
From: Patrick Uiterwijk <patrick@puiterwijk.org>
9cb50d
Date: Thu, 6 Dec 2018 10:08:45 +0100
9cb50d
Subject: [PATCH] Make EFI variable copying fatal only on secureboot enabled
9cb50d
 systems
9cb50d
9cb50d
I have come across systems that are unwilling to reserve enough memory for
9cb50d
a MokListRT big enough for big certificates.
9cb50d
This seems to be the case with firmware implementations that do not support
9cb50d
secureboot, which is probably the reason they went with much lower variable
9cb50d
storage.
9cb50d
9cb50d
This patch set makes sure we can still boot on those systems, by only
9cb50d
making the copy action fatal if the system has secure boot enabled, or if
9cb50d
the error was anything other than EFI_INVALID_PARAMETER.
9cb50d
9cb50d
Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
9cb50d
---
9cb50d
 shim.c | 14 +++++++++++---
9cb50d
 1 file changed, 11 insertions(+), 3 deletions(-)
9cb50d
9cb50d
diff --git a/shim.c b/shim.c
9cb50d
index fcc11eb3..89ef0036 100644
9cb50d
--- a/shim.c
9cb50d
+++ b/shim.c
9cb50d
@@ -2632,9 +2632,17 @@ efi_main (EFI_HANDLE passed_image_handle, EFI_SYSTEM_TABLE *passed_systab)
9cb50d
 die:
9cb50d
 		console_print(L"Something has gone seriously wrong: %s: %r\n",
9cb50d
 			      msgs[msg], efi_status);
9cb50d
-		msleep(5000000);
9cb50d
-		gRT->ResetSystem(EfiResetShutdown, EFI_SECURITY_VIOLATION,
9cb50d
-				 0, NULL);
9cb50d
+		/*
9cb50d
+		 * Make copy failures fatal only if secure_mode is enabled, or
9cb50d
+		 * the error was anything else than EFI_INVALID_PARAMETER.
9cb50d
+		 * There are non-secureboot firmware implementations that don't
9cb50d
+		 * reserve enough EFI variable memory to fit the variable.
9cb50d
+		 */
9cb50d
+		if (secure_mode() || efi_status != EFI_INVALID_PARAMETER) {
9cb50d
+			msleep(5000000);
9cb50d
+			gRT->ResetSystem(EfiResetShutdown, EFI_SECURITY_VIOLATION,
9cb50d
+					 0, NULL);
9cb50d
+		}
9cb50d
 	}
9cb50d
 
9cb50d
 	efi_status = shim_init();