From: Javier Martinez Canillas <javierm-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Thiebaud Weksteen <tweek-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
mjg59-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
Peter Jones <pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [tpmdd-devel] [PATCH v2 2/3] efi: call get_event_log before ExitBootServices
Date: Thu, 14 Sep 2017 12:24:29 +0200 [thread overview]
Message-ID: <1f25ebdc-ab90-517f-b580-991a7cb5e25a@redhat.com> (raw)
In-Reply-To: <20170911100022.7251-3-tweek-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
On 09/11/2017 12:00 PM, Thiebaud Weksteen via tpmdd-devel wrote:
> With TPM 2.0 specification, the event logs may only be accessible by
> calling an EFI Boot Service. Modify the EFI stub to copy the log area to
> a new Linux-specific EFI configuration table so it remains accessible
> once booted.
>
> When calling this service, it is possible to specify the expected format
> of the logs: TPM 1.2 (SHA1) or TPM 2.0 ("Crypto Agile"). For now, only the
> first format is retrieved.
>
> Signed-off-by: Thiebaud Weksteen <tweek-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> ---
[snip]
> +void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg)
> +{
[snip]
> +
> + /* Allocate space for the logs and copy them. */
> + status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
> + sizeof(*log_tbl) + log_size,
> + (void **) &log_tbl);
> +
> + if (status != EFI_SUCCESS) {
> + efi_printk(sys_table_arg,
> + "Unable to allocate memory for event log\n");
> + return;
> + }
If this fails or any previous error that will prevent the event log table + logs
to be allocated, shouldn't tpm_read_log_efi() be notified somehow? Since AFAICT
it will still try to access them even if the EFI allocate_pool did not succeed.
> + */
> +int __init efi_tpm_eventlog_init(void)
> +{
> + struct linux_efi_tpm_eventlog *tbl;
> + unsigned int tbl_size;
> +
The functions efi_retrieve_tpm2_eventlog_1_2() and tpm_read_log_efi() are using
log_tbl as variable name, so I would use it here too for consistency.
> + if (efi.tpm_log == EFI_INVALID_TABLE_ADDR)
> + return 0;
> +
> + tbl = early_memremap(efi.tpm_log, sizeof(*tbl));
> + if (!tbl) {
> + pr_err("Failed to map TPM Event Log table @ 0x%lx\n",
> + efi.tpm_log);
> + return -ENOMEM;
> + }
> +
Same question than before, if this fails then the table + logs memory won't be
reserved but tpm_read_log_efi() will still try to access it. I'm not sure what
is the correct way to notify though, maybe setting efi.tpm_log to 0 and then in
tpm_read_log_efi() check efi.tpm_log for 0 or EFI_INVALID_TABLE_ADDR instead?
> + tbl_size = sizeof(*tbl) + tbl->size;
> + memblock_reserve(efi.tpm_log, tbl_size);
> + early_memunmap(tbl, sizeof(*tbl));
> + return 0;
Best regards,
--
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat
next prev parent reply other threads:[~2017-09-14 10:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-11 10:00 [PATCH v2 0/3] Call GetEventLog before ExitBootServices Thiebaud Weksteen
2017-09-11 10:00 ` [PATCH v2 1/3] tpm: move tpm_eventlog.h outside of drivers folder Thiebaud Weksteen
2017-09-11 10:00 ` [PATCH v2 2/3] efi: call get_event_log before ExitBootServices Thiebaud Weksteen
[not found] ` <20170911100022.7251-3-tweek-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-09-13 14:49 ` kbuild test robot
[not found] ` <201709132252.uZyTCtDz%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-09-13 16:28 ` Thiebaud Weksteen via tpmdd-devel
2017-09-14 10:24 ` Javier Martinez Canillas [this message]
[not found] ` <1f25ebdc-ab90-517f-b580-991a7cb5e25a-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-09-18 12:11 ` [tpmdd-devel] " Thiebaud Weksteen
2017-09-18 12:49 ` Javier Martinez Canillas
2017-09-14 18:43 ` Jarkko Sakkinen
[not found] ` <20170914184126.eevnstwq3i6fiq4j-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-09-14 18:48 ` Matthew Garrett
2017-09-14 19:02 ` Jarkko Sakkinen
[not found] ` <20170914190247.rrbdzdexjjywxipf-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-09-15 4:06 ` Jarkko Sakkinen
2017-09-18 12:28 ` Thiebaud Weksteen
[not found] ` <CA+zpnLfs=DhW6kgbLV63_XzmKS7VnGGE0ecbFBZ0bu4wx3Jf+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-09-18 17:56 ` Jarkko Sakkinen
2017-09-11 10:00 ` [PATCH v2 3/3] tpm: parse TPM event logs based on EFI table Thiebaud Weksteen
[not found] ` <20170911100022.7251-4-tweek-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-09-11 16:47 ` Jason Gunthorpe
2017-09-12 8:48 ` Thiebaud Weksteen
[not found] ` <20170912084851.z3ednbeojawnyxk2-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-09-18 12:38 ` Thiebaud Weksteen
2017-09-18 16:28 ` Jason Gunthorpe
2017-09-13 16:27 ` kbuild test robot
[not found] ` <201709140034.ESdZA8H8%fengguang.wu-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-09-13 16:43 ` Thiebaud Weksteen
2017-09-14 18:47 ` Jarkko Sakkinen
[not found] ` <20170914184732.uiypaz4yft777oc7-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-09-18 12:33 ` Thiebaud Weksteen
[not found] ` <20170911100022.7251-1-tweek-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-09-13 18:59 ` [PATCH v2 0/3] Call GetEventLog before ExitBootServices Jarkko Sakkinen
2017-11-03 15:27 ` Jarkko Sakkinen
2017-09-14 10:21 ` [tpmdd-devel] " Javier Martinez Canillas
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=1f25ebdc-ab90-517f-b580-991a7cb5e25a@redhat.com \
--to=javierm-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org \
--cc=mjg59-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=tweek-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.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;
as well as URLs for NNTP newsgroup(s).