2
1

0031-commands-extcmd-Missing-check-for-failed-allocation.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 239a16a303228574f61a82c6fbb041688dff65d0 Mon Sep 17 00:00:00 2001
  2. From: Lidong Chen <lidong.chen@oracle.com>
  3. Date: Fri, 22 Nov 2024 06:27:55 +0000
  4. Subject: [PATCH] commands/extcmd: Missing check for failed allocation
  5. The grub_extcmd_dispatcher() calls grub_arg_list_alloc() to allocate
  6. a grub_arg_list struct but it does not verify the allocation was successful.
  7. In case of failed allocation the NULL state pointer can be accessed in
  8. parse_option() through grub_arg_parse() which may lead to a security issue.
  9. Fixes: CVE-2024-45775
  10. Reported-by: Nils Langius <nils@langius.de>
  11. Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
  12. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  13. Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
  14. Upstream: 05be856a8c3aae41f5df90cab7796ab7ee34b872
  15. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  16. ---
  17. grub-core/commands/extcmd.c | 3 +++
  18. 1 file changed, 3 insertions(+)
  19. diff --git a/grub-core/commands/extcmd.c b/grub-core/commands/extcmd.c
  20. index 90a5ca24a..c236be13a 100644
  21. --- a/grub-core/commands/extcmd.c
  22. +++ b/grub-core/commands/extcmd.c
  23. @@ -49,6 +49,9 @@ grub_extcmd_dispatcher (struct grub_command *cmd, int argc, char **args,
  24. }
  25. state = grub_arg_list_alloc (ext, argc, args);
  26. + if (state == NULL)
  27. + return grub_errno;
  28. +
  29. if (grub_arg_parse (ext, argc, args, state, &new_args, &new_argc))
  30. {
  31. context.state = state;
  32. --
  33. 2.50.1