0210-Print-module-name-on-license-check-failure.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Robbie Harwood <rharwood@redhat.com>
  3. Date: Tue, 12 Oct 2021 12:34:23 -0400
  4. Subject: [PATCH] Print module name on license check failure
  5. At the very least, this will make it easier to track down the problem
  6. module - or, if something else has gone wrong, provide more information
  7. for debugging.
  8. Signed-off-by: Robbie Harwood <rharwood@redhat.com>
  9. ---
  10. grub-core/kern/dl.c | 10 ++++++----
  11. 1 file changed, 6 insertions(+), 4 deletions(-)
  12. diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
  13. index 9557254035e..f3044945742 100644
  14. --- a/grub-core/kern/dl.c
  15. +++ b/grub-core/kern/dl.c
  16. @@ -528,14 +528,16 @@ grub_dl_find_section_index (Elf_Ehdr *e, const char *name)
  17. Be sure to understand your license obligations.
  18. */
  19. static grub_err_t
  20. -grub_dl_check_license (Elf_Ehdr *e)
  21. +grub_dl_check_license (grub_dl_t mod, Elf_Ehdr *e)
  22. {
  23. Elf_Shdr *s = grub_dl_find_section (e, ".module_license");
  24. if (s && (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0
  25. || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0
  26. || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0))
  27. return GRUB_ERR_NONE;
  28. - return grub_error (GRUB_ERR_BAD_MODULE, "incompatible license");
  29. + return grub_error (GRUB_ERR_BAD_MODULE,
  30. + "incompatible license in module %s: %s", mod->name,
  31. + (char *) e + s->sh_offset);
  32. }
  33. static grub_err_t
  34. @@ -743,8 +745,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size)
  35. constitutes linking) and GRUB core being licensed under GPLv3+.
  36. Be sure to understand your license obligations.
  37. */
  38. - if (grub_dl_check_license (e)
  39. - || grub_dl_resolve_name (mod, e)
  40. + if (grub_dl_resolve_name (mod, e)
  41. + || grub_dl_check_license (mod, e)
  42. || grub_dl_resolve_dependencies (mod, e)
  43. || grub_dl_load_segments (mod, e)
  44. || grub_dl_resolve_symbols (mod, e)