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

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