Received: by 10.213.65.68 with SMTP id h4csp85691imn; Mon, 12 Mar 2018 07:31:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELtcacUybT75bi0RwgbL/WCAuXqC3vPATrkd7y0LTIvQ4yBOs572KxcZvCc7BtxCvkDChdJn X-Received: by 2002:a17:902:8f96:: with SMTP id z22-v6mr8379330plo.169.1520865088902; Mon, 12 Mar 2018 07:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520865088; cv=none; d=google.com; s=arc-20160816; b=fq0RMnmPbDxlrILtTZ855UM8M8OmuWWRpgPE33h+RkI74kgLpgKi1Mw0OqV5cQXhya RCH2i7mP6fVHGxuwIlDhexHt0j4iz9ztAN5n/tJvkl+dr8uPIqVxUziswVgZYPJUz1vy HpPzv+Gw+fBoSqvyT8HG9vVDQ9FqRDUif3+vaP0+xeAo5ef6Aojh9lIVNjSWZ+OkJCyw 1M6lzGyN02MRo/YNHvGDAn6vPbe4GOS1qSiX3ugXTr4IcX39egK1/SJr0odk7PT4e/F+ dkKzV3AHXfkT8w6bh/vFff8AoXyMMP/ULlP9rhjvT2RzTaYvjLXzXhEF9MHI+7eb95GU I8oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :dkim-signature:arc-authentication-results; bh=UIbskj6McCKIPxpxnYbEWGOXp/WfN5ADj3Ozqr+1Ulc=; b=SCyz/LgeJtC28C9qCYFTi17Kgo9KlzeyfYBObq/z1vAYwdH+OCkoeCiSnK0FW8QPDJ 7DutTG/OdXoo4iq35zPz3sUuNjfk91CYBzJPoPKfn680q3ZELDHwDVvLN8yIlcBORMQl kttCSuc/igNMMAaQ/WzWlF+r8bq+Acmp9y66yYRxEMpdJQxkUkWeVEE9IEcgLnGlPX2o VHlvFFOkiXls2zulVL6TJrCzOzO0dG+dX9B2f347JMcEfLBYsZtDYzzLy2bM9GgO0Xmr QNqppe9KAURsrGuyiiOoJajOx6XnoWctu6qqyrYnvDm9Lhr68gy3FfRd/7Gp+n8marEf 5MSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jcline.org header.s=rdybrs3533vx7mghocfwl3vdwgpl2v5u header.b=DcjeL7WS; dkim=pass header.i=@amazonses.com header.s=224i4yxa5dv7c2xz3womw6peuasteono header.b=fGq8zQxl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1-v6si6265110plk.597.2018.03.12.07.31.14; Mon, 12 Mar 2018 07:31:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@jcline.org header.s=rdybrs3533vx7mghocfwl3vdwgpl2v5u header.b=DcjeL7WS; dkim=pass header.i=@amazonses.com header.s=224i4yxa5dv7c2xz3womw6peuasteono header.b=fGq8zQxl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751982AbeCLOaK (ORCPT + 99 others); Mon, 12 Mar 2018 10:30:10 -0400 Received: from a8-242.smtp-out.amazonses.com ([54.240.8.242]:60790 "EHLO a8-242.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751255AbeCLOaH (ORCPT ); Mon, 12 Mar 2018 10:30:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=rdybrs3533vx7mghocfwl3vdwgpl2v5u; d=jcline.org; t=1520865006; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=IbYpzqsiIzqcNV1Cd4uEUokgcbtsKhqxMWXj94KoTpY=; b=DcjeL7WSoo2E+jh1u6UTZdaSnqfYvorgAs5HdFKZ59U4HmjfIM2AudlERLxxUrbh 2kvcTaXGpzQLFtnNXVgoNaU19O7xk4SojnlQKRRt9TxhISo9+kc9xxcwt07IjIYG6Ql iSxTHDz/tn2zDhI+zh3kc7xo1E4L9HkrCFF/DwPU= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=224i4yxa5dv7c2xz3womw6peuasteono; d=amazonses.com; t=1520865006; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=IbYpzqsiIzqcNV1Cd4uEUokgcbtsKhqxMWXj94KoTpY=; b=fGq8zQxlgRoaPHMDtE5BoEpru3xb4ntFZf6zlTxLOp5XChXfZGyZay8qd8Qg0SK1 EccbfBxUMaJz3m3kPttzVrAw5HEBlwOplW44cZtoeS/9POTzK37udk00M+oq21VCM6p 2vwP85lT9/kuP2jpnmyHJbirTd0ndVgLmvTXn5h0= X-Virus-Scanned: amavisd-new at jcline.org Subject: Re: Regression from efi: call get_event_log before ExitBootServices To: Ard Biesheuvel , Thiebaud Weksteen Cc: Hans de Goede , Javier Martinez Canillas , Jarkko Sakkinen , linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org, tpmdd-devel@lists.sourceforge.net, Linux Kernel Mailing List References: <01000161fc0b4755-df0621f4-ab5d-479a-b425-adf98427a308-000000@email.amazonses.com> <0100016206a68850-bd5c96b3-f275-46ea-98b1-1317e02a5d6e-000000@email.amazonses.com> <29c1640a-cf19-ca19-7de9-96f202edfb5a@redhat.com> <010001620bafa06b-41525407-603e-40a9-ba11-6033b2f5dcc7-000000@email.amazonses.com> From: Jeremy Cline Message-ID: <010001621a9e5069-0b1a6328-97e4-4396-9438-b90f5b8c82a4-000000@email.amazonses.com> Date: Mon, 12 Mar 2018 14:30:05 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-SES-Outgoing: 2018.03.12-54.240.8.242 Feedback-ID: 1.us-east-1.z18Isoc/FaoPOvCyJyi1mnTt8STwoRuibXVNoUcvG6g=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/12/2018 07:08 AM, Ard Biesheuvel wrote: > On 10 March 2018 at 10:45, Thiebaud Weksteen wrote: >> On Fri, Mar 9, 2018 at 5:54 PM Jeremy Cline wrote: >> >>> On Fri, Mar 09, 2018 at 10:43:50AM +0000, Thiebaud Weksteen wrote: >>>> Thanks a lot for trying out the patch! >>>> >>>> Please don't modify your install at this stage, I think we are hitting a >>>> firmware bug and that would be awesome if we can fix how we are >> handling it. >>>> So, if we reach that stage in the function it could either be that: >>>> * The allocation did not succeed, somehow, but the firmware still >> returned >>>> EFI_SUCCEED. >>>> * The size requested is incorrect (I'm thinking something like a 1G of >>>> log). This would be due to either a miscalculation of log_size >> (possible) >>>> or; the returned values of GetEventLog are not correct. >>>> I'm sending a patch to add checks for these. Could you please apply and >>>> retest? >>>> Again, thanks for helping debugging this. >> >>> No problem, thanks for the help :) >> >>> With the new patch: >> >>> Locating the TCG2Protocol >>> Calling GetEventLog on TCG2Protocol >>> Log returned >>> log_location is not empty >>> log_size != 0 >>> log_size < 1M >>> Allocating memory for storing the logs >>> Returned from memory allocation >>> Copying log to new location >> >>> And then it hangs. I added a couple more print statements: >> >>> diff --git a/drivers/firmware/efi/libstub/tpm.c >> b/drivers/firmware/efi/libstub/tpm.c >>> index ee3fac109078..1ab5638bc50e 100644 >>> --- a/drivers/firmware/efi/libstub/tpm.c >>> +++ b/drivers/firmware/efi/libstub/tpm.c >>> @@ -148,8 +148,11 @@ void >> efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg) >>> efi_printk(sys_table_arg, "Copying log to new location\n"); >> >>> memset(log_tbl, 0, sizeof(*log_tbl) + log_size); >>> + efi_printk(sys_table_arg, "Successfully memset log_tbl to 0\n"); >>> log_tbl->size = log_size; >>> + efi_printk(sys_table_arg, "Set log_tbl->size\n"); >>> log_tbl->version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2; >>> + efi_printk(sys_table_arg, "Set log_tbl-version\n"); >>> memcpy(log_tbl->log, (void *) first_entry_addr, log_size); >> >>> efi_printk(sys_table_arg, "Installing the log into the >> configuration table\n"); >> >>> and it's hanging at "memset(log_tbl, 0, sizeof(*log_tbl) + log_size);" >> >> Thanks. Well, it looks like the memory that is supposedly allocated is not >> usable. I'm thinking this is a firmware bug. >> Ard, would you agree on this assumption? Thoughts on how to proceed? >> > > I am rather puzzled why the allocate_pool() should succeed and the > subsequent memset() should fail. This does not look like an issue that > is intimately related to TPM2 support, rather an issue in the firmware > that happens to get tickled after the change. > > Would you mind trying replacing EFI_LOADER_DATA with > EFI_BOOT_SERVICES_DATA in the allocate_pool() call? Replacing EFI_LOADER_DATA with EFI_BOOT_SERVICES_DATA still hangs at the memset() call. Regards, Jeremy