]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
efi_loader: check tcg2 protocol installation outside the TCG protocol
authorMasahisa Kojima <masahisa.kojima@linaro.org>
Tue, 7 Dec 2021 05:15:32 +0000 (14:15 +0900)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 9 Dec 2021 19:43:25 +0000 (11:43 -0800)
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>
lib/efi_loader/efi_tcg2.c

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