2018-07-12 14:56:34 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-04-06 19:38:57 +00:00
|
|
|
From: Matthew Garrett <mjg59@coreos.com>
|
|
|
|
Date: Tue, 1 Sep 2015 16:02:55 -0700
|
2018-07-10 18:39:10 +00:00
|
|
|
Subject: [PATCH] Measure multiboot images and modules
|
2018-04-06 19:38:57 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
grub-core/loader/i386/multiboot_mbi.c | 3 +++
|
|
|
|
grub-core/loader/multiboot.c | 2 ++
|
|
|
|
grub-core/loader/multiboot_mbi2.c | 4 +++-
|
|
|
|
3 files changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c
|
2018-07-10 19:08:14 +00:00
|
|
|
index dc98dbcae25..1c5b0ac25ce 100644
|
2018-04-06 19:38:57 +00:00
|
|
|
--- a/grub-core/loader/i386/multiboot_mbi.c
|
|
|
|
+++ b/grub-core/loader/i386/multiboot_mbi.c
|
|
|
|
@@ -36,6 +36,7 @@
|
|
|
|
#include <grub/net.h>
|
|
|
|
#include <grub/i18n.h>
|
|
|
|
#include <grub/lib/cmdline.h>
|
|
|
|
+#include <grub/tpm.h>
|
|
|
|
|
|
|
|
#ifdef GRUB_MACHINE_EFI
|
|
|
|
#include <grub/efi/efi.h>
|
|
|
|
@@ -173,6 +174,8 @@ grub_multiboot_load (grub_file_t file, const char *filename)
|
|
|
|
return grub_errno;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ grub_tpm_measure((unsigned char*)buffer, len, GRUB_KERNEL_PCR, filename);
|
|
|
|
+
|
|
|
|
header = find_header (buffer, len);
|
|
|
|
|
|
|
|
if (header == 0)
|
|
|
|
diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c
|
2018-07-10 19:08:14 +00:00
|
|
|
index 26df46a4161..93e026c53db 100644
|
2018-04-06 19:38:57 +00:00
|
|
|
--- a/grub-core/loader/multiboot.c
|
|
|
|
+++ b/grub-core/loader/multiboot.c
|
2018-07-10 19:08:14 +00:00
|
|
|
@@ -51,6 +51,7 @@
|
2018-04-06 19:38:57 +00:00
|
|
|
#include <grub/memory.h>
|
|
|
|
#include <grub/i18n.h>
|
|
|
|
#include <grub/efi/sb.h>
|
|
|
|
+#include <grub/tpm.h>
|
|
|
|
|
|
|
|
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
|
|
2018-07-10 19:08:14 +00:00
|
|
|
@@ -440,6 +441,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)),
|
2018-04-06 19:38:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
grub_file_close (file);
|
|
|
|
+ grub_tpm_measure (module, size, GRUB_KERNEL_PCR, argv[0]);
|
|
|
|
return GRUB_ERR_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
|
2018-07-10 19:08:14 +00:00
|
|
|
index 4df6595954d..d5ad02a33a1 100644
|
2018-04-06 19:38:57 +00:00
|
|
|
--- a/grub-core/loader/multiboot_mbi2.c
|
|
|
|
+++ b/grub-core/loader/multiboot_mbi2.c
|
|
|
|
@@ -36,6 +36,7 @@
|
|
|
|
#include <grub/i18n.h>
|
|
|
|
#include <grub/net.h>
|
|
|
|
#include <grub/lib/cmdline.h>
|
|
|
|
+#include <grub/tpm.h>
|
|
|
|
|
|
|
|
#if defined (GRUB_MACHINE_EFI)
|
|
|
|
#include <grub/efi/efi.h>
|
2018-07-10 19:08:14 +00:00
|
|
|
@@ -131,8 +132,9 @@ grub_multiboot2_load (grub_file_t file, const char *filename)
|
2018-04-06 19:38:57 +00:00
|
|
|
|
|
|
|
COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0);
|
|
|
|
|
2018-04-06 20:17:39 +00:00
|
|
|
+ grub_tpm_measure ((unsigned char *)buffer, len, GRUB_KERNEL_PCR, filename);
|
2018-04-06 19:38:57 +00:00
|
|
|
+
|
|
|
|
header = find_header (mld.buffer, len);
|
|
|
|
-
|
|
|
|
if (header == 0)
|
|
|
|
{
|
|
|
|
grub_free (mld.buffer);
|