Blame SOURCES/0133-Measure-multiboot-images-and-modules.patch

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