|
| 1 | +From 05d3698b8b03eccc49e53491bbd75dba15f40917 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Alec Brown <alec.r.brown@oracle.com> |
| 3 | +Date: Thu, 21 Aug 2025 21:14:07 +0000 |
| 4 | +Subject: [PATCH] normal/main: Unregister commands on module unload |
| 5 | + |
| 6 | +When the normal module is loaded, the normal and normal_exit commands |
| 7 | +are registered but aren't unregistered when the module is unloaded. We |
| 8 | +need to add calls to grub_unregister_command() when unloading the module |
| 9 | +for these commands. |
| 10 | + |
| 11 | +Fixes: CVE-2025-61663 |
| 12 | +Fixes: CVE-2025-61664 |
| 13 | + |
| 14 | +Reported-by: Alec Brown <alec.r.brown@oracle.com> |
| 15 | +Signed-off-by: Alec Brown <alec.r.brown@oracle.com> |
| 16 | +Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> |
| 17 | + |
| 18 | +Upstream Patch Reference: https://gitweb.git.savannah.gnu.org/gitweb/?p=grub.git;a=patch;h=05d3698b8b03eccc49e53491bbd75dba15f40917 |
| 19 | +--- |
| 20 | + grub-core/normal/main.c | 12 +++++++----- |
| 21 | + 1 file changed, 7 insertions(+), 5 deletions(-) |
| 22 | + |
| 23 | +diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c |
| 24 | +index c4ebe9e..65fa95b 100644 |
| 25 | +--- a/grub-core/normal/main.c |
| 26 | ++++ b/grub-core/normal/main.c |
| 27 | +@@ -499,7 +499,7 @@ grub_mini_cmd_clear (struct grub_command *cmd __attribute__ ((unused)), |
| 28 | + return 0; |
| 29 | + } |
| 30 | + |
| 31 | +-static grub_command_t cmd_clear; |
| 32 | ++static grub_command_t cmd_clear, cmd_normal, cmd_normal_exit; |
| 33 | + |
| 34 | + static void (*grub_xputs_saved) (const char *str); |
| 35 | + static const char *features[] = { |
| 36 | +@@ -541,10 +541,10 @@ GRUB_MOD_INIT(normal) |
| 37 | + grub_env_export ("pager"); |
| 38 | + |
| 39 | + /* Register a command "normal" for the rescue mode. */ |
| 40 | +- grub_register_command ("normal", grub_cmd_normal, |
| 41 | +- 0, N_("Enter normal mode.")); |
| 42 | +- grub_register_command ("normal_exit", grub_cmd_normal_exit, |
| 43 | +- 0, N_("Exit from normal mode.")); |
| 44 | ++ cmd_normal = grub_register_command ("normal", grub_cmd_normal, |
| 45 | ++ 0, N_("Enter normal mode.")); |
| 46 | ++ cmd_normal_exit = grub_register_command ("normal_exit", grub_cmd_normal_exit, |
| 47 | ++ 0, N_("Exit from normal mode.")); |
| 48 | + |
| 49 | + /* Reload terminal colors when these variables are written to. */ |
| 50 | + grub_register_variable_hook ("color_normal", NULL, grub_env_write_color_normal); |
| 51 | +@@ -584,4 +584,6 @@ GRUB_MOD_FINI(normal) |
| 52 | + grub_register_variable_hook ("pager", 0, 0); |
| 53 | + grub_fs_autoload_hook = 0; |
| 54 | + grub_unregister_command (cmd_clear); |
| 55 | ++ grub_unregister_command (cmd_normal); |
| 56 | ++ grub_unregister_command (cmd_normal_exit); |
| 57 | + } |
| 58 | +-- |
| 59 | +2.43.0 |
| 60 | + |
0 commit comments