0033-commands-pgp-Unregister-the-check_signatures-hooks-o.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From c05c4d591ef5f21fefd95fc928fe123a12f2bfb0 Mon Sep 17 00:00:00 2001
  2. From: B Horn <b@horn.uk>
  3. Date: Fri, 1 Nov 2024 19:24:29 +0000
  4. Subject: [PATCH] commands/pgp: Unregister the "check_signatures" hooks on
  5. module unload
  6. If the hooks are not removed they can be called after the module has
  7. been unloaded leading to an use-after-free.
  8. Fixes: CVE-2025-0622
  9. Reported-by: B Horn <b@horn.uk>
  10. Signed-off-by: B Horn <b@horn.uk>
  11. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  12. Upstream: 2123c5bca7e21fbeb0263df4597ddd7054700726
  13. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  14. ---
  15. grub-core/commands/pgp.c | 2 ++
  16. 1 file changed, 2 insertions(+)
  17. diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c
  18. index c6766f044..5fadc33c4 100644
  19. --- a/grub-core/commands/pgp.c
  20. +++ b/grub-core/commands/pgp.c
  21. @@ -1010,6 +1010,8 @@ GRUB_MOD_INIT(pgp)
  22. GRUB_MOD_FINI(pgp)
  23. {
  24. + grub_register_variable_hook ("check_signatures", NULL, NULL);
  25. + grub_env_unset ("check_signatures");
  26. grub_verifier_unregister (&grub_pubkey_verifier);
  27. grub_unregister_extcmd (cmd);
  28. grub_unregister_extcmd (cmd_trust);
  29. --
  30. 2.50.1