* [PATCH] Print module name on license check failure
@ 2021-10-14 18:26 Robbie Harwood
2021-10-20 14:43 ` Daniel Kiper
0 siblings, 1 reply; 2+ messages in thread
From: Robbie Harwood @ 2021-10-14 18:26 UTC (permalink / raw)
To: grub-devel; +Cc: Robbie Harwood
At the very least, this will make it easier to track down the problem
module - or, if something else has gone wrong, provide more information
for debugging.
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
---
grub-core/kern/dl.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index 48f8a7907..90e83e4d4 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -457,14 +457,16 @@ grub_dl_find_section (Elf_Ehdr *e, const char *name)
Be sure to understand your license obligations.
*/
static grub_err_t
-grub_dl_check_license (Elf_Ehdr *e)
+grub_dl_check_license (grub_dl_t mod, Elf_Ehdr *e)
{
Elf_Shdr *s = grub_dl_find_section (e, ".module_license");
if (s && (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0
|| grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0
|| grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0))
return GRUB_ERR_NONE;
- return grub_error (GRUB_ERR_BAD_MODULE, "incompatible license");
+ return grub_error (GRUB_ERR_BAD_MODULE,
+ "incompatible license in module %s: %s", mod->name,
+ (char *) e + s->sh_offset);
}
static grub_err_t
@@ -641,8 +643,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size)
constitutes linking) and GRUB core being licensed under GPLv3+.
Be sure to understand your license obligations.
*/
- if (grub_dl_check_license (e)
- || grub_dl_resolve_name (mod, e)
+ if (grub_dl_resolve_name (mod, e)
+ || grub_dl_check_license (mod, e)
|| grub_dl_resolve_dependencies (mod, e)
|| grub_dl_load_segments (mod, e)
|| grub_dl_resolve_symbols (mod, e)
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Print module name on license check failure
2021-10-14 18:26 [PATCH] Print module name on license check failure Robbie Harwood
@ 2021-10-20 14:43 ` Daniel Kiper
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2021-10-20 14:43 UTC (permalink / raw)
To: Robbie Harwood; +Cc: grub-devel
On Thu, Oct 14, 2021 at 02:26:35PM -0400, Robbie Harwood wrote:
> At the very least, this will make it easier to track down the problem
> module - or, if something else has gone wrong, provide more information
> for debugging.
>
> Signed-off-by: Robbie Harwood <rharwood@redhat.com>
> ---
> grub-core/kern/dl.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
> index 48f8a7907..90e83e4d4 100644
> --- a/grub-core/kern/dl.c
> +++ b/grub-core/kern/dl.c
> @@ -457,14 +457,16 @@ grub_dl_find_section (Elf_Ehdr *e, const char *name)
> Be sure to understand your license obligations.
> */
> static grub_err_t
> -grub_dl_check_license (Elf_Ehdr *e)
> +grub_dl_check_license (grub_dl_t mod, Elf_Ehdr *e)
> {
> Elf_Shdr *s = grub_dl_find_section (e, ".module_license");
> if (s && (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0
> || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0
> || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0))
> return GRUB_ERR_NONE;
> - return grub_error (GRUB_ERR_BAD_MODULE, "incompatible license");
> + return grub_error (GRUB_ERR_BAD_MODULE,
> + "incompatible license in module %s: %s", mod->name,
> + (char *) e + s->sh_offset);
> }
>
> static grub_err_t
> @@ -641,8 +643,8 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size)
> constitutes linking) and GRUB core being licensed under GPLv3+.
> Be sure to understand your license obligations.
> */
> - if (grub_dl_check_license (e)
> - || grub_dl_resolve_name (mod, e)
> + if (grub_dl_resolve_name (mod, e)
> + || grub_dl_check_license (mod, e)
I think you should explain in the commit message why you change the
order of these functions calls. Otherwise LGTM.
Daniel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-20 14:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 18:26 [PATCH] Print module name on license check failure Robbie Harwood
2021-10-20 14:43 ` Daniel Kiper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.