diff mbox series

[v2,01/11] efi_loader: Don't warn if the TCG2 FinalEvents table is not installed

Message ID 20241224160118.675977-2-raymond.mao@linaro.org
State New
Headers show
Series [v2,01/11] efi_loader: Don't warn if the TCG2 FinalEvents table is not installed | expand

Commit Message

Raymond Mao Dec. 24, 2024, 4:01 p.m. UTC
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>

When the TCG2 protocol installation fails, we are trying to remove
all the objects we created in tcg2_uninit().

However, there are cases when this function runs before the config
table was installed. So instead of printing an error unconditionally
check against EFI_NOT_FOUND and don't print anything if the table wasn't
installed to begin with.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
---
Changes in v2
- None.

 lib/efi_loader/efi_tcg2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Heinrich Schuchardt Dec. 24, 2024, 8:58 p.m. UTC | #1
On 12/24/24 17:01, Raymond Mao wrote:
> From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
>
> When the TCG2 protocol installation fails, we are trying to remove
> all the objects we created in tcg2_uninit().
>
> However, there are cases when this function runs before the config
> table was installed. So instead of printing an error unconditionally
> check against EFI_NOT_FOUND and don't print anything if the table wasn't
> installed to begin with.
>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
> ---
> Changes in v2
> - None.
>
>   lib/efi_loader/efi_tcg2.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
> index 572c6b5bf6..a15c73162e 100644
> --- a/lib/efi_loader/efi_tcg2.c
> +++ b/lib/efi_loader/efi_tcg2.c
> @@ -791,7 +791,7 @@ static void tcg2_uninit(void)
>   	efi_status_t ret;
>
>   	ret = efi_install_configuration_table(&efi_guid_final_events, NULL);
> -	if (ret != EFI_SUCCESS)
> +	if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
>   		log_err("Failed to delete final events config table\n");

tcg2_uninit() is called after another problem has occurred.

The user probably is much more interested why efi_tcg2_register() failed
but and less why this secondary issue occurred.

We can drop this message completely.

@Ilias, Raymond

Beyond this patch the following needs to be fixed:

The TCG2 driver should open the TCG2 protocol with BY_DRIVER to ensure
that it cannot be uninstalled without taking down the driver.

Best regards

Heinrich

>
>   	efi_free_pool(event_log.buffer);
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 572c6b5bf6..a15c73162e 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -791,7 +791,7 @@  static void tcg2_uninit(void)
 	efi_status_t ret;
 
 	ret = efi_install_configuration_table(&efi_guid_final_events, NULL);
-	if (ret != EFI_SUCCESS)
+	if (ret != EFI_SUCCESS && ret != EFI_NOT_FOUND)
 		log_err("Failed to delete final events config table\n");
 
 	efi_free_pool(event_log.buffer);