nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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