c78952
From 5aee2444093cfc8006865766f89e5a775a940ab1 Mon Sep 17 00:00:00 2001
0bcec2
From: Matthew Garrett <mjg59@coreos.com>
0bcec2
Date: Sun, 9 Aug 2015 16:28:29 -0700
63f1a9
Subject: [PATCH 219/250] Measure kernel and initrd on BIOS systems
0bcec2
0bcec2
Measure the kernel and initrd when loaded on BIOS systems
0bcec2
---
0bcec2
 grub-core/loader/i386/linux.c    | 5 +++++
0bcec2
 grub-core/loader/i386/pc/linux.c | 3 +++
0bcec2
 grub-core/loader/linux.c         | 2 ++
0bcec2
 3 files changed, 10 insertions(+)
0bcec2
0bcec2
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
0bcec2
index c9e89310bdd..bc10add45a6 100644
0bcec2
--- a/grub-core/loader/i386/linux.c
0bcec2
+++ b/grub-core/loader/i386/linux.c
0bcec2
@@ -36,6 +36,7 @@
0bcec2
 #include <grub/lib/cmdline.h>
0bcec2
 #include <grub/linux.h>
0bcec2
 #include <grub/efi/sb.h>
0bcec2
+#include <grub/tpm.h>
0bcec2
 
0bcec2
 GRUB_MOD_LICENSE ("GPLv3+");
0bcec2
 
0bcec2
@@ -718,7 +719,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
0bcec2
       goto fail;
0bcec2
     }
0bcec2
 
0bcec2
+  grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "Linux Kernel");
0bcec2
+
0bcec2
   grub_memcpy (&lh, kernel, sizeof (lh));
0bcec2
+
0bcec2
   kernel_offset = sizeof (lh);
0bcec2
 
0bcec2
   if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
0bcec2
@@ -1032,6 +1036,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
0bcec2
 
0bcec2
   len = prot_file_size;
0bcec2
   grub_memcpy (prot_mode_mem, kernel + kernel_offset, len);
0bcec2
+  kernel_offset += len;
0bcec2
 
0bcec2
   if (grub_errno == GRUB_ERR_NONE)
0bcec2
     {
0bcec2
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
0bcec2
index b864e540333..6b8f365c9cf 100644
0bcec2
--- a/grub-core/loader/i386/pc/linux.c
0bcec2
+++ b/grub-core/loader/i386/pc/linux.c
0bcec2
@@ -36,6 +36,7 @@
0bcec2
 #include <grub/lib/cmdline.h>
0bcec2
 #include <grub/linux.h>
0bcec2
 #include <grub/efi/sb.h>
0bcec2
+#include <grub/tpm.h>
0bcec2
 
0bcec2
 GRUB_MOD_LICENSE ("GPLv3+");
0bcec2
 
0bcec2
@@ -161,6 +162,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
0bcec2
       goto fail;
0bcec2
     }
0bcec2
 
0bcec2
+  grub_tpm_measure (kernel, len, GRUB_KERNEL_PCR, "BIOS Linux Kernel");
0bcec2
+
0bcec2
   grub_memcpy (&lh, kernel, sizeof (lh));
0bcec2
   kernel_offset = sizeof (lh);
0bcec2
 
0bcec2
diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
0bcec2
index be6fa0f4d45..3005c0d19c9 100644
0bcec2
--- a/grub-core/loader/linux.c
0bcec2
+++ b/grub-core/loader/linux.c
0bcec2
@@ -4,6 +4,7 @@
0bcec2
 #include <grub/misc.h>
0bcec2
 #include <grub/file.h>
0bcec2
 #include <grub/mm.h>
0bcec2
+#include <grub/tpm.h>
0bcec2
 
0bcec2
 struct newc_head
0bcec2
 {
0bcec2
@@ -288,6 +289,7 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
0bcec2
 	  grub_initrd_close (initrd_ctx);
0bcec2
 	  return grub_errno;
0bcec2
 	}
0bcec2
+      grub_tpm_measure (ptr, cursize, GRUB_INITRD_PCR, "Linux Initrd");
0bcec2
       ptr += cursize;
0bcec2
     }
0bcec2
   if (newc)
0bcec2
-- 
63f1a9
2.14.3
0bcec2