From: Michael Chang <mchang@suse.com>
To: Stefan Berger <stefanb@linux.ibm.com>
Cc: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH v2] tpm: Disable tpm verifier if tpm is not present
Date: Mon, 20 Feb 2023 12:39:00 +0800 [thread overview]
Message-ID: <20230220043900.umw7mtyzzmpecmog@lore> (raw)
In-Reply-To: <cfea4799-f577-96b7-8731-b11d47490257@linux.ibm.com>
On Thu, Feb 16, 2023 at 01:02:00PM -0500, Stefan Berger wrote:
>
>
> On 10/7/22 01:37, Michael Chang via Grub-devel wrote:
> > This helps to prevent out of memory error when reading large files via disabling
> > tpm device as verifier has to read all content into memory in one chunk to
> > measure the hash and extend to tpm.
>
> For ibmvtpm driver support this change here would be need. Can you merge it into your patch once the ibmvtpm driver is in the repo?
>
> diff --git a/grub-core/commands/ieee1275/ibmvtpm.c b/grub-core/commands/ieee1275/ibmvtpm.c
> index 239942d27..e01759c17 100644
> --- a/grub-core/commands/ieee1275/ibmvtpm.c
> +++ b/grub-core/commands/ieee1275/ibmvtpm.c
> @@ -135,16 +135,6 @@ grub_err_t
> grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr,
> const char *description)
> {
> - /*
> - * Call tpm_init() 'late' rather than from GRUB_MOD_INIT() so that device nodes
> - * can be found.
> - */
> - grub_err_t err = tpm_init ();
> -
> - /* Absence of a TPM isn't a failure. */
> - if (err != GRUB_ERR_NONE)
> - return GRUB_ERR_NONE;
> -
> grub_dprintf ("tpm", "log_event, pcr = %d, size = 0x%" PRIxGRUB_SIZE ", %s\n",
> pcr, size, description);
>
> @@ -153,3 +143,13 @@ grub_tpm_measure (unsigned char *buf, grub_size_t size, grub_uint8_t pcr,
>
> return GRUB_ERR_NONE;
> }
> +
> +int
> +grub_tpm_present (void)
> +{
> + /*
> + * Call tpm_init() 'late' rather than from GRUB_MOD_INIT() so that device nodes
> + * can be found.
> + */
> + return tpm_init() == GRUB_ERR_NONE;
> +}
>
>
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
>
> > diff --git a/grub-core/commands/tpm.c b/grub-core/commands/tpm.c
> > index 2052c36ea..cb8ed6b94 100644
> > --- a/grub-core/commands/tpm.c
> > +++ b/grub-core/commands/tpm.c
> > @@ -86,10 +86,14 @@ struct grub_file_verifier grub_tpm_verifier = {
> > GRUB_MOD_INIT (tpm)
> > {
> > + if (!grub_tpm_present())
> > + return;
>
> Even though this now calls grub_tpm_present() from GRUB_MOD_INIT() and I have this comment in the code
> above, it does seem to call it late enough in the initialization sequence so that whatever discovered
> 'device nodes' before your GRUB_MOD_INIT() is called, enables the ibmvtpm driver to see the device nodes.
Thanks to the clarification. I think it is worth to keep this comment in
the patched hunk so the reader won't get confused by the comment
followed in grub_tpm_present.
>
> Per my tests powerpc grub now measures and logs for PCR 8 and 9 correctly and also extends PCRs 8 & 9.
> I hope that nothing will change this initialization order because there seems to be little control over it.
I will merge you change and submit a new version.
Thanks.
Michael
>
> Stefan
>
> > grub_verifier_register (&grub_tpm_verifier);
> > }
> > GRUB_MOD_FINI (tpm)
> > {
> > + if (!grub_tpm_present())
> > + return;
> > grub_verifier_unregister (&grub_tpm_verifier);
> > }
> > diff --git a/include/grub/tpm.h b/include/grub/tpm.h
> > index 5c285cbc5..c19fcbd0a 100644
> > --- a/include/grub/tpm.h
> > +++ b/include/grub/tpm.h
> > @@ -36,4 +36,5 @@
> > grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size,
> > grub_uint8_t pcr, const char *description);
> > +int grub_tpm_present (void);
> > #endif
prev parent reply other threads:[~2023-02-20 4:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-07 5:37 [PATCH v2] tpm: Disable tpm verifier if tpm is not present Michael Chang
2022-10-14 9:40 ` Daniel Kiper
2022-10-17 5:19 ` Michael Chang
2022-11-24 16:04 ` Daniel Kiper
2022-11-25 7:00 ` Michael Chang
2022-11-29 15:11 ` Daniel Kiper
2023-02-20 4:57 ` Michael Chang
2023-02-23 13:22 ` Daniel Kiper
2023-02-28 3:22 ` Michael Chang
2023-03-02 18:59 ` Daniel Kiper
2023-03-03 4:18 ` Michael Chang
2023-03-03 18:19 ` Daniel Kiper
2023-03-06 3:58 ` Michael Chang
2023-02-16 18:02 ` Stefan Berger
2023-02-20 4:39 ` Michael Chang [this message]
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=20230220043900.umw7mtyzzmpecmog@lore \
--to=mchang@suse.com \
--cc=grub-devel@gnu.org \
--cc=stefanb@linux.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.