Blame SOURCES/0001-Make-sure-that-MOK-variables-always-get-mirrored.patch

12f6e9
From 9ab0d796bdc9cefdaa3b0df7434845d26c43d894 Mon Sep 17 00:00:00 2001
12f6e9
From: Patrick Uiterwijk <patrick@puiterwijk.org>
12f6e9
Date: Mon, 5 Nov 2018 14:51:16 +0100
12f6e9
Subject: [PATCH 1/3] Make sure that MOK variables always get mirrored
12f6e9
12f6e9
Without this, if a Mok variable doesn't exist in Boot Services, it will also
12f6e9
not be copied to Runtime, even if we have data to be added to it (vendor cert).
12f6e9
This patch makes sure that if we have extra data to append, we still mirror
12f6e9
the variable.
12f6e9
12f6e9
Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
12f6e9
---
12f6e9
 mok.c | 20 ++++++++++++++++----
12f6e9
 1 file changed, 16 insertions(+), 4 deletions(-)
12f6e9
12f6e9
diff --git a/mok.c b/mok.c
12f6e9
index 38675211e0e..00dd1ad3034 100644
12f6e9
--- a/mok.c
12f6e9
+++ b/mok.c
12f6e9
@@ -223,11 +223,26 @@ EFI_STATUS import_mok_state(EFI_HANDLE image_handle)
12f6e9
 		UINT32 attrs = 0;
12f6e9
 		BOOLEAN delete = FALSE, present, addend;
12f6e9
 
12f6e9
+		addend = (v->addend_source && v->addend_size &&
12f6e9
+			  *v->addend_source && *v->addend_size)
12f6e9
+			? TRUE : FALSE;
12f6e9
+
12f6e9
 		efi_status = get_variable_attr(v->name,
12f6e9
 					       &v->data, &v->data_size,
12f6e9
 					       *v->guid, &attrs);
12f6e9
-		if (efi_status == EFI_NOT_FOUND)
12f6e9
+		if (efi_status == EFI_NOT_FOUND) {
12f6e9
+			if (v->rtname && addend) {
12f6e9
+				efi_status = mirror_one_mok_variable(v);
12f6e9
+				if (EFI_ERROR(efi_status) &&
12f6e9
+				    ret != EFI_SECURITY_VIOLATION)
12f6e9
+					ret = efi_status;
12f6e9
+			}
12f6e9
+			/*
12f6e9
+			 * after possibly adding, we can continue, no
12f6e9
+			 * further checks to be done.
12f6e9
+			 */
12f6e9
 			continue;
12f6e9
+		}
12f6e9
 		if (EFI_ERROR(efi_status)) {
12f6e9
 			perror(L"Could not verify %s: %r\n", v->name,
12f6e9
 			       efi_status);
12f6e9
@@ -272,9 +287,6 @@ EFI_STATUS import_mok_state(EFI_HANDLE image_handle)
12f6e9
 		}
12f6e9
 
12f6e9
 		present = (v->data && v->data_size) ? TRUE : FALSE;
12f6e9
-		addend = (v->addend_source && v->addend_size &&
12f6e9
-			  *v->addend_source && *v->addend_size)
12f6e9
-			? TRUE : FALSE;
12f6e9
 
12f6e9
 		if (v->flags & MOK_VARIABLE_MEASURE && present) {
12f6e9
 			/*
12f6e9
-- 
12f6e9
2.20.1
12f6e9