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

00e791
From 95bd1d88003a9a7c2732472b061ad2a9c7140419 Mon Sep 17 00:00:00 2001
9cb50d
From: Patrick Uiterwijk <patrick@puiterwijk.org>
9cb50d
Date: Thu, 6 Dec 2018 10:08:45 +0100
00e791
Subject: [PATCH 27/62] Make EFI variable copying fatal only on secureboot
00e791
 enabled 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>
00e791
Upstream-commit-id: 741c61abba7
9cb50d
---
00e791
 shim.c | 12 +++++++++++-
00e791
 1 file changed, 11 insertions(+), 1 deletion(-)
9cb50d
9cb50d
diff --git a/shim.c b/shim.c
00e791
index 0a95f94b360..d4ed332f901 100644
9cb50d
--- a/shim.c
9cb50d
+++ b/shim.c
00e791
@@ -2609,7 +2609,17 @@ efi_main (EFI_HANDLE passed_image_handle, EFI_SYSTEM_TABLE *passed_systab)
00e791
 	 * boot-services-only state variables are what we think they are.
00e791
 	 */
00e791
 	efi_status = import_mok_state(image_handle);
00e791
-	if (EFI_ERROR(efi_status)) {
00e791
+	if (!secure_mode() && efi_status == EFI_INVALID_PARAMETER) {
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
+		 */
00e791
+		console_print(L"Importing MOK states has failed: %s: %r\n",
00e791
+			      msgs[msg], efi_status);
00e791
+		console_print(L"Continuing boot since secure mode is disabled");
00e791
+	} else if (EFI_ERROR(efi_status)) {
00e791
 die:
00e791
 		console_print(L"Something has gone seriously wrong: %s: %r\n",
00e791
 			      msgs[msg], efi_status);
00e791
-- 
00e791
2.26.2
00e791