Blame SOURCES/0031-Hook-exit-when-shim_lock-protocol-installed.patch

d1e1c8
From b5e10f70c7a495dc1788e3604803ee633f1e5f76 Mon Sep 17 00:00:00 2001
d1e1c8
From: Stuart Hayes <stuart.w.hayes@gmail.com>
d1e1c8
Date: Fri, 8 Feb 2019 15:48:20 -0500
d1e1c8
Subject: [PATCH 31/62] Hook exit when shim_lock protocol installed
d1e1c8
d1e1c8
A recent commit moved where the shim_lock protocol is loaded and
d1e1c8
unloaded, but did not move where exit was hooked and unhooked.  Exit
d1e1c8
needs to be hooked when the protocol is installed, so that the protocol
d1e1c8
will be uninstalled on exit.  Otherwise, the system can crash if, for
d1e1c8
example, shim loads grub, the user exits grub, shim is run again, which
d1e1c8
installs a second instance of the protocol, and then grub tries to use
d1e1c8
the shim_lock protocol that was installed by the first instance of shim.
d1e1c8
d1e1c8
Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>
d1e1c8
Upstream-commit-id: 06c92591e94
d1e1c8
---
d1e1c8
 shim.c | 5 +++--
d1e1c8
 1 file changed, 3 insertions(+), 2 deletions(-)
d1e1c8
d1e1c8
diff --git a/shim.c b/shim.c
d1e1c8
index f69e69487fc..16911a37b17 100644
d1e1c8
--- a/shim.c
d1e1c8
+++ b/shim.c
d1e1c8
@@ -2474,9 +2474,9 @@ shim_init(void)
d1e1c8
 			loader_is_participating = 0;
d1e1c8
 		}
d1e1c8
 
d1e1c8
-		hook_exit(systab);
d1e1c8
 	}
d1e1c8
 
d1e1c8
+	hook_exit(systab);
d1e1c8
 	return install_shim_protocols();
d1e1c8
 }
d1e1c8
 
d1e1c8
@@ -2494,9 +2494,10 @@ shim_fini(void)
d1e1c8
 		 * Remove our hooks from system services.
d1e1c8
 		 */
d1e1c8
 		unhook_system_services();
d1e1c8
-		unhook_exit();
d1e1c8
 	}
d1e1c8
 
d1e1c8
+	unhook_exit();
d1e1c8
+
d1e1c8
 	/*
d1e1c8
 	 * Free the space allocated for the alternative 2nd stage loader
d1e1c8
 	 */
d1e1c8
-- 
d1e1c8
2.26.2
d1e1c8