[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/18] dl: provide a fake grub_dl_set_persistent for the emu targ
From: |
Daniel Axtens |
Subject: |
[PATCH 03/18] dl: provide a fake grub_dl_set_persistent for the emu target |
Date: |
Fri, 2 Oct 2020 15:13:06 +1000 |
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 <dja@axtens.net>
---
include/grub/dl.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/grub/dl.h b/include/grub/dl.h
index f03c03561a15..941e68abe63b 100644
--- a/include/grub/dl.h
+++ b/include/grub/dl.h
@@ -241,11 +241,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)
--
2.25.1
- [PATCH 00/18] Verify appended signatures from grub, Daniel Axtens, 2020/10/02
- [PATCH 01/18] docs/grub: grub-install is no longer a shell script, Daniel Axtens, 2020/10/02
- [PATCH 02/18] docs/grub: --pubkey has been supported for some time, Daniel Axtens, 2020/10/02
- [PATCH 03/18] dl: provide a fake grub_dl_set_persistent for the emu target,
Daniel Axtens <=
- [PATCH 04/18] verifiers: factor unsafe module handling out of shim_lock, Daniel Axtens, 2020/10/02
- [PATCH 05/18] pgp: factor out rsa_pad, Daniel Axtens, 2020/10/02
- [PATCH 07/18] posix_wrap: tweaks in preparation for libtasn1, Daniel Axtens, 2020/10/02
- [PATCH 06/18] crypto: move storage for grub_crypto_pk_* to crypto.c, Daniel Axtens, 2020/10/02
- [PATCH 09/18] libtasn1: disable code not needed in grub, Daniel Axtens, 2020/10/02
- [PATCH 08/18] libtasn1: import libtasn1-4.16.0, Daniel Axtens, 2020/10/02
- [PATCH 10/18] libtasn1: changes for grub compatibility, Daniel Axtens, 2020/10/02
- [PATCH 11/18] libtasn1: compile into asn1 module, Daniel Axtens, 2020/10/02