mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javierm@redhat.com>
To: Thiebaud Weksteen <tweek@google.com>, linux-efi@vger.kernel.org
Cc: ard.biesheuvel@linaro.org, matt@codeblueprint.co.uk,
	linux-kernel@vger.kernel.org, mjg59@google.com,
	jgunthorpe@obsidianresearch.com,
	tpmdd-devel@lists.sourceforge.net,
	jarkko.sakkinen@linux.intel.com, Peter Jones <pjones@redhat.com>
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@google.com>

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@google.com>
> ---

[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

  parent reply	other threads:[~2017-09-14 10:24 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-11 10:00 [PATCH v2 0/3] Call GetEventLog " 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
2017-09-13 14:49   ` kbuild test robot
2017-09-14 10:24   ` Javier Martinez Canillas [this message]
2017-09-18 12:11     ` [tpmdd-devel] " Thiebaud Weksteen
2017-09-18 12:49       ` Javier Martinez Canillas
2017-09-14 18:43   ` Jarkko Sakkinen
2017-09-14 18:48     ` Matthew Garrett
2017-09-14 19:02       ` Jarkko Sakkinen
2017-09-15  4:06         ` Jarkko Sakkinen
2017-09-18 12:28         ` Thiebaud Weksteen
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
2017-09-11 16:47   ` Jason Gunthorpe
2017-09-12  8:48     ` Thiebaud Weksteen
2017-09-18 12:38       ` Thiebaud Weksteen
2017-09-18 16:28         ` Jason Gunthorpe
2017-09-13 16:27   ` kbuild test robot
2017-09-13 16:43     ` Thiebaud Weksteen
2017-09-14 18:47   ` Jarkko Sakkinen
2017-09-18 12:33     ` Thiebaud Weksteen
2017-09-13 18:59 ` [PATCH v2 0/3] Call GetEventLog before ExitBootServices Jarkko Sakkinen
2017-09-14 10:21 ` [tpmdd-devel] " Javier Martinez Canillas
2017-11-03 15:27 ` 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=1f25ebdc-ab90-517f-b580-991a7cb5e25a@redhat.com \
    --to=javierm@redhat.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=mjg59@google.com \
    --cc=pjones@redhat.com \
    --cc=tpmdd-devel@lists.sourceforge.net \
    --cc=tweek@google.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 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®