All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL 0/1] EFI fix for v4.16
@ 2018-03-13 14:09 Ard Biesheuvel
  2018-03-13 14:09 ` [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables for mixed mode Ard Biesheuvel
  0 siblings, 1 reply; 5+ messages in thread
From: Ard Biesheuvel @ 2018-03-13 14:09 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner
  Cc: hdegoede, tweek, javierm, jarkko.sakkinen, Ard Biesheuvel,
	linux-kernel, Jeremy Cline

The following changes since commit 7928b2cbe55b2a410a0f5c1f154610059c57b1b2:

  Linux 4.16-rc1 (2018-02-11 15:04:29 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-urgent

for you to fetch changes up to 5c4d724b7ccfa934b95c5c49fab770035a425950:

  efi/libstub: tpm: zero initialize pointer variables for mixed mode (2018-03-13 13:48:25 +0000)

----------------------------------------------------------------
EFI fix for v4.16:
- fix an issue in the mixed mode handling of the new TPM libstub code

----------------------------------------------------------------
Ard Biesheuvel (1):
      efi/libstub: tpm: zero initialize pointer variables for mixed mode

 drivers/firmware/efi/libstub/tpm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables for mixed mode
  2018-03-13 14:09 [GIT PULL 0/1] EFI fix for v4.16 Ard Biesheuvel
@ 2018-03-13 14:09 ` Ard Biesheuvel
  2018-03-13 15:10   ` Javier Martinez Canillas
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2018-03-13 14:09 UTC (permalink / raw)
  To: linux-efi, Ingo Molnar, Thomas Gleixner
  Cc: hdegoede, tweek, javierm, jarkko.sakkinen, Ard Biesheuvel, linux-kernel

As reported by Jeremy, running the new TPM libstub code in mixed mode
(i.e., 64-bit kernel on 32-bit UEFI) results in hangs when invoking
the TCG2 protocol, or when accessing the log_tbl pool allocation.

The reason turns out to be that in both cases, the 64-bit pointer
variables are not fully initialized by the 32-bit EFI code, and so
we should take care to zero initialize these variables beforehand,
or we'll end up dereferencing bogus pointers.

Reported-by: Jeremy Cline <jeremy@jcline.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/firmware/efi/libstub/tpm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
index da661bf8cb96..13c1edd37e96 100644
--- a/drivers/firmware/efi/libstub/tpm.c
+++ b/drivers/firmware/efi/libstub/tpm.c
@@ -68,11 +68,11 @@ void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg)
 	efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID;
 	efi_status_t status;
 	efi_physical_addr_t log_location, log_last_entry;
-	struct linux_efi_tpm_eventlog *log_tbl;
+	struct linux_efi_tpm_eventlog *log_tbl = NULL;
 	unsigned long first_entry_addr, last_entry_addr;
 	size_t log_size, last_entry_size;
 	efi_bool_t truncated;
-	void *tcg2_protocol;
+	void *tcg2_protocol = NULL;
 
 	status = efi_call_early(locate_protocol, &tcg2_guid, NULL,
 				&tcg2_protocol);
-- 
2.15.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables for mixed mode
  2018-03-13 14:09 ` [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables for mixed mode Ard Biesheuvel
@ 2018-03-13 15:10   ` Javier Martinez Canillas
  2018-03-13 15:14   ` [tip:efi/urgent] efi/libstub/tpm: Initialize pointer variables to zero " tip-bot for Ard Biesheuvel
  2018-03-16 13:02   ` [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables " Jarkko Sakkinen
  2 siblings, 0 replies; 5+ messages in thread
From: Javier Martinez Canillas @ 2018-03-13 15:10 UTC (permalink / raw)
  To: Ard Biesheuvel, linux-efi, Ingo Molnar, Thomas Gleixner
  Cc: hdegoede, tweek, jarkko.sakkinen, linux-kernel, linux-integrity,
	tpmdd-devel

[adding linux-integrity and tpmdd-devel since this was discussed in these ML too]

On 03/13/2018 03:09 PM, Ard Biesheuvel wrote:
> As reported by Jeremy, running the new TPM libstub code in mixed mode
> (i.e., 64-bit kernel on 32-bit UEFI) results in hangs when invoking
> the TCG2 protocol, or when accessing the log_tbl pool allocation.
> 
> The reason turns out to be that in both cases, the 64-bit pointer
> variables are not fully initialized by the 32-bit EFI code, and so
> we should take care to zero initialize these variables beforehand,
> or we'll end up dereferencing bogus pointers.
> 
> Reported-by: Jeremy Cline <jeremy@jcline.org>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  drivers/firmware/efi/libstub/tpm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
> index da661bf8cb96..13c1edd37e96 100644
> --- a/drivers/firmware/efi/libstub/tpm.c
> +++ b/drivers/firmware/efi/libstub/tpm.c
> @@ -68,11 +68,11 @@ void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg)
>  	efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID;
>  	efi_status_t status;
>  	efi_physical_addr_t log_location, log_last_entry;
> -	struct linux_efi_tpm_eventlog *log_tbl;
> +	struct linux_efi_tpm_eventlog *log_tbl = NULL;
>  	unsigned long first_entry_addr, last_entry_addr;
>  	size_t log_size, last_entry_size;
>  	efi_bool_t truncated;
> -	void *tcg2_protocol;
> +	void *tcg2_protocol = NULL;
>  
>  	status = efi_call_early(locate_protocol, &tcg2_guid, NULL,
>  				&tcg2_protocol);
> 

Looks good to me.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Best regards,
-- 
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:efi/urgent] efi/libstub/tpm: Initialize pointer variables to zero for mixed mode
  2018-03-13 14:09 ` [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables for mixed mode Ard Biesheuvel
  2018-03-13 15:10   ` Javier Martinez Canillas
@ 2018-03-13 15:14   ` tip-bot for Ard Biesheuvel
  2018-03-16 13:02   ` [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables " Jarkko Sakkinen
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Ard Biesheuvel @ 2018-03-13 15:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, linux-kernel, jeremy, ard.biesheuvel, mingo, peterz, torvalds, hpa

Commit-ID:  79832f0b5f718e0023d9dd73e6845310609a564d
Gitweb:     https://git.kernel.org/tip/79832f0b5f718e0023d9dd73e6845310609a564d
Author:     Ard Biesheuvel <ard.biesheuvel@linaro.org>
AuthorDate: Tue, 13 Mar 2018 14:09:21 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 13 Mar 2018 15:28:29 +0100

efi/libstub/tpm: Initialize pointer variables to zero for mixed mode

As reported by Jeremy Cline, running the new TPM libstub code in mixed
mode (i.e., 64-bit kernel on 32-bit UEFI) results in hangs when invoking
the TCG2 protocol, or when accessing the log_tbl pool allocation.

The reason turns out to be that in both cases, the 64-bit pointer
variables are not fully initialized by the 32-bit EFI code, and so
we should take care to zero initialize these variables beforehand,
or we'll end up dereferencing bogus pointers.

Reported-by: Jeremy Cline <jeremy@jcline.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: hdegoede@redhat.com
Cc: jarkko.sakkinen@linux.intel.com
Cc: javierm@redhat.com
Cc: linux-efi@vger.kernel.org
Cc: tweek@google.com
Link: http://lkml.kernel.org/r/20180313140922.17266-2-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/firmware/efi/libstub/tpm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
index da661bf8cb96..13c1edd37e96 100644
--- a/drivers/firmware/efi/libstub/tpm.c
+++ b/drivers/firmware/efi/libstub/tpm.c
@@ -68,11 +68,11 @@ void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg)
 	efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID;
 	efi_status_t status;
 	efi_physical_addr_t log_location, log_last_entry;
-	struct linux_efi_tpm_eventlog *log_tbl;
+	struct linux_efi_tpm_eventlog *log_tbl = NULL;
 	unsigned long first_entry_addr, last_entry_addr;
 	size_t log_size, last_entry_size;
 	efi_bool_t truncated;
-	void *tcg2_protocol;
+	void *tcg2_protocol = NULL;
 
 	status = efi_call_early(locate_protocol, &tcg2_guid, NULL,
 				&tcg2_protocol);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables for mixed mode
  2018-03-13 14:09 ` [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables for mixed mode Ard Biesheuvel
  2018-03-13 15:10   ` Javier Martinez Canillas
  2018-03-13 15:14   ` [tip:efi/urgent] efi/libstub/tpm: Initialize pointer variables to zero " tip-bot for Ard Biesheuvel
@ 2018-03-16 13:02   ` Jarkko Sakkinen
  2 siblings, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2018-03-16 13:02 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-efi, Ingo Molnar, Thomas Gleixner, hdegoede, tweek,
	javierm, linux-kernel

On Tue, Mar 13, 2018 at 02:09:21PM +0000, Ard Biesheuvel wrote:
> As reported by Jeremy, running the new TPM libstub code in mixed mode
> (i.e., 64-bit kernel on 32-bit UEFI) results in hangs when invoking
> the TCG2 protocol, or when accessing the log_tbl pool allocation.
> 
> The reason turns out to be that in both cases, the 64-bit pointer
> variables are not fully initialized by the 32-bit EFI code, and so
> we should take care to zero initialize these variables beforehand,
> or we'll end up dereferencing bogus pointers.
> 
> Reported-by: Jeremy Cline <jeremy@jcline.org>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-16 13:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-13 14:09 [GIT PULL 0/1] EFI fix for v4.16 Ard Biesheuvel
2018-03-13 14:09 ` [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables for mixed mode Ard Biesheuvel
2018-03-13 15:10   ` Javier Martinez Canillas
2018-03-13 15:14   ` [tip:efi/urgent] efi/libstub/tpm: Initialize pointer variables to zero " tip-bot for Ard Biesheuvel
2018-03-16 13:02   ` [PATCH 1/1] efi/libstub: tpm: zero initialize pointer variables " Jarkko Sakkinen

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.