From patchwork Fri Mar 9 10:50:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thi=C3=A9baud_Weksteen?= X-Patchwork-Id: 10270439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7222960211 for ; Fri, 9 Mar 2018 10:50:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 643B728736 for ; Fri, 9 Mar 2018 10:50:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5892429DB0; Fri, 9 Mar 2018 10:50:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A86928736 for ; Fri, 9 Mar 2018 10:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751147AbeCIKu2 (ORCPT ); Fri, 9 Mar 2018 05:50:28 -0500 Received: from mail-ua0-f202.google.com ([209.85.217.202]:33323 "EHLO mail-ua0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751008AbeCIKu0 (ORCPT ); Fri, 9 Mar 2018 05:50:26 -0500 Received: by mail-ua0-f202.google.com with SMTP id d35so1692152uag.0 for ; Fri, 09 Mar 2018 02:50:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:message-id:subject:from:to:cc; bh=zCBA5iT4ehnWvjFHQ8MafBBTS20Rj1Q9M8May4gxPOk=; b=ujqT9jP/JHZFlNehZpwWEyFRXa9Uakiswc2LgRTsomLoVT/iypEe0WpkdlT2PKwm+2 cAqw3kF0/IPjzKBwWSUmCIpaN9Zki5G8tQ3CEZe2+j+ozbdyb1+pH1j587+JJjz3BvIz iIRV6ijHSNfGDrBgVkWNFn8b5gi88hsimI8GEC23BE+vrizHa+yQI6p1TZhTK1u8NrDz IxcJHbAaB0+kDz/yujGIPG2eiij6zXI+YeJHo2lSAYf49i5tRHQtoR0g+uycv0Guw9V5 zlRyuJFvANzwq6fm6bonELpXl7nLRYm75BlkA1lWOG7heea9m/ETIUOqG76ASeSCI6Da qZ2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=zCBA5iT4ehnWvjFHQ8MafBBTS20Rj1Q9M8May4gxPOk=; b=iRP+270Ak8+ZPezF1gIHivpXB94pQmXFfm+2LDWZ8K54aSErva4lfQhzXo4uZNABsK L0F22JXe+RmEdT8ezaxqddmUfF356a3D1YHxfQZzi21GERMUW8jlZifg3LqqbOyMmz64 /vFZGM2dG89z6/cYKzz37s7S7vHFF3qpIt2Un3O1jiz0z7yILFVX04OhzQpprqGYXAxl 387EzAg/Q99W8PInqc0389MTX9u4S8ijx/Idh2otVi1znPOwyGDb6p+e9qWsObMoJ56u sWa1c0YQbehW0uI++6I0sobev0L/sfQ+ftD4MTck1cGEzkx6uGRwd7sWGiNKnFGqZ+PK T9fw== X-Gm-Message-State: AElRT7FGeHT6mOfUwUGnHnleMbwNvC1y9sx7OfQiOmbzUKxtZk1nsn9p nr7Lpj63FY1A1qie20NRo1PkUonl0g== X-Google-Smtp-Source: AG47ELtYbq623gCuzTwY3aHW6KQrju1ENt5KPBNPqc0y3wuRF6lrIal95bqTV7KUVUfI5XIkZl2hLtOQAw== MIME-Version: 1.0 X-Received: by 10.159.48.222 with SMTP id k30mr14107194uab.11.1520592625767; Fri, 09 Mar 2018 02:50:25 -0800 (PST) Date: Fri, 9 Mar 2018 11:50:15 +0100 Message-Id: <20180309105015.97429-1-tweek@google.com> X-Mailer: git-send-email 2.16.2.395.g2e18187dfd-goog Subject: Re: Regression from efi: call get_event_log before ExitBootServices From: Thiebaud Weksteen To: Jeremy Cline Cc: Javier Martinez Canillas , Jarkko Sakkinen , hdegoede@redhat.com, linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Thiebaud Weksteen Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP --- drivers/firmware/efi/libstub/tpm.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c index 773afcd6a37c..ee3fac109078 100644 --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -112,6 +112,22 @@ void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg) log_size = log_last_entry - log_location + last_entry_size; } + if (log_size == 0) { + efi_printk(sys_table_arg, "log_size == 0\n"); + } + else if (log_size < 1 * 1024 * 1024) { + efi_printk(sys_table_arg, "log_size < 1M\n"); + } + else if (log_size < 500 * 1024 * 1024) { + efi_printk(sys_table_arg, "log_size < 500M\n"); + } + else if (log_size < 1000 * 1024 * 1024) { + efi_printk(sys_table_arg, "log_size < 1G\n"); + } + else { + efi_printk(sys_table_arg, "log_size > 1G\n"); + } + efi_printk(sys_table_arg, "Allocating memory for storing the logs\n"); /* Allocate space for the logs and copy them. */ status = efi_call_early(allocate_pool, EFI_LOADER_DATA, @@ -124,6 +140,11 @@ void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg) "Unable to allocate memory for event log\n"); return; } + if (!log_tbl) { + efi_printk(sys_table_arg, "Pointer returned from allocation is NULL!\n"); + return; + } + efi_printk(sys_table_arg, "Copying log to new location\n"); memset(log_tbl, 0, sizeof(*log_tbl) + log_size);