grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Kiper <daniel.kiper@oracle.com>
To: grub-devel@gnu.org
Cc: dpsmith.dev@gmail.com, eric.snowberg@oracle.com,
	javierm@redhat.com, jonmccune@google.com,
	kanth.ghatraju@oracle.com, keng-yu.lin@hpe.com,
	konrad.wilk@oracle.com, leif.lindholm@linaro.org,
	mjg59@srcf.ucam.org,  phcoder@gmail.com,
	philip.b.tricca@intel.com, ross.philipson@oracle.com
Subject: [PATCH v3 7/8] dl: Add support for persistent modules
Date: Wed,  3 Oct 2018 11:36:54 +0200	[thread overview]
Message-ID: <1538559415-6233-8-git-send-email-daniel.kiper@oracle.com> (raw)
In-Reply-To: <1538559415-6233-1-git-send-email-daniel.kiper@oracle.com>

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 <daniel.kiper@oracle.com>
---
 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



  parent reply	other threads:[~2018-10-03  9:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03  9:36 [PATCH v3 0/8] verifiers: Framework and EFI shim lock verifier Daniel Kiper
2018-10-03  9:36 ` [PATCH v3 1/8] verifiers: File type for fine-grained signature-verification controlling Daniel Kiper
2018-10-03 17:33   ` Ross Philipson
2018-10-09 13:43     ` Daniel Kiper
2018-10-03  9:36 ` [PATCH v3 2/8] verifiers: Framework core Daniel Kiper
2018-10-03 17:55   ` Ross Philipson
2018-10-09 13:48     ` Daniel Kiper
2018-10-03  9:36 ` [PATCH v3 3/8] verifiers: Add possibility to verify kernel and modules command lines Daniel Kiper
2018-10-03  9:36 ` [PATCH v3 4/8] verifiers: Add possibility to defer verification to other verifiers Daniel Kiper
2018-10-05 16:09   ` Ross Philipson
2018-10-09 13:57     ` Daniel Kiper
2018-10-03  9:36 ` [PATCH v3 5/8] verifiers: Rename verify module to pgp module Daniel Kiper
2018-10-05 16:24   ` Ross Philipson
2018-10-09 14:11     ` Daniel Kiper
2018-10-09 14:17       ` Michel Hermier
2018-10-09 14:20         ` Michel Hermier
2018-10-09 14:44           ` Ross Philipson
2018-10-09 15:06       ` Konrad Rzeszutek Wilk
2018-10-03  9:36 ` [PATCH v3 6/8] verifiers: Add the documentation Daniel Kiper
2018-10-05 16:43   ` Ross Philipson
2018-10-09 14:26     ` Daniel Kiper
2018-10-09 14:46       ` Ross Philipson
2018-10-09 14:59   ` Ross Philipson
2018-10-03  9:36 ` Daniel Kiper [this message]
2018-10-03  9:36 ` [PATCH v3 8/8] efi: Add EFI shim lock verifier Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1538559415-6233-8-git-send-email-daniel.kiper@oracle.com \
    --to=daniel.kiper@oracle.com \
    --cc=dpsmith.dev@gmail.com \
    --cc=eric.snowberg@oracle.com \
    --cc=grub-devel@gnu.org \
    --cc=javierm@redhat.com \
    --cc=jonmccune@google.com \
    --cc=kanth.ghatraju@oracle.com \
    --cc=keng-yu.lin@hpe.com \
    --cc=konrad.wilk@oracle.com \
    --cc=leif.lindholm@linaro.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=phcoder@gmail.com \
    --cc=philip.b.tricca@intel.com \
    --cc=ross.philipson@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).