|
|
80913e |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
80913e |
From: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
80913e |
Date: Wed, 26 Sep 2018 13:17:52 +0200
|
|
|
80913e |
Subject: [PATCH] verifiers: Add possibility to defer verification to other
|
|
|
80913e |
verifiers
|
|
|
80913e |
|
|
|
80913e |
This way if a verifier requires verification of a given file it can defer task
|
|
|
80913e |
to another verifier (another authority) if it is not able to do it itself. E.g.
|
|
|
80913e |
shim_lock verifier, posted as a subsequent patch, is able to verify only PE
|
|
|
80913e |
files. This means that it is not able to verify any of GRUB2 modules which have
|
|
|
80913e |
to be trusted on UEFI systems with secure boot enabled. So, it can defer
|
|
|
80913e |
verification to other verifier, e.g. PGP one.
|
|
|
80913e |
|
|
|
80913e |
I silently assume that other verifiers are trusted and will do good job for us.
|
|
|
80913e |
Or at least they will not do any harm.
|
|
|
80913e |
|
|
|
80913e |
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
80913e |
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
|
|
|
80913e |
---
|
|
|
80913e |
grub-core/commands/verifiers.c | 23 ++++++++++++++++++++---
|
|
|
80913e |
include/grub/verify.h | 4 +++-
|
|
|
80913e |
2 files changed, 23 insertions(+), 4 deletions(-)
|
|
|
80913e |
|
|
|
80913e |
diff --git a/grub-core/commands/verifiers.c b/grub-core/commands/verifiers.c
|
|
|
80913e |
index 59ea418a2d9..c638d5f43e0 100644
|
|
|
80913e |
--- a/grub-core/commands/verifiers.c
|
|
|
80913e |
+++ b/grub-core/commands/verifiers.c
|
|
|
80913e |
@@ -83,6 +83,7 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type)
|
|
|
80913e |
void *context;
|
|
|
80913e |
grub_file_t ret = 0;
|
|
|
80913e |
grub_err_t err;
|
|
|
80913e |
+ int defer = 0;
|
|
|
80913e |
|
|
|
80913e |
grub_dprintf ("verify", "file: %s type: %d\n", io->name, type);
|
|
|
80913e |
|
|
|
80913e |
@@ -102,13 +103,27 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type)
|
|
|
80913e |
err = ver->init (io, type, &context, &flags);
|
|
|
80913e |
if (err)
|
|
|
80913e |
goto fail_noclose;
|
|
|
80913e |
+ if (flags & GRUB_VERIFY_FLAGS_DEFER_AUTH)
|
|
|
80913e |
+ {
|
|
|
80913e |
+ defer = 1;
|
|
|
80913e |
+ continue;
|
|
|
80913e |
+ }
|
|
|
80913e |
if (!(flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION))
|
|
|
80913e |
break;
|
|
|
80913e |
}
|
|
|
80913e |
|
|
|
80913e |
if (!ver)
|
|
|
80913e |
- /* No verifiers wanted to verify. Just return underlying file. */
|
|
|
80913e |
- return io;
|
|
|
80913e |
+ {
|
|
|
80913e |
+ if (defer)
|
|
|
80913e |
+ {
|
|
|
80913e |
+ grub_error (GRUB_ERR_ACCESS_DENIED,
|
|
|
80913e |
+ N_("verification requested but nobody cares: %s"), io->name);
|
|
|
80913e |
+ goto fail_noclose;
|
|
|
80913e |
+ }
|
|
|
80913e |
+
|
|
|
80913e |
+ /* No verifiers wanted to verify. Just return underlying file. */
|
|
|
80913e |
+ return io;
|
|
|
80913e |
+ }
|
|
|
80913e |
|
|
|
80913e |
ret = grub_malloc (sizeof (*ret));
|
|
|
80913e |
if (!ret)
|
|
|
80913e |
@@ -160,7 +175,9 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type)
|
|
|
80913e |
err = ver->init (io, type, &context, &flags);
|
|
|
80913e |
if (err)
|
|
|
80913e |
goto fail_noclose;
|
|
|
80913e |
- if (flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION)
|
|
|
80913e |
+ if (flags & GRUB_VERIFY_FLAGS_SKIP_VERIFICATION ||
|
|
|
80913e |
+ /* Verification done earlier. So, we are happy here. */
|
|
|
80913e |
+ flags & GRUB_VERIFY_FLAGS_DEFER_AUTH)
|
|
|
80913e |
continue;
|
|
|
80913e |
err = ver->write (context, verified->buf, ret->size);
|
|
|
80913e |
if (err)
|
|
|
80913e |
diff --git a/include/grub/verify.h b/include/grub/verify.h
|
|
|
80913e |
index 9f892d8fedb..79022b42258 100644
|
|
|
80913e |
--- a/include/grub/verify.h
|
|
|
80913e |
+++ b/include/grub/verify.h
|
|
|
80913e |
@@ -22,7 +22,9 @@
|
|
|
80913e |
enum grub_verify_flags
|
|
|
80913e |
{
|
|
|
80913e |
GRUB_VERIFY_FLAGS_SKIP_VERIFICATION = 1,
|
|
|
80913e |
- GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2
|
|
|
80913e |
+ GRUB_VERIFY_FLAGS_SINGLE_CHUNK = 2,
|
|
|
80913e |
+ /* Defer verification to another authority. */
|
|
|
80913e |
+ GRUB_VERIFY_FLAGS_DEFER_AUTH = 4
|
|
|
80913e |
};
|
|
|
80913e |
|
|
|
80913e |
enum grub_verify_string_type
|