Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cVxds-000141-SX for mharc-grub-devel@gnu.org; Tue, 24 Jan 2017 04:43:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cVoNg-0001ht-7L for grub-devel@gnu.org; Mon, 23 Jan 2017 18:50:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cVoNf-00085q-2x for grub-devel@gnu.org; Mon, 23 Jan 2017 18:50:36 -0500 Received: from cavan.codon.org.uk ([2a00:1098:0:80:1000:c:0:1]:55920) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cVoNe-00085S-TR for grub-devel@gnu.org; Mon, 23 Jan 2017 18:50:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codon.org.uk; s=63138784; h=Subject:References:In-Reply-To:Message-Id:Date:Cc:To:From; bh=PszuPpDfy8GaRtwTJrve+cqtnYD91dv3KGiZfWxi/Hk=; b=h9ifacqxfcBCk59xrlK7mR6KEFM8c0ACmMcihKEqmvm7+Wj2RDZb8iGdO3+9lmwgkk1OXVj8lu4wxLjLgEdCUQeZdpq3uj9DK6ozAu1fHIxOaesYniPmBeK6jh6yLrCVHMWb9Usdz6wqGSxefqaBsakOx1Kbq0K/p1TUtxo8GLw=; Received: from [2603:3024:1c06:3af3:3252:cbff:fee6:e579] (helo=xps13-mjg59.libcore.so) by cavan.codon.org.uk with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1cVoNZ-00028t-4X; Mon, 23 Jan 2017 23:50:31 +0000 From: Matthew Garrett To: grub-devel@gnu.org Cc: Matthew Garrett Date: Mon, 23 Jan 2017 15:49:51 -0800 Message-Id: <20170123234954.22689-5-mjg59@coreos.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170123234954.22689-1-mjg59@coreos.com> References: <20170123234954.22689-1-mjg59@coreos.com> X-SA-Do-Not-Run: Yes X-SA-Exim-Connect-IP: 2603:3024:1c06:3af3:3252:cbff:fee6:e579 X-SA-Exim-Mail-From: mjg59@codon.org.uk Subject: [PATCH 4/7] Measure kernel and initrd X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:54:46 +0000) X-SA-Exim-Scanned: Yes (on cavan.codon.org.uk) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2a00:1098:0:80:1000:c:0:1 X-Mailman-Approved-At: Tue, 24 Jan 2017 04:43:51 -0500 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jan 2017 23:50:37 -0000 Measure the kernel and initrd at load time --- grub-core/loader/i386/linux.c | 6 ++++++ grub-core/loader/i386/pc/linux.c | 4 ++++ grub-core/loader/linux.c | 3 +++ 3 files changed, 13 insertions(+) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 5e54ec9..6d8d3d6 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -35,6 +35,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -716,7 +717,11 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } + grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux", "Linux Kernel"); + grub_print_error(); + grub_memcpy (&lh, kernel, sizeof (lh)); + kernel_offset = sizeof (lh); if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) @@ -1025,6 +1030,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), len = prot_file_size; grub_memcpy (prot_mode_mem, kernel + kernel_offset, len); + kernel_offset += len; if (grub_errno == GRUB_ERR_NONE) { diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 1ac9cd1..c6197a1 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -35,6 +35,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -160,6 +161,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } + grub_tpm_measure (kernel, len, GRUB_BINARY_PCR, "grub_linux16", "BIOS Linux Kernel"); + grub_print_error(); + grub_memcpy (&lh, kernel, sizeof (lh)); kernel_offset = sizeof (lh); diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index be6fa0f..8b5e6e0 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -4,6 +4,7 @@ #include #include #include +#include struct newc_head { @@ -288,6 +289,8 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, grub_initrd_close (initrd_ctx); return grub_errno; } + grub_tpm_measure (ptr, cursize, GRUB_BINARY_PCR, "grub_initrd", "Linux Initrd"); + grub_print_error(); ptr += cursize; } if (newc) -- 2.9.3