On Thu, Mar 27, 2025 at 01:02:25AM +0530, Sudhakar Kuppusamy wrote:
> From: Daniel Axtens <d...@axtens.net>
>
> Trying to start grub-emu with a module that calls grub_dl_set_persistent
> will crash because grub-emu fakes modules and passes NULL to the module
> init function.
>
> Provide an empty function for the emu case.
>
> Fixes: ee7808e2197c (dl: Add support for persistent modules)
> Signed-off-by: Daniel Axtens <d...@axtens.net>
> Signed-off-by: Sudhakar Kuppusamy <sudha...@linux.ibm.com>
> Reviewed-by: Stefan Berger <stef...@linux.ibm.com>
> Reviewed-by: Avnish Chouhan <avn...@linux.ibm.com>
> ---
>  include/grub/dl.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/include/grub/dl.h b/include/grub/dl.h
> index 84509c5c1..43e411fef 100644
> --- a/include/grub/dl.h
> +++ b/include/grub/dl.h
> @@ -242,11 +242,22 @@ grub_dl_get (const char *name)
>    return 0;
>  }
>
> +#ifdef GRUB_MACHINE_EMU
> +/*
> + * Under grub-emu, modules are faked and NULL is passed to GRUB_MOD_INIT.
> + * So we fake this out to avoid a NULL deref.
> + */
> +static inline void
> +grub_dl_set_persistent (grub_dl_t mod __attribute__((unused)))
> +{
> +}
> +#else
>  static inline void
>  grub_dl_set_persistent (grub_dl_t mod)
>  {
>    mod->persistent = 1;
>  }
> +#endif
>
>  static inline int
>  grub_dl_is_persistent (grub_dl_t mod)

You will have the same problem with this function...

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to