|
|
c1d7cf |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
c1d7cf |
From: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
c1d7cf |
Date: Wed, 16 Oct 2019 15:32:04 +0200
|
|
|
c1d7cf |
Subject: [PATCH] TPM: Print messages if measuraments fail as debug instead of
|
|
|
c1d7cf |
error
|
|
|
c1d7cf |
|
|
|
c1d7cf |
If the calls to EFI services to do TPM measuraments fail, currently error
|
|
|
c1d7cf |
messages are printed. But this is not a fatal error and just pollutes the
|
|
|
c1d7cf |
output, so instead just print them as debug messages.
|
|
|
c1d7cf |
|
|
|
c1d7cf |
Resolves: rhbz#1761811
|
|
|
c1d7cf |
|
|
|
c1d7cf |
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
|
|
|
c1d7cf |
---
|
|
|
c1d7cf |
grub-core/kern/efi/tpm.c | 58 +++++++++++++++++++++++++-----------------------
|
|
|
c1d7cf |
1 file changed, 30 insertions(+), 28 deletions(-)
|
|
|
c1d7cf |
|
|
|
c1d7cf |
diff --git a/grub-core/kern/efi/tpm.c b/grub-core/kern/efi/tpm.c
|
|
|
b71686 |
index 0d3ebe22e..5dc908652 100644
|
|
|
c1d7cf |
--- a/grub-core/kern/efi/tpm.c
|
|
|
c1d7cf |
+++ b/grub-core/kern/efi/tpm.c
|
|
|
c1d7cf |
@@ -161,6 +161,34 @@ grub_tpm_execute(PassThroughToTPM_InputParamBlock *inbuf,
|
|
|
c1d7cf |
}
|
|
|
c1d7cf |
}
|
|
|
c1d7cf |
|
|
|
c1d7cf |
+static inline grub_err_t grub_tpm_dprintf(grub_efi_status_t status)
|
|
|
c1d7cf |
+{
|
|
|
c1d7cf |
+ switch (status) {
|
|
|
c1d7cf |
+ case GRUB_EFI_SUCCESS:
|
|
|
c1d7cf |
+ return 0;
|
|
|
c1d7cf |
+ case GRUB_EFI_DEVICE_ERROR:
|
|
|
c1d7cf |
+ grub_dprintf ("tpm", "Command failed: 0x%"PRIxGRUB_EFI_STATUS"\n",
|
|
|
c1d7cf |
+ status);
|
|
|
c1d7cf |
+ return GRUB_ERR_IO;
|
|
|
c1d7cf |
+ case GRUB_EFI_INVALID_PARAMETER:
|
|
|
c1d7cf |
+ grub_dprintf ("tpm", "Invalid parameter: 0x%"PRIxGRUB_EFI_STATUS"\n",
|
|
|
c1d7cf |
+ status);
|
|
|
c1d7cf |
+ return GRUB_ERR_BAD_ARGUMENT;
|
|
|
c1d7cf |
+ case GRUB_EFI_BUFFER_TOO_SMALL:
|
|
|
c1d7cf |
+ grub_dprintf ("tpm", "Output buffer too small: 0x%"PRIxGRUB_EFI_STATUS"\n",
|
|
|
c1d7cf |
+ status);
|
|
|
c1d7cf |
+ return GRUB_ERR_BAD_ARGUMENT;
|
|
|
c1d7cf |
+ case GRUB_EFI_NOT_FOUND:
|
|
|
c1d7cf |
+ grub_dprintf ("tpm", "TPM unavailable: 0x%"PRIxGRUB_EFI_STATUS"\n",
|
|
|
c1d7cf |
+ status);
|
|
|
c1d7cf |
+ return GRUB_ERR_UNKNOWN_DEVICE;
|
|
|
c1d7cf |
+ default:
|
|
|
c1d7cf |
+ grub_dprintf ("tpm", "Unknown TPM error: 0x%"PRIxGRUB_EFI_STATUS"\n",
|
|
|
c1d7cf |
+ status);
|
|
|
c1d7cf |
+ return GRUB_ERR_UNKNOWN_DEVICE;
|
|
|
c1d7cf |
+ }
|
|
|
c1d7cf |
+}
|
|
|
c1d7cf |
+
|
|
|
c1d7cf |
static grub_err_t
|
|
|
c1d7cf |
grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf,
|
|
|
c1d7cf |
grub_size_t size, grub_uint8_t pcr,
|
|
|
c1d7cf |
@@ -194,20 +222,7 @@ grub_tpm1_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf,
|
|
|
c1d7cf |
(unsigned long) buf, (grub_uint64_t) size,
|
|
|
c1d7cf |
algorithm, event, &eventnum, &lastevent);
|
|
|
c1d7cf |
|
|
|
c1d7cf |
- switch (status) {
|
|
|
c1d7cf |
- case GRUB_EFI_SUCCESS:
|
|
|
c1d7cf |
- return 0;
|
|
|
c1d7cf |
- case GRUB_EFI_DEVICE_ERROR:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_IO, N_("Command failed"));
|
|
|
c1d7cf |
- case GRUB_EFI_INVALID_PARAMETER:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter"));
|
|
|
c1d7cf |
- case GRUB_EFI_BUFFER_TOO_SMALL:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Output buffer too small"));
|
|
|
c1d7cf |
- case GRUB_EFI_NOT_FOUND:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable"));
|
|
|
c1d7cf |
- default:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error"));
|
|
|
c1d7cf |
- }
|
|
|
c1d7cf |
+ return grub_tpm_dprintf(status);
|
|
|
c1d7cf |
}
|
|
|
c1d7cf |
|
|
|
c1d7cf |
static grub_err_t
|
|
|
c1d7cf |
@@ -240,20 +255,7 @@ grub_tpm2_log_event(grub_efi_handle_t tpm_handle, unsigned char *buf,
|
|
|
c1d7cf |
status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (unsigned long) buf,
|
|
|
c1d7cf |
(grub_uint64_t) size, event);
|
|
|
c1d7cf |
|
|
|
c1d7cf |
- switch (status) {
|
|
|
c1d7cf |
- case GRUB_EFI_SUCCESS:
|
|
|
c1d7cf |
- return 0;
|
|
|
c1d7cf |
- case GRUB_EFI_DEVICE_ERROR:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_IO, N_("Command failed"));
|
|
|
c1d7cf |
- case GRUB_EFI_INVALID_PARAMETER:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid parameter"));
|
|
|
c1d7cf |
- case GRUB_EFI_BUFFER_TOO_SMALL:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Output buffer too small"));
|
|
|
c1d7cf |
- case GRUB_EFI_NOT_FOUND:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("TPM unavailable"));
|
|
|
c1d7cf |
- default:
|
|
|
c1d7cf |
- return grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("Unknown TPM error"));
|
|
|
c1d7cf |
- }
|
|
|
c1d7cf |
+ return grub_tpm_dprintf(status);
|
|
|
c1d7cf |
}
|
|
|
c1d7cf |
|
|
|
c1d7cf |
grub_err_t
|