0042-commands-hexdump-Disable-memory-reading-in-lockdown-.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From d5028a608b21c6fa6ff02e4d84a96ab28034d170 Mon Sep 17 00:00:00 2001
  2. From: B Horn <b@horn.uk>
  3. Date: Fri, 19 Apr 2024 22:31:45 +0100
  4. Subject: [PATCH] commands/hexdump: Disable memory reading in lockdown mode
  5. Reported-by: B Horn <b@horn.uk>
  6. Signed-off-by: B Horn <b@horn.uk>
  7. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  8. Upstream: 5f31164aed51f498957cdd6ed733ec71a8592c99
  9. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  10. ---
  11. grub-core/commands/hexdump.c | 7 ++++++-
  12. 1 file changed, 6 insertions(+), 1 deletion(-)
  13. diff --git a/grub-core/commands/hexdump.c b/grub-core/commands/hexdump.c
  14. index eaa12465b..d6f61d98a 100644
  15. --- a/grub-core/commands/hexdump.c
  16. +++ b/grub-core/commands/hexdump.c
  17. @@ -24,6 +24,7 @@
  18. #include <grub/lib/hexdump.h>
  19. #include <grub/extcmd.h>
  20. #include <grub/i18n.h>
  21. +#include <grub/lockdown.h>
  22. GRUB_MOD_LICENSE ("GPLv3+");
  23. @@ -51,7 +52,11 @@ grub_cmd_hexdump (grub_extcmd_context_t ctxt, int argc, char **args)
  24. length = (state[1].set) ? grub_strtoul (state[1].arg, 0, 0) : 256;
  25. if (!grub_strcmp (args[0], "(mem)"))
  26. - hexdump (skip, (char *) (grub_addr_t) skip, length);
  27. + {
  28. + if (grub_is_lockdown() == GRUB_LOCKDOWN_ENABLED)
  29. + return grub_error (GRUB_ERR_ACCESS_DENIED, N_("memory reading is disabled in lockdown mode"));
  30. + hexdump (skip, (char *) (grub_addr_t) skip, length);
  31. + }
  32. else if ((args[0][0] == '(') && (args[0][namelen - 1] == ')'))
  33. {
  34. grub_disk_t disk;
  35. --
  36. 2.50.1