4cf8c08
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4cf8c08
From: Javier Martinez Canillas <javierm@redhat.com>
4cf8c08
Date: Sat, 16 May 2020 11:33:18 +0200
4cf8c08
Subject: [PATCH] tpm: Don't propagate TPM measurement errors to the verifiers
4cf8c08
 layer
4cf8c08
4cf8c08
Currently if the EFI firmware fails to do a TPM measurement for a file,
4cf8c08
the error will be propagated to the verifiers framework and so opening
4cf8c08
the file will not succeed.
4cf8c08
4cf8c08
This mean that buggy firmwares will prevent the system to boot since the
4cf8c08
loader won't be able to open any file. But failing to do TPM measurements
4cf8c08
shouldn't be a fatal error and the system should still be able to boot.
4cf8c08
4cf8c08
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
4cf8c08
---
4cf8c08
 grub-core/commands/tpm.c | 14 +++++++-------
4cf8c08
 1 file changed, 7 insertions(+), 7 deletions(-)
4cf8c08
4cf8c08
diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c
46968b6
index 2052c36eaba..e287d042e6b 100644
4cf8c08
--- a/grub-core/commands/tpm.c
4cf8c08
+++ b/grub-core/commands/tpm.c
46968b6
@@ -42,7 +42,8 @@ grub_tpm_verify_init (grub_file_t io,
4cf8c08
 static grub_err_t
4cf8c08
 grub_tpm_verify_write (void *context, void *buf, grub_size_t size)
4cf8c08
 {
4cf8c08
-  return grub_tpm_measure (buf, size, GRUB_BINARY_PCR, context);
4cf8c08
+  grub_tpm_measure (buf, size, GRUB_BINARY_PCR, context);
4cf8c08
+  return GRUB_ERR_NONE;
4cf8c08
 }
4cf8c08
 
4cf8c08
 static grub_err_t
46968b6
@@ -50,7 +51,6 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type)
4cf8c08
 {
4cf8c08
   const char *prefix = NULL;
4cf8c08
   char *description;
4cf8c08
-  grub_err_t status;
4cf8c08
 
4cf8c08
   switch (type)
4cf8c08
     {
46968b6
@@ -66,15 +66,15 @@ grub_tpm_verify_string (char *str, enum grub_verify_string_type type)
4cf8c08
     }
4cf8c08
   description = grub_malloc (grub_strlen (str) + grub_strlen (prefix) + 1);
4cf8c08
   if (!description)
4cf8c08
-    return grub_errno;
4cf8c08
+    return GRUB_ERR_NONE;
4cf8c08
   grub_memcpy (description, prefix, grub_strlen (prefix));
4cf8c08
   grub_memcpy (description + grub_strlen (prefix), str,
4cf8c08
 	       grub_strlen (str) + 1);
4cf8c08
-  status =
4cf8c08
-    grub_tpm_measure ((unsigned char *) str, grub_strlen (str),
4cf8c08
-		      GRUB_STRING_PCR, description);
4cf8c08
+
4cf8c08
+  grub_tpm_measure ((unsigned char *) str, grub_strlen (str), GRUB_STRING_PCR,
4cf8c08
+                    description);
4cf8c08
   grub_free (description);
4cf8c08
-  return status;
4cf8c08
+  return GRUB_ERR_NONE;
4cf8c08
 }
4cf8c08
 
4cf8c08
 struct grub_file_verifier grub_tpm_verifier = {