From: "Ard Biesheuvel" <ardb@kernel.org>
To: "Guo Zihao" <guozh23@xiaopeng.com>,
"Peter Huewe" <peterhuewe@gmx.de>,
"Jarkko Sakkinen" <jarkko@kernel.org>
Cc: "Jason Gunthorpe" <jgg@ziepe.ca>,
"Matthew Garrett" <matthewgarrett@google.com>,
linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] tpm: efi: reject a final events table with an oversized preboot log
Date: Fri, 06 Nov 2026 10:12:42 +0100 [thread overview]
Message-ID: <73a5f412-0962-400d-9e80-5b9eef92bb8e@app.fastmail.com> (raw)
In-Reply-To: <20261106014956.4129904-1-guozh23@xiaopeng.com>
On Fri, 6 Nov 2026, at 02:49, Guo Zihao wrote:
> The preboot portion recorded in the main event log is subtracted from
> the size of the final events table taken from the firmware:
>
> /*
> * The 'final events log' size excludes the 'final events preboot log'
> * at its beginning.
> */
> final_events_log_size -= log_tbl->final_events_preboot_size;
>
> Both sizes come from EFI configuration tables and are not validated
> against each other. A final events table claiming a preboot portion
> larger than the table itself makes final_events_log_size go negative:
> the subsequent devm_krealloc() can then end up with a wrapped, too
> small allocation, and the memcpy() that appends the final events log
> uses the negative value as its length, running far past the buffer.
>
> The boot path has no way to fix up such a table, so fail the final
> events log instead of appending from it.
>
> Fixes: 166a2809d65b ("tpm: Don't duplicate events from the final event
> log in the TCG2 log")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guo Zihao <guozh23@xiaopeng.com>
> ---
> drivers/char/tpm/eventlog/efi.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/char/tpm/eventlog/efi.c b/drivers/char/tpm/eventlog/efi.c
> index 4e9d7c2bf..0a8006f3e 100644
> --- a/drivers/char/tpm/eventlog/efi.c
> +++ b/drivers/char/tpm/eventlog/efi.c
> @@ -82,6 +82,9 @@ int tpm_read_log_efi(struct tpm_chip *chip)
> goto out;
> }
>
> + if (log_tbl->final_events_preboot_size > final_events_log_size)
> + goto out;
> +
Should we add a pr_warn() here?
next prev parent reply other threads:[~2026-11-06 9:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 1:49 Guo Zihao
2026-11-06 9:12 ` Ard Biesheuvel [this message]
2026-11-06 9:20 ` [PATCH v2] " Guo Zihao
2026-11-06 15:24 ` [PATCH] " Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=73a5f412-0962-400d-9e80-5b9eef92bb8e@app.fastmail.com \
--to=ardb@kernel.org \
--cc=guozh23@xiaopeng.com \
--cc=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthewgarrett@google.com \
--cc=peterhuewe@gmx.de \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®