From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Eddie James <eajames@linux.ibm.com>
Cc: u-boot@lists.denx.de, sjg@chromium.org, xypron.glpk@gmx.de,
joel@jms.id.au
Subject: Re: [PATCH v7 3/6] tpm: Support boot measurements
Date: Thu, 2 Mar 2023 16:17:26 +0200 [thread overview]
Message-ID: <ZACv9smeBfOjt/AW@hera> (raw)
In-Reply-To: <20230301225056.1402722-4-eajames@linux.ibm.com>
Hi Eddie,
The good news, is that this generally seems to be working and is really
close to what I had in mind on code re-usage. Thanks for the patience!
The bad new now is that I think I found one last (famous last words)
problem
[...]
> + }
> +
> + /* Read PCR0 to check if previous firmware extended the PCRs or not. */
> + rc = tcg2_pcr_read(dev, 0, &digest_list);
> + if (rc)
> + return rc;
> +
This is changing how the code used to work and I think the new way of doing
it is wrong.
First of all the check above doesn't check that PCR0 is indeed 0. It
simply checks we can *read* that PCR.
> + for (i = 0; i < digest_list.count; ++i) {
> + len = tpm2_algorithm_to_len(digest_list.digests[i].hash_alg);
> + for (j = 0; j < len; ++j) {
> + if (digest_list.digests[i].digest.sha512[j])
> + break;
> + }
> +
> + /* PCR is non-zero; it has been extended, so skip extending. */
I don't think we need this tbh. The previous bootloader would have either
extended some of the PCRs along with the EventLog construction or he hasn't.
If it did indeed extend the PCRs then PCR0 should be != 0 since it must
contain a measurement of EV_S_CRTM_VERSION. So looking at PCR0 should be
sufficient to trigger replaying the EventLog or not.
If the previous loader managed to mess up somehow, I don't think it should
be U-Boot's job to fix the mess :)
> + if (j != len) {
> + digest_list.count = 0;
> + break;
> + }
> + }
> +
> + elog->log_position = offsetof(struct tcg_pcr_event, event) + evsz;
> + rc = tcg2_log_find_end(elog, dev, &digest_list);
> + if (rc)
> + return rc;
> +
> + elog->found = true;
> + return 0;
> +}
> +
P.S: I did test this using TF-A and re-using the 'forwarded' EventLog. I
can see all the events replayed correctly apart from the last one, so i'll
keep looking in case something else is missing
Regards
/Ilias
next prev parent reply other threads:[~2023-03-02 14:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 22:50 [PATCH v7 0/6] tpm: Support boot measurements Eddie James
2023-03-01 22:50 ` [PATCH v7 1/6] tpm: Fix spelling for tpmu_ha union Eddie James
2023-03-01 22:50 ` [PATCH v7 2/6] tpm: sandbox: Update for needed TPM2 capabilities Eddie James
2023-03-01 22:50 ` [PATCH v7 3/6] tpm: Support boot measurements Eddie James
2023-03-02 14:17 ` Ilias Apalodimas [this message]
2023-03-02 14:35 ` Ilias Apalodimas
2023-03-02 20:22 ` Ilias Apalodimas
2023-03-03 19:17 ` Eddie James
2023-03-01 22:50 ` [PATCH v7 4/6] bootm: Support boot measurement Eddie James
2023-03-02 10:28 ` Ilias Apalodimas
2023-03-01 22:50 ` [PATCH v7 5/6] test: Add sandbox TPM " Eddie James
2023-03-01 22:50 ` [PATCH v7 6/6] doc: Add measured boot documentation Eddie James
2023-03-02 10:29 ` Ilias Apalodimas
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=ZACv9smeBfOjt/AW@hera \
--to=ilias.apalodimas@linaro.org \
--cc=eajames@linux.ibm.com \
--cc=joel@jms.id.au \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/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