|
|
3efed6 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
3efed6 |
From: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
3efed6 |
Date: Tue, 2 Oct 2018 18:49:26 +0200
|
|
|
3efed6 |
Subject: [PATCH] dl: Add support for persistent modules
|
|
|
3efed6 |
|
|
|
3efed6 |
This type of modules cannot be unloaded. This is useful if a given
|
|
|
3efed6 |
functionality, e.g. UEFI secure boot shim signature verification, should
|
|
|
3efed6 |
not be disabled if it was enabled at some point in time. Somebody may
|
|
|
3efed6 |
say that we can use standalone GRUB2 here. That is true. However, the
|
|
|
3efed6 |
code is not so big nor complicated hence it make sense to support
|
|
|
3efed6 |
modularized configs too.
|
|
|
3efed6 |
|
|
|
3efed6 |
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
3efed6 |
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
|
|
|
3efed6 |
(cherry picked from commit ee7808e2197cbf5e8515d90ecbd81c9d0dd6fc15)
|
|
|
3efed6 |
---
|
|
|
3efed6 |
grub-core/commands/minicmd.c | 3 +++
|
|
|
3efed6 |
include/grub/dl.h | 13 +++++++++++++
|
|
|
3efed6 |
2 files changed, 16 insertions(+)
|
|
|
3efed6 |
|
|
|
3efed6 |
diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c
|
|
|
b71686 |
index 46bf135e8..6d66b7c45 100644
|
|
|
3efed6 |
--- a/grub-core/commands/minicmd.c
|
|
|
3efed6 |
+++ b/grub-core/commands/minicmd.c
|
|
|
3efed6 |
@@ -137,6 +137,9 @@ grub_mini_cmd_rmmod (struct grub_command *cmd __attribute__ ((unused)),
|
|
|
3efed6 |
if (! mod)
|
|
|
3efed6 |
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no such module");
|
|
|
3efed6 |
|
|
|
3efed6 |
+ if (grub_dl_is_persistent (mod))
|
|
|
3efed6 |
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "cannot unload persistent module");
|
|
|
3efed6 |
+
|
|
|
3efed6 |
if (grub_dl_unref (mod) <= 0)
|
|
|
3efed6 |
grub_dl_unload (mod);
|
|
|
3efed6 |
|
|
|
3efed6 |
diff --git a/include/grub/dl.h b/include/grub/dl.h
|
|
|
b71686 |
index 7b5bfb07c..f7cfe6482 100644
|
|
|
3efed6 |
--- a/include/grub/dl.h
|
|
|
3efed6 |
+++ b/include/grub/dl.h
|
|
|
3efed6 |
@@ -177,6 +177,7 @@ struct grub_dl
|
|
|
3efed6 |
{
|
|
|
3efed6 |
char *name;
|
|
|
3efed6 |
int ref_count;
|
|
|
3efed6 |
+ int persistent;
|
|
|
3efed6 |
grub_dl_dep_t dep;
|
|
|
3efed6 |
grub_dl_segment_t segment;
|
|
|
3efed6 |
Elf_Sym *symtab;
|
|
|
3efed6 |
@@ -242,6 +243,18 @@ grub_dl_get (const char *name)
|
|
|
3efed6 |
return 0;
|
|
|
3efed6 |
}
|
|
|
3efed6 |
|
|
|
3efed6 |
+static inline void
|
|
|
3efed6 |
+grub_dl_set_persistent (grub_dl_t mod)
|
|
|
3efed6 |
+{
|
|
|
3efed6 |
+ mod->persistent = 1;
|
|
|
3efed6 |
+}
|
|
|
3efed6 |
+
|
|
|
3efed6 |
+static inline int
|
|
|
3efed6 |
+grub_dl_is_persistent (grub_dl_t mod)
|
|
|
3efed6 |
+{
|
|
|
3efed6 |
+ return mod->persistent;
|
|
|
3efed6 |
+}
|
|
|
3efed6 |
+
|
|
|
3efed6 |
#endif
|
|
|
3efed6 |
|
|
|
3efed6 |
void * EXPORT_FUNC(grub_resolve_symbol) (const char *name);
|