efi_loader: check tcg2 protocol installation outside the TCG protocol

There are functions that calls tcg2_agile_log_append() outside
of the TCG protocol invocation (e.g tcg2_measure_pe_image).
These functions must to check that TCG2 protocol is installed.
If not, measurement shall be skipped.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
Masahisa Kojima 2021-12-07 14:15:32 +09:00 committed by Heinrich Schuchardt
parent 54bec17f6b
commit 9e32bf9362

View file

@ -972,6 +972,9 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
IMAGE_NT_HEADERS32 *nt; IMAGE_NT_HEADERS32 *nt;
struct efi_handler *handler; struct efi_handler *handler;
if (!is_tcg2_protocol_installed())
return EFI_SUCCESS;
ret = platform_get_tpm2_device(&dev); ret = platform_get_tpm2_device(&dev);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
return ret; return ret;
@ -2189,6 +2192,9 @@ efi_status_t efi_tcg2_measure_efi_app_invocation(struct efi_loaded_image_obj *ha
u32 event = 0; u32 event = 0;
struct smbios_entry *entry; struct smbios_entry *entry;
if (!is_tcg2_protocol_installed())
return EFI_SUCCESS;
if (tcg2_efi_app_invoked) if (tcg2_efi_app_invoked)
return EFI_SUCCESS; return EFI_SUCCESS;
@ -2239,6 +2245,9 @@ efi_status_t efi_tcg2_measure_efi_app_exit(void)
efi_status_t ret; efi_status_t ret;
struct udevice *dev; struct udevice *dev;
if (!is_tcg2_protocol_installed())
return EFI_SUCCESS;
ret = platform_get_tpm2_device(&dev); ret = platform_get_tpm2_device(&dev);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
return ret; return ret;
@ -2264,6 +2273,12 @@ efi_tcg2_notify_exit_boot_services(struct efi_event *event, void *context)
EFI_ENTRY("%p, %p", event, context); EFI_ENTRY("%p, %p", event, context);
event_log.ebs_called = true; event_log.ebs_called = true;
if (!is_tcg2_protocol_installed()) {
ret = EFI_SUCCESS;
goto out;
}
ret = platform_get_tpm2_device(&dev); ret = platform_get_tpm2_device(&dev);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
goto out; goto out;
@ -2293,6 +2308,9 @@ efi_status_t efi_tcg2_notify_exit_boot_services_failed(void)
struct udevice *dev; struct udevice *dev;
efi_status_t ret; efi_status_t ret;
if (!is_tcg2_protocol_installed())
return EFI_SUCCESS;
ret = platform_get_tpm2_device(&dev); ret = platform_get_tpm2_device(&dev);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
goto out; goto out;