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