File 0011-commands-pgp-Unregister-the-check_signatures-hooks-o.patch of Package grub2.43007

From e36cb1907f5b54247e93ab9ca57b8788c5185fe5 Mon Sep 17 00:00:00 2001
From: B Horn <b@horn.uk>
Date: Fri, 1 Nov 2024 19:24:29 +0000
Subject: [PATCH 11/20] commands/pgp: Unregister the "check_signatures" hooks
 on module unload

If the hooks are not removed they can be called after the module has
been unloaded leading to an use-after-free.

Fixes: CVE-2025-0622

Reported-by: B Horn <b@horn.uk>
Signed-off-by: B Horn <b@horn.uk>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/commands/verify.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c
index 67cb1c7850..e58f8eb430 100644
--- a/grub-core/commands/verify.c
+++ b/grub-core/commands/verify.c
@@ -1034,6 +1034,8 @@ GRUB_MOD_INIT(verify)
 
 GRUB_MOD_FINI(verify)
 {
+  grub_register_variable_hook ("check_signatures", NULL, NULL);
+  grub_env_unset ("check_signatures");
   grub_file_filter_unregister (GRUB_FILE_FILTER_PUBKEY);
   grub_unregister_extcmd (cmd);
   grub_unregister_extcmd (cmd_trust);
-- 
2.48.1

openSUSE Build Service is sponsored by