[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 8/9] dl: Add support for persistent modules
From: |
Daniel Kiper |
Subject: |
[PATCH v4 8/9] dl: Add support for persistent modules |
Date: |
Tue, 30 Oct 2018 14:12:57 +0100 |
This type of modules cannot be unloaded. This is useful if a given
functionality, e.g. UEFI secure boot shim signature verification, should
not be disabled if it was enabled at some point in time. Somebody may
say that we can use standalone GRUB2 here. That is true. However, the
code is not so big nor complicated hence it make sense to support
modularized configs too.
Signed-off-by: Daniel Kiper <address@hidden>
---
grub-core/commands/minicmd.c | 3 +++
include/grub/dl.h | 13 +++++++++++++
2 files changed, 16 insertions(+)
diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c
index fc20c65..6bbce31 100644
--- a/grub-core/commands/minicmd.c
+++ b/grub-core/commands/minicmd.c
@@ -137,6 +137,9 @@ grub_mini_cmd_rmmod (struct grub_command *cmd __attribute__
((unused)),
if (! mod)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "no such module");
+ if (grub_dl_is_persistent (mod))
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "cannot unload persistent
module");
+
if (grub_dl_unref (mod) <= 0)
grub_dl_unload (mod);
diff --git a/include/grub/dl.h b/include/grub/dl.h
index 2bca56c..fee27a1 100644
--- a/include/grub/dl.h
+++ b/include/grub/dl.h
@@ -175,6 +175,7 @@ struct grub_dl
{
char *name;
int ref_count;
+ int persistent;
grub_dl_dep_t dep;
grub_dl_segment_t segment;
Elf_Sym *symtab;
@@ -240,6 +241,18 @@ grub_dl_get (const char *name)
return 0;
}
+static inline void
+grub_dl_set_persistent (grub_dl_t mod)
+{
+ mod->persistent = 1;
+}
+
+static inline int
+grub_dl_is_persistent (grub_dl_t mod)
+{
+ return mod->persistent;
+}
+
#endif
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
--
1.7.10.4
- [PATCH v4 0/9] verifiers: Framework and EFI shim lock verifier, Daniel Kiper, 2018/10/30
- [PATCH v4 3/9] verifiers: Framework core, Daniel Kiper, 2018/10/30
- [PATCH v4 6/9] verifiers: Rename verify module to pgp module, Daniel Kiper, 2018/10/30
- [PATCH v4 4/9] verifiers: Add possibility to verify kernel and modules command lines, Daniel Kiper, 2018/10/30
- [PATCH v4 8/9] dl: Add support for persistent modules,
Daniel Kiper <=
- [PATCH v4 7/9] verifiers: Add the documentation, Daniel Kiper, 2018/10/30
- [PATCH v4 5/9] verifiers: Add possibility to defer verification to other verifiers, Daniel Kiper, 2018/10/30
- [PATCH v4 1/9] bufio: Use grub_size_t instead of plain int for size, Daniel Kiper, 2018/10/30
- [PATCH v4 2/9] verifiers: File type for fine-grained signature-verification controlling, Daniel Kiper, 2018/10/30
- [PATCH v4 9/9] efi: Add EFI shim lock verifier, Daniel Kiper, 2018/10/30
- Re: [PATCH v4 0/9] verifiers: Framework and EFI shim lock verifier, Ross Philipson, 2018/10/31