Blame SOURCES/0027-Make-EFI-variable-copying-fatal-only-on-secureboot-e.patch

6a35ff
From 95bd1d88003a9a7c2732472b061ad2a9c7140419 Mon Sep 17 00:00:00 2001
6a35ff
From: Patrick Uiterwijk <patrick@puiterwijk.org>
6a35ff
Date: Thu, 6 Dec 2018 10:08:45 +0100
6a35ff
Subject: [PATCH 27/62] Make EFI variable copying fatal only on secureboot
6a35ff
 enabled systems
6a35ff
6a35ff
I have come across systems that are unwilling to reserve enough memory for
6a35ff
a MokListRT big enough for big certificates.
6a35ff
This seems to be the case with firmware implementations that do not support
6a35ff
secureboot, which is probably the reason they went with much lower variable
6a35ff
storage.
6a35ff
6a35ff
This patch set makes sure we can still boot on those systems, by only
6a35ff
making the copy action fatal if the system has secure boot enabled, or if
6a35ff
the error was anything other than EFI_INVALID_PARAMETER.
6a35ff
6a35ff
Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
6a35ff
Upstream-commit-id: 741c61abba7
6a35ff
---
6a35ff
 shim.c | 12 +++++++++++-
6a35ff
 1 file changed, 11 insertions(+), 1 deletion(-)
6a35ff
6a35ff
diff --git a/shim.c b/shim.c
6a35ff
index 0a95f94b360..d4ed332f901 100644
6a35ff
--- a/shim.c
6a35ff
+++ b/shim.c
6a35ff
@@ -2609,7 +2609,17 @@ efi_main (EFI_HANDLE passed_image_handle, EFI_SYSTEM_TABLE *passed_systab)
6a35ff
 	 * boot-services-only state variables are what we think they are.
6a35ff
 	 */
6a35ff
 	efi_status = import_mok_state(image_handle);
6a35ff
-	if (EFI_ERROR(efi_status)) {
6a35ff
+	if (!secure_mode() && efi_status == EFI_INVALID_PARAMETER) {
6a35ff
+		/*
6a35ff
+		 * Make copy failures fatal only if secure_mode is enabled, or
6a35ff
+		 * the error was anything else than EFI_INVALID_PARAMETER.
6a35ff
+		 * There are non-secureboot firmware implementations that don't
6a35ff
+		 * reserve enough EFI variable memory to fit the variable.
6a35ff
+		 */
6a35ff
+		console_print(L"Importing MOK states has failed: %s: %r\n",
6a35ff
+			      msgs[msg], efi_status);
6a35ff
+		console_print(L"Continuing boot since secure mode is disabled");
6a35ff
+	} else if (EFI_ERROR(efi_status)) {
6a35ff
 die:
6a35ff
 		console_print(L"Something has gone seriously wrong: %s: %r\n",
6a35ff
 			      msgs[msg], efi_status);
6a35ff
-- 
6a35ff
2.26.2
6a35ff