lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <157045974981.9978.10521392421826592930.tip-bot2@tip-bot2>
Date:   Mon, 07 Oct 2019 14:49:09 -0000
From:   "tip-bot2 for Peter Jones" <tip-bot2@...utronix.de>
To:     linux-tip-commits@...r.kernel.org
Cc:     Lyude Paul <lyude@...hat.com>, Peter Jones <pjones@...hat.com>,
        Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
        Ard Biesheuvel <ard.biesheuvel@...aro.org>,
        Matthew Garrett <mjg59@...gle.com>,
        Ben Dooks <ben.dooks@...ethink.co.uk>,
        Dave Young <dyoung@...hat.com>,
        Jerry Snitselaar <jsnitsel@...hat.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Lukas Wunner <lukas@...ner.de>,
        Octavian Purdila <octavian.purdila@...el.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Scott Talbert <swt@...hie.net>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-efi@...r.kernel.org, linux-integrity@...r.kernel.org,
        stable@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
        Borislav Petkov <bp@...en8.de>, linux-kernel@...r.kernel.org
Subject: [tip: efi/urgent] efi/tpm: Don't traverse an event log with no events

The following commit has been merged into the efi/urgent branch of tip:

Commit-ID:     05c8c1ff81ed2eb9bad7c27cf92e55c864c16df8
Gitweb:        https://git.kernel.org/tip/05c8c1ff81ed2eb9bad7c27cf92e55c864c16df8
Author:        Peter Jones <pjones@...hat.com>
AuthorDate:    Wed, 02 Oct 2019 18:59:01 +02:00
Committer:     Ingo Molnar <mingo@...nel.org>
CommitterDate: Mon, 07 Oct 2019 15:24:35 +02:00

efi/tpm: Don't traverse an event log with no events

When there are no entries to put into the final event log, some machines
will return the template they would have populated anyway.  In this case
the nr_events field is 0, but the rest of the log is just garbage.

This patch stops us from trying to iterate the table with
__calc_tpm2_event_size() when the number of events in the table is 0.

Tested-by: Lyude Paul <lyude@...hat.com>
Signed-off-by: Peter Jones <pjones@...hat.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@...aro.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
Acked-by: Matthew Garrett <mjg59@...gle.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@...aro.org>
Cc: Ben Dooks <ben.dooks@...ethink.co.uk>
Cc: Dave Young <dyoung@...hat.com>
Cc: Jerry Snitselaar <jsnitsel@...hat.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Lukas Wunner <lukas@...ner.de>
Cc: Octavian Purdila <octavian.purdila@...el.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Scott Talbert <swt@...hie.net>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-efi@...r.kernel.org
Cc: linux-integrity@...r.kernel.org
Cc: stable@...r.kernel.org
Fixes: c46f3405692d ("tpm: Reserve the TPM final events table")
Link: https://lkml.kernel.org/r/20191002165904.8819-5-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
 drivers/firmware/efi/tpm.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
index 1d3f5ca..b9ae5c6 100644
--- a/drivers/firmware/efi/tpm.c
+++ b/drivers/firmware/efi/tpm.c
@@ -75,11 +75,16 @@ int __init efi_tpm_eventlog_init(void)
 		goto out;
 	}
 
-	tbl_size = tpm2_calc_event_log_size((void *)efi.tpm_final_log
-					    + sizeof(final_tbl->version)
-					    + sizeof(final_tbl->nr_events),
-					    final_tbl->nr_events,
-					    log_tbl->log);
+	tbl_size = 0;
+	if (final_tbl->nr_events != 0) {
+		void *events = (void *)efi.tpm_final_log
+				+ sizeof(final_tbl->version)
+				+ sizeof(final_tbl->nr_events);
+
+		tbl_size = tpm2_calc_event_log_size(events,
+						    final_tbl->nr_events,
+						    log_tbl->log);
+	}
 	memblock_reserve((unsigned long)final_tbl,
 			 tbl_size + sizeof(*final_tbl));
 	early_memunmap(final_tbl, sizeof(*final_tbl));

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ