linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V6] efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified
@ 2025-07-12  3:24 yangge1116
  2025-07-14  5:26 ` Ard Biesheuvel
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: yangge1116 @ 2025-07-12  3:24 UTC (permalink / raw)
  To: ardb
  Cc: jarkko, James.Bottomley, sathyanarayanan.kuppuswamy,
	ilias.apalodimas, jgg, linux-efi, linux-kernel, stable, liuzixing,
	Ge Yang

From: Ge Yang <yangge1116@126.com>

Since commit d228814b1913 ("efi/libstub: Add get_event_log() support
for CC platforms") reuses TPM2 support code for the CC platforms, when
launching a TDX virtual machine with coco measurement enabled, the
following error log is generated:

[Firmware Bug]: Failed to parse event in TPM Final Events Log

Call Trace:
efi_config_parse_tables()
  efi_tpm_eventlog_init()
    tpm2_calc_event_log_size()
      __calc_tpm2_event_size()

The pcr_idx value in the Intel TDX log header is 1, causing the function
__calc_tpm2_event_size() to fail to recognize the log header, ultimately
leading to the "Failed to parse event in TPM Final Events Log" error.

Intel misread the spec and wrongly sets pcrIndex to 1 in the header and
since they did this, we fear others might, so we're relaxing the header
check. There's no danger of this causing problems because we check for
the TCG_SPECID_SIG signature as the next thing.

Fixes: d228814b1913 ("efi/libstub: Add get_event_log() support for CC platforms")
Signed-off-by: Ge Yang <yangge1116@126.com>
Cc: stable@vger.kernel.org
---

V6:
- improve commit message suggested by James 

V5:
- remove the pcr_index check without adding any replacement checks suggested by James and Sathyanarayanan 

V4:
- remove cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT) suggested by Ard

V3:
- fix build error

V2:
- limit the fix for CC only suggested by Jarkko and Sathyanarayanan

 include/linux/tpm_eventlog.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/tpm_eventlog.h b/include/linux/tpm_eventlog.h
index 891368e..05c0ae5 100644
--- a/include/linux/tpm_eventlog.h
+++ b/include/linux/tpm_eventlog.h
@@ -202,8 +202,7 @@ static __always_inline u32 __calc_tpm2_event_size(struct tcg_pcr_event2_head *ev
 	event_type = event->event_type;
 
 	/* Verify that it's the log header */
-	if (event_header->pcr_idx != 0 ||
-	    event_header->event_type != NO_ACTION ||
+	if (event_header->event_type != NO_ACTION ||
 	    memcmp(event_header->digest, zero_digest, sizeof(zero_digest))) {
 		size = 0;
 		goto out;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V6] efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified
  2025-07-12  3:24 [PATCH V6] efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified yangge1116
@ 2025-07-14  5:26 ` Ard Biesheuvel
  2025-07-14 13:28 ` Sathyanarayanan Kuppuswamy
  2025-07-15 20:51 ` James Bottomley
  2 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2025-07-14  5:26 UTC (permalink / raw)
  To: yangge1116
  Cc: jarkko, James.Bottomley, sathyanarayanan.kuppuswamy,
	ilias.apalodimas, jgg, linux-efi, linux-kernel, stable, liuzixing

On Sat, 12 Jul 2025 at 13:41, <yangge1116@126.com> wrote:
>
> From: Ge Yang <yangge1116@126.com>
>
> Since commit d228814b1913 ("efi/libstub: Add get_event_log() support
> for CC platforms") reuses TPM2 support code for the CC platforms, when
> launching a TDX virtual machine with coco measurement enabled, the
> following error log is generated:
>
> [Firmware Bug]: Failed to parse event in TPM Final Events Log
>
> Call Trace:
> efi_config_parse_tables()
>   efi_tpm_eventlog_init()
>     tpm2_calc_event_log_size()
>       __calc_tpm2_event_size()
>
> The pcr_idx value in the Intel TDX log header is 1, causing the function
> __calc_tpm2_event_size() to fail to recognize the log header, ultimately
> leading to the "Failed to parse event in TPM Final Events Log" error.
>
> Intel misread the spec and wrongly sets pcrIndex to 1 in the header and
> since they did this, we fear others might, so we're relaxing the header
> check. There's no danger of this causing problems because we check for
> the TCG_SPECID_SIG signature as the next thing.
>
> Fixes: d228814b1913 ("efi/libstub: Add get_event_log() support for CC platforms")
> Signed-off-by: Ge Yang <yangge1116@126.com>
> Cc: stable@vger.kernel.org

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>


> ---
>
> V6:
> - improve commit message suggested by James
>
> V5:
> - remove the pcr_index check without adding any replacement checks suggested by James and Sathyanarayanan
>
> V4:
> - remove cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT) suggested by Ard
>
> V3:
> - fix build error
>
> V2:
> - limit the fix for CC only suggested by Jarkko and Sathyanarayanan
>
>  include/linux/tpm_eventlog.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/include/linux/tpm_eventlog.h b/include/linux/tpm_eventlog.h
> index 891368e..05c0ae5 100644
> --- a/include/linux/tpm_eventlog.h
> +++ b/include/linux/tpm_eventlog.h
> @@ -202,8 +202,7 @@ static __always_inline u32 __calc_tpm2_event_size(struct tcg_pcr_event2_head *ev
>         event_type = event->event_type;
>
>         /* Verify that it's the log header */
> -       if (event_header->pcr_idx != 0 ||
> -           event_header->event_type != NO_ACTION ||
> +       if (event_header->event_type != NO_ACTION ||
>             memcmp(event_header->digest, zero_digest, sizeof(zero_digest))) {
>                 size = 0;
>                 goto out;
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V6] efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified
  2025-07-12  3:24 [PATCH V6] efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified yangge1116
  2025-07-14  5:26 ` Ard Biesheuvel
@ 2025-07-14 13:28 ` Sathyanarayanan Kuppuswamy
  2025-07-15 20:51 ` James Bottomley
  2 siblings, 0 replies; 4+ messages in thread
From: Sathyanarayanan Kuppuswamy @ 2025-07-14 13:28 UTC (permalink / raw)
  To: yangge1116, ardb
  Cc: jarkko, James.Bottomley, ilias.apalodimas, jgg, linux-efi,
	linux-kernel, stable, liuzixing


On 7/11/25 8:24 PM, yangge1116@126.com wrote:
> From: Ge Yang <yangge1116@126.com>
>
> Since commit d228814b1913 ("efi/libstub: Add get_event_log() support
> for CC platforms") reuses TPM2 support code for the CC platforms, when
> launching a TDX virtual machine with coco measurement enabled, the
> following error log is generated:
>
> [Firmware Bug]: Failed to parse event in TPM Final Events Log
>
> Call Trace:
> efi_config_parse_tables()
>    efi_tpm_eventlog_init()
>      tpm2_calc_event_log_size()
>        __calc_tpm2_event_size()
>
> The pcr_idx value in the Intel TDX log header is 1, causing the function
> __calc_tpm2_event_size() to fail to recognize the log header, ultimately
> leading to the "Failed to parse event in TPM Final Events Log" error.
>
> Intel misread the spec and wrongly sets pcrIndex to 1 in the header and
> since they did this, we fear others might, so we're relaxing the header
> check. There's no danger of this causing problems because we check for
> the TCG_SPECID_SIG signature as the next thing.
>
> Fixes: d228814b1913 ("efi/libstub: Add get_event_log() support for CC platforms")
> Signed-off-by: Ge Yang <yangge1116@126.com>
> Cc: stable@vger.kernel.org
> ---
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
> V6:
> - improve commit message suggested by James
>
> V5:
> - remove the pcr_index check without adding any replacement checks suggested by James and Sathyanarayanan
>
> V4:
> - remove cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT) suggested by Ard
>
> V3:
> - fix build error
>
> V2:
> - limit the fix for CC only suggested by Jarkko and Sathyanarayanan
>
>   include/linux/tpm_eventlog.h | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/include/linux/tpm_eventlog.h b/include/linux/tpm_eventlog.h
> index 891368e..05c0ae5 100644
> --- a/include/linux/tpm_eventlog.h
> +++ b/include/linux/tpm_eventlog.h
> @@ -202,8 +202,7 @@ static __always_inline u32 __calc_tpm2_event_size(struct tcg_pcr_event2_head *ev
>   	event_type = event->event_type;
>   
>   	/* Verify that it's the log header */
> -	if (event_header->pcr_idx != 0 ||
> -	    event_header->event_type != NO_ACTION ||
> +	if (event_header->event_type != NO_ACTION ||
>   	    memcmp(event_header->digest, zero_digest, sizeof(zero_digest))) {
>   		size = 0;
>   		goto out;

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V6] efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified
  2025-07-12  3:24 [PATCH V6] efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified yangge1116
  2025-07-14  5:26 ` Ard Biesheuvel
  2025-07-14 13:28 ` Sathyanarayanan Kuppuswamy
@ 2025-07-15 20:51 ` James Bottomley
  2 siblings, 0 replies; 4+ messages in thread
From: James Bottomley @ 2025-07-15 20:51 UTC (permalink / raw)
  To: yangge1116, ardb
  Cc: jarkko, sathyanarayanan.kuppuswamy, ilias.apalodimas, jgg,
	linux-efi, linux-kernel, stable, liuzixing

On Sat, 2025-07-12 at 11:24 +0800, yangge1116@126.com wrote:
> From: Ge Yang <yangge1116@126.com>
> 
> Since commit d228814b1913 ("efi/libstub: Add get_event_log() support
> for CC platforms") reuses TPM2 support code for the CC platforms,
> when launching a TDX virtual machine with coco measurement enabled,
> the following error log is generated:
> 
> [Firmware Bug]: Failed to parse event in TPM Final Events Log
> 
> Call Trace:
> efi_config_parse_tables()
>   efi_tpm_eventlog_init()
>     tpm2_calc_event_log_size()
>       __calc_tpm2_event_size()
> 
> The pcr_idx value in the Intel TDX log header is 1, causing the
> function __calc_tpm2_event_size() to fail to recognize the log
> header, ultimately leading to the "Failed to parse event in TPM Final
> Events Log" error.
> 
> Intel misread the spec and wrongly sets pcrIndex to 1 in the header
> and since they did this, we fear others might, so we're relaxing the
> header check. There's no danger of this causing problems because we
> check for the TCG_SPECID_SIG signature as the next thing.
> 
> Fixes: d228814b1913 ("efi/libstub: Add get_event_log() support for CC
> platforms")
> Signed-off-by: Ge Yang <yangge1116@126.com>
> Cc: stable@vger.kernel.org

Reviewed-by: James Bottomley <James.Bottomley@HansenPartnership.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-15 20:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-12  3:24 [PATCH V6] efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified yangge1116
2025-07-14  5:26 ` Ard Biesheuvel
2025-07-14 13:28 ` Sathyanarayanan Kuppuswamy
2025-07-15 20:51 ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).