fix(shim): don't overwrite original handlers when already hooked

If the security hook was installed while already installed, the
protocols contained Sprout's own handlers, which were then saved as the
"original" handlers. A verification failure would then call back into
the hook forever. Keep the existing saved state in that case.
This commit is contained in:
alex authored and Alex Zenla committed 2026-09-26 18:58:54 -07:00
1 parent ad37a2bcf3
commit bcc78fd4a3
1 file changed
+7
+7
View File
@@ -216,6 +216,13 @@ impl SecurityHook {
// Acquire the lock to the global state and replace it. // Acquire the lock to the global state and replace it.
let mut global_state = GLOBAL_HOOK_STATE.lock(); let mut global_state = GLOBAL_HOOK_STATE.lock();
// If the hook is already installed, the protocols contain our hooks.
// Storing them as the original hooks would cause infinite recursion on
// verification failure, so keep the existing state instead.
if global_state.is_some() {
return Ok(true);
}
global_state.replace(state); global_state.replace(state);
// Install the hooks into the UEFI stack. // Install the hooks into the UEFI stack.