From patchwork Mon Feb 11 14:30:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Szczepanek X-Patchwork-Id: 10806177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23B171399 for ; Mon, 11 Feb 2019 16:01:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12B632ABE4 for ; Mon, 11 Feb 2019 16:01:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06E752AC8B; Mon, 11 Feb 2019 16:01:10 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 8A8B82AC94 for ; Mon, 11 Feb 2019 16:01:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730473AbfBKQBI (ORCPT ); Mon, 11 Feb 2019 11:01:08 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45802 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729721AbfBKOb1 (ORCPT ); Mon, 11 Feb 2019 09:31:27 -0500 Received: by mail-lj1-f194.google.com with SMTP id s5-v6so8889335ljd.12 for ; Mon, 11 Feb 2019 06:31:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AI0vxFWLuRgnzWT6ylhQhD0AdrQinrJeHY3w7Uhh0g8=; b=v2ksebaY4Ez01MrEKe6v7Ktauk/pBeXlPkS/WEEjGiEuuyVqjEhrsebEPUp/cy3/EB e7gMkTC9Df0iGfKUWHq7S4Br3Q/hWaRaMCWaC7kruVyrPzL6o+RvDsogOk1/4HFS/hsn YOtZgNvjDi1Lq0eKe9UwTEKbuoPB9V6EpQpBmAzhni7kOGifauuOTtGipb95GlP3eKD9 VL0d+KYCWP2FioU+0HTpRmu+7ao4H/JAwtxSdYtocJ9XrRyOH1UtuQOYa8uC5QUepFVj 5gZvG6dvlKhsJWpuul7dGLENK8xSy2JjGe0F+xoVwA0cVR/taP56iUxwwrcfIUvwFtnM DvWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AI0vxFWLuRgnzWT6ylhQhD0AdrQinrJeHY3w7Uhh0g8=; b=Goby4Bx8we4KLCrO92vHkg6XlSjCXU3hRjKm2yUa6Wt4bt8g3naKAPBWeRPqSmbaGu ij1SIBntRzQm66hHqPCsrNZ0K8Uqje3hmB0aajRGfS1I63I6TAeVRwd+Z36VxarBlLeJ RSWAmlmMY5SIldEL/PvdIxyOyXwvaNzlx/xeJ/aDeY0S4ZLRVe1ImgY5eoqRdGDXZlXc Pl6dEkD2CT+XtSSAN9ZE8cqNRkdpWzXtSoXjqZOWHo97VYj0a0WPVke+njfdM5dVuUHJ w2hRxC/wVt/9ACvyEwYuad3O1f6WHxG39UOKt6ZLX0enynxNMlLufFb2cPog0RG03Zwz izqQ== X-Gm-Message-State: AHQUAuaiEwO57luNq/Vxv1DWOAhjsrZTce2gR0Fm/QJfa4RZcOV5w/qo T9zQLghFID/hWXs40FZ3ErB4kw== X-Google-Smtp-Source: AHgI3IbqX799aYtadJ9H5rJ43BT7V/No+WEWTRtHyQaGle1ozhHIWCdnMmsH0XJCoRNlAMab1Q9ACQ== X-Received: by 2002:a2e:874b:: with SMTP id q11-v6mr1980029ljj.97.1549895485732; Mon, 11 Feb 2019 06:31:25 -0800 (PST) Received: from bsz-kubuntu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id z6sm2322373lfa.87.2019.02.11.06.31.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 06:31:25 -0800 (PST) From: bsz@semihalf.com To: linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com, ard.biesheuvel@linaro.org Cc: tweek@google.com, mingo@kernel.org, hdegoede@redhat.com, leif.lindholm@linaro.org, mw@semihalf.com, Bartosz Szczepanek Subject: [PATCH 1/5] tpm: Copy calc_tpm2_event_size() to TPM library Date: Mon, 11 Feb 2019 15:30:48 +0100 Message-Id: <20190211143052.3128-2-bsz@semihalf.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190211143052.3128-1-bsz@semihalf.com> References: <20190211143052.3128-1-bsz@semihalf.com> 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 From: Bartosz Szczepanek Function to calculate event size in TPM 2.0 log will also be needed in EFI stub. Separate it to library to make it accessible out of TPM character driver. It will be removed from tpm2.c in subsequent commit. Signed-off-by: Bartosz Szczepanek --- lib/tpm.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lib/tpm.c diff --git a/lib/tpm.c b/lib/tpm.c new file mode 100644 index 000000000000..aaeeafe52426 --- /dev/null +++ b/lib/tpm.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2016 IBM Corporation + * + * Parts of this file based on earlier work by: + * Nayna Jain + * Petr Vandrovec + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#include +#include +#include +#include + +/* + * calc_tpm2_event_size() - calculate the event size, where event + * is an entry in the TPM 2.0 event log. The event is of type Crypto + * Agile Log Entry Format as defined in TCG EFI Protocol Specification + * Family "2.0". + + * @event: event whose size is to be calculated. + * @event_header: the first event in the event log. + * + * Returns size of the event. If it is an invalid event, returns 0. + */ +int calc_tpm2_event_size(struct tcg_pcr_event2 *event, + struct tcg_pcr_event *event_header) +{ + struct tcg_efi_specid_event *efispecid; + struct tcg_event_field *event_field; + void *marker; + void *marker_start; + u32 halg_size; + size_t size; + u16 halg; + int i; + int j; + + marker = event; + marker_start = marker; + marker = marker + sizeof(event->pcr_idx) + sizeof(event->event_type) + + sizeof(event->count); + + efispecid = (struct tcg_efi_specid_event *)event_header->event; + + /* Check if event is malformed. */ + if (event->count > efispecid->num_algs) + return 0; + + for (i = 0; i < event->count; i++) { + halg_size = sizeof(event->digests[i].alg_id); + memcpy(&halg, marker, halg_size); + marker = marker + halg_size; + for (j = 0; j < efispecid->num_algs; j++) { + if (halg == efispecid->digest_sizes[j].alg_id) { + marker += + efispecid->digest_sizes[j].digest_size; + break; + } + } + /* Algorithm without known length. Such event is unparseable. */ + if (j == efispecid->num_algs) + return 0; + } + + event_field = (struct tcg_event_field *)marker; + marker = marker + sizeof(event_field->event_size) + + event_field->event_size; + size = marker - marker_start; + + if ((event->event_type == 0) && (event_field->event_size == 0)) + return 0; + + return size; +} +EXPORT_SYMBOL(calc_tpm2_event_size); From patchwork Mon Feb 11 14:30:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Szczepanek X-Patchwork-Id: 10806175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA0046C2 for ; Mon, 11 Feb 2019 16:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9C5E2A9B2 for ; Mon, 11 Feb 2019 16:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6CA42AC77; Mon, 11 Feb 2019 16:00:42 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 518522A9B2 for ; Mon, 11 Feb 2019 16:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730322AbfBKObd (ORCPT ); Mon, 11 Feb 2019 09:31:33 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:42079 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730316AbfBKObd (ORCPT ); Mon, 11 Feb 2019 09:31:33 -0500 Received: by mail-lf1-f67.google.com with SMTP id l10so7875061lfh.9 for ; Mon, 11 Feb 2019 06:31:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zdCd+eahJl+Jgx83sGQrXrCpsjO9ENXDoI/VLqO8N5s=; b=g0WkK0wADX8usdHfa0VcNaX+oFsXFAHJ7hqtjYsXRj13tO75890Yt7ke+hAf3zNhO4 qvpNKp8vZzVbGiWc6pNTDqZFddInSVwpzCPBjWZnRMKFwHfzQNDEEOFR5lCVyaY1Rk20 XB/9OiEbnok9nElviucOobsJrWqxiDRl2ylaMkTL26Qb6GSmrGjrlTgjj450XtF29Vi3 kbXv9UKnZrqWAU8bTnzoheeEJ/cjRj7UHK/5V7qBxH5yeEi1u6We0QjZGBWASReXZmEs 0bN8HQxhah2hDaYTbFRLmV8LZNBVHAhRC+wIA9QS67dlmCAjymW+8v83YyRPhhsluckM ojdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zdCd+eahJl+Jgx83sGQrXrCpsjO9ENXDoI/VLqO8N5s=; b=q5wKIawWwYG7lxWeKvOuERA5im7rMhgWmaMWyYzm8fkb/A4uxyjyhFlKGpEAoMt7D5 9PGVcVmQyHaVdIZmk9xYJALLMybDnsKXUTT536OuTpHfArEkcEYi6WqIlrRkM3dMD1Zj ARBDlRGq5pxPVjT6pjTTK0bprgSTUV3fsbqMfGAM4iX0OuAoH7kl1l3CgLh9JAnpSSaq 9H2ionVJOK4bNyFQ45QmzHqQORfzH7tXKUnrdpOplDB0EdqUxrdkSvc8aDSlIOAwybCS MgQ8rPuf8t5AHEd+/Q8pKd8OUo1wVv1BqhhslobhgiciUTRzQJ+Nkpvomjm8SdThrs+C UwLg== X-Gm-Message-State: AHQUAuYDRS6YwGjveIGsbcEywUmnibcSwmH/ZI3/7mKQcz3IIWOCD21M HSL3ef6dmyH9oX47kSQ4yjIBUQ== X-Google-Smtp-Source: AHgI3Ia/bzbAdHoVwbD8MW7fu5H495FVNVCwC6MPyee5idQwV9PqSGypBxhNikglHZ/R6FsZ8RUsuw== X-Received: by 2002:ac2:43b7:: with SMTP id t23mr1696969lfl.50.1549895491490; Mon, 11 Feb 2019 06:31:31 -0800 (PST) Received: from bsz-kubuntu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id z6sm2322373lfa.87.2019.02.11.06.31.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 06:31:31 -0800 (PST) From: bsz@semihalf.com To: linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com, ard.biesheuvel@linaro.org Cc: tweek@google.com, mingo@kernel.org, hdegoede@redhat.com, leif.lindholm@linaro.org, mw@semihalf.com, Bartosz Szczepanek Subject: [PATCH 2/5] tpm: Change calc_tpm2_event_size signature Date: Mon, 11 Feb 2019 15:30:49 +0100 Message-Id: <20190211143052.3128-3-bsz@semihalf.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190211143052.3128-1-bsz@semihalf.com> References: <20190211143052.3128-1-bsz@semihalf.com> 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 From: Bartosz Szczepanek Pass tcg_efi_specid_event as an argument instead of tcg_pcr_event, as the former is what is actually needed to compute event size. tcg_pcr_event structure describes TPM event log header (even though its name), from where efispecid can be extracted -- it seems cleaner and less misleading to do it out of calc_tpm2_event_size function. Also, use ssize_t instead of int for event log size. Signed-off-by: Bartosz Szczepanek --- lib/tpm.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/tpm.c b/lib/tpm.c index aaeeafe52426..263ccfdaefa5 100644 --- a/lib/tpm.c +++ b/lib/tpm.c @@ -15,6 +15,7 @@ #include #include #include +#include /* * calc_tpm2_event_size() - calculate the event size, where event @@ -23,19 +24,18 @@ * Family "2.0". * @event: event whose size is to be calculated. - * @event_header: the first event in the event log. + * @efispecid: pointer to structure describing algorithms used. * - * Returns size of the event. If it is an invalid event, returns 0. + * Returns size of the event. If it is an invalid event, returns -EINVAL. */ -int calc_tpm2_event_size(struct tcg_pcr_event2 *event, - struct tcg_pcr_event *event_header) +ssize_t calc_tpm2_event_size(struct tcg_pcr_event2 *event, + struct tcg_efi_specid_event *efispecid) { - struct tcg_efi_specid_event *efispecid; struct tcg_event_field *event_field; void *marker; void *marker_start; u32 halg_size; - size_t size; + ssize_t size; u16 halg; int i; int j; @@ -45,11 +45,9 @@ int calc_tpm2_event_size(struct tcg_pcr_event2 *event, marker = marker + sizeof(event->pcr_idx) + sizeof(event->event_type) + sizeof(event->count); - efispecid = (struct tcg_efi_specid_event *)event_header->event; - /* Check if event is malformed. */ if (event->count > efispecid->num_algs) - return 0; + return -EINVAL; for (i = 0; i < event->count; i++) { halg_size = sizeof(event->digests[i].alg_id); @@ -64,7 +62,7 @@ int calc_tpm2_event_size(struct tcg_pcr_event2 *event, } /* Algorithm without known length. Such event is unparseable. */ if (j == efispecid->num_algs) - return 0; + return -EINVAL; } event_field = (struct tcg_event_field *)marker; @@ -73,7 +71,7 @@ int calc_tpm2_event_size(struct tcg_pcr_event2 *event, size = marker - marker_start; if ((event->event_type == 0) && (event_field->event_size == 0)) - return 0; + return -EINVAL; return size; } From patchwork Mon Feb 11 14:30:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Szczepanek X-Patchwork-Id: 10805965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BA3213A4 for ; Mon, 11 Feb 2019 14:31:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A58C2A804 for ; Mon, 11 Feb 2019 14:31:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E5942A7F5; Mon, 11 Feb 2019 14:31:41 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 6C0F52A80D for ; Mon, 11 Feb 2019 14:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730325AbfBKObj (ORCPT ); Mon, 11 Feb 2019 09:31:39 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42086 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729613AbfBKObi (ORCPT ); Mon, 11 Feb 2019 09:31:38 -0500 Received: by mail-lf1-f65.google.com with SMTP id l10so7875244lfh.9 for ; Mon, 11 Feb 2019 06:31:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4mT+Uw4qv/27OkDGZ2Z4PNLv1X7pO+nJwrUwXygNfR4=; b=Ksoo+IaFbmKFle9VdM18OBfuhuq0AORuU9TMZhqnGG4BhuOcpzLfP39+nSSNz7guOj XUj4NweOocnRBgkvfUoJK0CMB9l4DHseIMOriF3dxaLxaJ/+iQRiPRIbsoxL6mcO8HCN vPmU884prGZIfUgXceoHizmjqzdssXSpY4R50ThjS33EhEcvzPDUgD1FYMeBqIgG2+eZ 0S2IfTSoAd86+Dv20Iqj+LOvwAT/FFAqaUxExdYsPFcfIqHCeI1IdBETTMMWaSb43ohW FUiCCNZV8GHyPxOVHkYJu8Gmfd1L2KIHdIwWpCLLuy2ILht2E7alJHc2LpUjgf2e9iQz LdwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4mT+Uw4qv/27OkDGZ2Z4PNLv1X7pO+nJwrUwXygNfR4=; b=s7MYM0A1mwVli7mRyoqutGWXbz9G6jMEFPYGNX1rXp7BeO+YsKIm883id4oOJRIMdp l5eaFgtfJkPO7ktdTUq09evON0virKtt3DSK347qYHHv4xduMI/qtoftpMJGI+KwxJz4 3x46l3Ti0r89S36CCM8zj308FdT8p2Dj27YGMKulQ2CDt9KJKwsNdBMfpW6ZlURhij6d YSGZmmp8AXw0WEqZ+hAReBQUCNeMWyszwUwIbF36uczlUpU70sAptGD7qGySFZyEVATS RKDoYpqMHZyDlxLbTbqrZHV+g4CuFUyhKWCSyfDACPT1D0Iwm5A6jSUJT53cMs2swpC/ Sa5g== X-Gm-Message-State: AHQUAubUDFnsNjYJzRqeAxNTeMtwwjRQs3m3DH37zRMdSEcYUTqfvpvq htXi/o12d4arDTD9GAMPP67RxQ== X-Google-Smtp-Source: AHgI3IaaYuqW+RAhaTPZ6ViRMxwgnwsPAunrxKxxCVBGSYpoOIexho4j8rBEhxeUbmll5qa8kaVNag== X-Received: by 2002:a19:59c2:: with SMTP id n185mr21587542lfb.118.1549895495351; Mon, 11 Feb 2019 06:31:35 -0800 (PST) Received: from bsz-kubuntu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id z6sm2322373lfa.87.2019.02.11.06.31.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 06:31:34 -0800 (PST) From: bsz@semihalf.com To: linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com, ard.biesheuvel@linaro.org Cc: tweek@google.com, mingo@kernel.org, hdegoede@redhat.com, leif.lindholm@linaro.org, mw@semihalf.com, Bartosz Szczepanek Subject: [PATCH 3/5] tpm: Use library version of calc_tpm2_event_size in sysfs code Date: Mon, 11 Feb 2019 15:30:50 +0100 Message-Id: <20190211143052.3128-4-bsz@semihalf.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190211143052.3128-1-bsz@semihalf.com> References: <20190211143052.3128-1-bsz@semihalf.com> 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 From: Bartosz Szczepanek Expect negative values from calc_tpm2_event_size as error codes. Pass efispecid instead of event header to calc_tpm2_event_size. Also, include tpm library in the build. Signed-off-by: Bartosz Szczepanek --- drivers/char/tpm/eventlog/tpm2.c | 89 ++++++++-------------------------------- include/linux/tpm_eventlog.h | 3 ++ lib/Makefile | 2 + 3 files changed, 22 insertions(+), 72 deletions(-) diff --git a/drivers/char/tpm/eventlog/tpm2.c b/drivers/char/tpm/eventlog/tpm2.c index 1b8fa9de2cac..5230821d5b1c 100644 --- a/drivers/char/tpm/eventlog/tpm2.c +++ b/drivers/char/tpm/eventlog/tpm2.c @@ -26,80 +26,20 @@ #include "../tpm.h" #include "common.h" -/* - * calc_tpm2_event_size() - calculate the event size, where event - * is an entry in the TPM 2.0 event log. The event is of type Crypto - * Agile Log Entry Format as defined in TCG EFI Protocol Specification - * Family "2.0". - - * @event: event whose size is to be calculated. - * @event_header: the first event in the event log. - * - * Returns size of the event. If it is an invalid event, returns 0. - */ -static int calc_tpm2_event_size(struct tcg_pcr_event2 *event, - struct tcg_pcr_event *event_header) -{ - struct tcg_efi_specid_event *efispecid; - struct tcg_event_field *event_field; - void *marker; - void *marker_start; - u32 halg_size; - size_t size; - u16 halg; - int i; - int j; - - marker = event; - marker_start = marker; - marker = marker + sizeof(event->pcr_idx) + sizeof(event->event_type) - + sizeof(event->count); - - efispecid = (struct tcg_efi_specid_event *)event_header->event; - - /* Check if event is malformed. */ - if (event->count > efispecid->num_algs) - return 0; - - for (i = 0; i < event->count; i++) { - halg_size = sizeof(event->digests[i].alg_id); - memcpy(&halg, marker, halg_size); - marker = marker + halg_size; - for (j = 0; j < efispecid->num_algs; j++) { - if (halg == efispecid->digest_sizes[j].alg_id) { - marker += - efispecid->digest_sizes[j].digest_size; - break; - } - } - /* Algorithm without known length. Such event is unparseable. */ - if (j == efispecid->num_algs) - return 0; - } - - event_field = (struct tcg_event_field *)marker; - marker = marker + sizeof(event_field->event_size) - + event_field->event_size; - size = marker - marker_start; - - if ((event->event_type == 0) && (event_field->event_size == 0)) - return 0; - - return size; -} - static void *tpm2_bios_measurements_start(struct seq_file *m, loff_t *pos) { struct tpm_chip *chip = m->private; struct tpm_bios_log *log = &chip->log; void *addr = log->bios_event_log; void *limit = log->bios_event_log_end; + struct tcg_efi_specid_event *efispecid; struct tcg_pcr_event *event_header; struct tcg_pcr_event2 *event; - size_t size; + ssize_t size; int i; event_header = addr; + efispecid = (struct tcg_efi_specid_event *) event_header->event; size = sizeof(struct tcg_pcr_event) - sizeof(event_header->event) + event_header->event_size; @@ -115,16 +55,16 @@ static void *tpm2_bios_measurements_start(struct seq_file *m, loff_t *pos) if (*pos > 0) { addr += size; event = addr; - size = calc_tpm2_event_size(event, event_header); - if ((addr + size >= limit) || (size == 0)) + size = calc_tpm2_event_size(event, efispecid); + if ((addr + size >= limit) || (size < 0)) return NULL; } for (i = 0; i < (*pos - 1); i++) { event = addr; - size = calc_tpm2_event_size(event, event_header); + size = calc_tpm2_event_size(event, efispecid); - if ((addr + size >= limit) || (size == 0)) + if ((addr + size >= limit) || (size < 0)) return NULL; addr += size; } @@ -135,6 +75,7 @@ static void *tpm2_bios_measurements_start(struct seq_file *m, loff_t *pos) static void *tpm2_bios_measurements_next(struct seq_file *m, void *v, loff_t *pos) { + struct tcg_efi_specid_event *efispecid; struct tcg_pcr_event *event_header; struct tcg_pcr_event2 *event; struct tpm_chip *chip = m->private; @@ -144,6 +85,7 @@ static void *tpm2_bios_measurements_next(struct seq_file *m, void *v, void *marker; event_header = log->bios_event_log; + efispecid = (struct tcg_efi_specid_event *) event_header->event; if (v == SEQ_START_TOKEN) { event_size = sizeof(struct tcg_pcr_event) - @@ -151,8 +93,8 @@ static void *tpm2_bios_measurements_next(struct seq_file *m, void *v, marker = event_header; } else { event = v; - event_size = calc_tpm2_event_size(event, event_header); - if (event_size == 0) + event_size = calc_tpm2_event_size(event, efispecid); + if (event_size < 0) return NULL; marker = event; } @@ -163,8 +105,8 @@ static void *tpm2_bios_measurements_next(struct seq_file *m, void *v, v = marker; event = v; - event_size = calc_tpm2_event_size(event, event_header); - if (((v + event_size) >= limit) || (event_size == 0)) + event_size = calc_tpm2_event_size(event, efispecid); + if (((v + event_size) >= limit) || (event_size < 0)) return NULL; (*pos)++; @@ -180,10 +122,13 @@ static int tpm2_binary_bios_measurements_show(struct seq_file *m, void *v) struct tpm_chip *chip = m->private; struct tpm_bios_log *log = &chip->log; struct tcg_pcr_event *event_header = log->bios_event_log; + struct tcg_efi_specid_event *efispecid; struct tcg_pcr_event2 *event = v; void *temp_ptr; size_t size; + efispecid = (struct tcg_efi_specid_event *) event_header->event; + if (v == SEQ_START_TOKEN) { size = sizeof(struct tcg_pcr_event) - sizeof(event_header->event) + event_header->event_size; @@ -193,7 +138,7 @@ static int tpm2_binary_bios_measurements_show(struct seq_file *m, void *v) if (size > 0) seq_write(m, temp_ptr, size); } else { - size = calc_tpm2_event_size(event, event_header); + size = calc_tpm2_event_size(event, efispecid); temp_ptr = event; if (size > 0) seq_write(m, temp_ptr, size); diff --git a/include/linux/tpm_eventlog.h b/include/linux/tpm_eventlog.h index 20d9da77fc11..872ab1545456 100644 --- a/include/linux/tpm_eventlog.h +++ b/include/linux/tpm_eventlog.h @@ -121,4 +121,7 @@ struct tcg_pcr_event2 { struct tcg_event_field event; } __packed; +ssize_t calc_tpm2_event_size(struct tcg_pcr_event2 *event, + struct tcg_efi_specid_event *efispecid); + #endif diff --git a/lib/Makefile b/lib/Makefile index e1b59da71418..4458d914f40b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -276,3 +276,5 @@ obj-$(CONFIG_GENERIC_LIB_MULDI3) += muldi3.o obj-$(CONFIG_GENERIC_LIB_CMPDI2) += cmpdi2.o obj-$(CONFIG_GENERIC_LIB_UCMPDI2) += ucmpdi2.o obj-$(CONFIG_OBJAGG) += objagg.o + +obj-$(CONFIG_TCG_TPM) += tpm.o From patchwork Mon Feb 11 14:30:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Szczepanek X-Patchwork-Id: 10806173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7A086C2 for ; Mon, 11 Feb 2019 16:00:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C72A62AB4B for ; Mon, 11 Feb 2019 16:00:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C592D2ABF7; Mon, 11 Feb 2019 16:00:22 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 2918C2ABE4 for ; Mon, 11 Feb 2019 16:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728697AbfBKQAP (ORCPT ); Mon, 11 Feb 2019 11:00:15 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:43969 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730350AbfBKObo (ORCPT ); Mon, 11 Feb 2019 09:31:44 -0500 Received: by mail-lj1-f195.google.com with SMTP id o1-v6so3087632ljc.10 for ; Mon, 11 Feb 2019 06:31:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ln6fM3szTzWlr7YX/AOAutoZxJqo4vzjmHWgjbDG09Q=; b=mxJwbMP9AE6Z6Xp7QcJsYtNs7m7uIBdHTmLfyahLu/gVBKQOVWIeUJA53gs5y+8KMX 6ClTgjljC9bCDzHAu8FHU/HwDzCQ5uC8gSrusVFvywOEuwONj7YJi5uO4e0kT7pOA2Cl hrJIrgW5pM7aBoX88phdDCsZz+UDUpMe4TD7W2RVOhEtvSsKxDtgjgIGXyzoYkshghGf DZJT093lT9NiUEp9zkMnnaICXKLp6wUbZz4QTyDt+4QOKOMu/GgeePuVivgYcNFn2UXP h6suGnqUvWm+tSl3KsnCzBLB+D+eCIn/JYirLMmVA/K0P+xewGAeG3GitDVw1Yzg/Zof YAsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ln6fM3szTzWlr7YX/AOAutoZxJqo4vzjmHWgjbDG09Q=; b=ILfBwfM3+vWHZMSeIYdwcXLDwp/uwdC6R0EsSURh+5s2rSYl7uVgeg3BdDgZkp/32t ADl5qeyIOpigcvDXHHG9EtKmSZ1vW3pzxN6m7QHcZDR5Ovg8o696l5RFR09wr0HJnDS+ XHhj9fbJliPYip5cqi5Y6WcRuOe265jOcJ9p0X4BLRYQ9kCXaHbs6/BUcUk7zYB6n4A4 hEEWitF4M41JjiQX3Z22NYrSQaY5lnMXaWsAGsxEUuVjCax5jQvwRtK8n6+g9M36Sg8E euwpa+ePO1cPhJW7g1dwrCJsfe6vHg/VXpJoAEPstZl/dyChqYNxGFdkybXCP6eSX+4b UZ8Q== X-Gm-Message-State: AHQUAuZMQkoyGBZko1TYH1XD/sGGIQ0lGc556o3dsO5DXYtTxsjfybfp qQj+bbPyLEDRMC5zOENjd5v/5w== X-Google-Smtp-Source: AHgI3IbmPwTbEcsSKY4UjyIhXnteVk4oYnCvmlgsENltt+kNY1l4LZq8SWX4uOYolHBw++8lZm7VFQ== X-Received: by 2002:a2e:99d4:: with SMTP id l20-v6mr4713090ljj.142.1549895501475; Mon, 11 Feb 2019 06:31:41 -0800 (PST) Received: from bsz-kubuntu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id z6sm2322373lfa.87.2019.02.11.06.31.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 06:31:40 -0800 (PST) From: bsz@semihalf.com To: linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com, ard.biesheuvel@linaro.org Cc: tweek@google.com, mingo@kernel.org, hdegoede@redhat.com, leif.lindholm@linaro.org, mw@semihalf.com, Bartosz Szczepanek Subject: [PATCH 4/5] efi/libstub/tpm: Retrieve TPM event log in 2.0 format Date: Mon, 11 Feb 2019 15:30:51 +0100 Message-Id: <20190211143052.3128-5-bsz@semihalf.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190211143052.3128-1-bsz@semihalf.com> References: <20190211143052.3128-1-bsz@semihalf.com> 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 From: Bartosz Szczepanek Currently, the only way to get TPM 2.0 event log from firmware is to use device tree. Introduce efi_retrieve_tpm2_eventlog_2 function to enable retrieving it from EFI structures. Include lib/tpm.c into EFI stub to calculate event sizes using helper function. Signed-off-by: Bartosz Szczepanek --- drivers/firmware/efi/libstub/Makefile | 3 +- drivers/firmware/efi/libstub/tpm.c | 107 +++++++++++++++++++++++++++++++++- 2 files changed, 107 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index d9845099635e..0d7d66ad916d 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -38,7 +38,8 @@ OBJECT_FILES_NON_STANDARD := y # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n -lib-y := efi-stub-helper.o gop.o secureboot.o tpm.o +lib-y := efi-stub-helper.o gop.o secureboot.o tpm.o \ + lib-tpm.o # include the stub's generic dependencies from lib/ when building for ARM/arm64 arm-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c index a90b0b8fc69a..c8c2531be413 100644 --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -129,8 +129,111 @@ static void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg) efi_call_early(free_pool, log_tbl); } +static efi_status_t +efi_calc_tpm2_eventlog_2_size(efi_system_table_t *sys_table_arg, + void *log, void *last_entry, ssize_t *log_size) +{ + struct tcg_pcr_event2 *event = last_entry; + struct tcg_efi_specid_event *efispecid; + struct tcg_pcr_event *log_header = log; + ssize_t last_entry_size; + + efispecid = (struct tcg_efi_specid_event *) log_header->event; + + if (last_entry == NULL || log_size == NULL) + return EFI_INVALID_PARAMETER; + + if (log == last_entry) { + /* + * Only one entry (header) in the log. + */ + *log_size = log_header->event_size + + sizeof(struct tcg_pcr_event); + return EFI_SUCCESS; + } + + if (event->count > efispecid->num_algs) { + efi_printk(sys_table_arg, + "TCG2 event uses more algorithms than defined\n"); + return EFI_INVALID_PARAMETER; + } + + last_entry_size = calc_tpm2_event_size(last_entry, efispecid); + if (last_entry_size < 0) { + efi_printk(sys_table_arg, + "TCG2 log has invalid last entry size\n"); + return EFI_INVALID_PARAMETER; + } + + *log_size = last_entry + last_entry_size - log; + return EFI_SUCCESS; +} + +static efi_status_t efi_retrieve_tpm2_eventlog_2(efi_system_table_t *sys_table_arg) +{ + efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID; + efi_physical_addr_t log_location = 0, log_last_entry = 0; + efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID; + efi_bool_t truncated; + efi_status_t status; + struct linux_efi_tpm_eventlog *log_tbl = NULL; + void *tcg2_protocol = NULL; + ssize_t log_size; + + status = efi_call_early(locate_protocol, &tcg2_guid, NULL, + &tcg2_protocol); + if (status != EFI_SUCCESS) + return status; + + status = efi_call_proto(efi_tcg2_protocol, get_event_log, tcg2_protocol, + EFI_TCG2_EVENT_LOG_FORMAT_TCG_2, + &log_location, &log_last_entry, &truncated); + if (status != EFI_SUCCESS) + return status; + + if (!log_location) + return EFI_NOT_FOUND; + + status = efi_calc_tpm2_eventlog_2_size(sys_table_arg, + (void *)log_location, + (void *) log_last_entry, + &log_size); + if (status != EFI_SUCCESS) + return status; + + /* 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 status; + } + + memset(log_tbl, 0, sizeof(*log_tbl) + log_size); + log_tbl->size = log_size; + log_tbl->version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2; + memcpy(log_tbl->log, (void *) log_location, log_size); + + status = efi_call_early(install_configuration_table, + &linux_eventlog_guid, log_tbl); + if (status != EFI_SUCCESS) + goto err_free; + + return EFI_SUCCESS; + +err_free: + efi_call_early(free_pool, log_tbl); + return status; +} + void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg) { - /* Only try to retrieve the logs in 1.2 format. */ - efi_retrieve_tpm2_eventlog_1_2(sys_table_arg); + efi_status_t status; + + status = efi_retrieve_tpm2_eventlog_2(sys_table_arg); + if (status != EFI_SUCCESS) + efi_retrieve_tpm2_eventlog_1_2(sys_table_arg); } From patchwork Mon Feb 11 14:30:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Szczepanek X-Patchwork-Id: 10806171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 262C36C2 for ; Mon, 11 Feb 2019 16:00:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1236B2ABB3 for ; Mon, 11 Feb 2019 16:00:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 101512ABF0; Mon, 11 Feb 2019 16:00:09 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 A443D2ABB3 for ; Mon, 11 Feb 2019 16:00:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729806AbfBKQAI (ORCPT ); Mon, 11 Feb 2019 11:00:08 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40197 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730025AbfBKObq (ORCPT ); Mon, 11 Feb 2019 09:31:46 -0500 Received: by mail-lj1-f194.google.com with SMTP id z25-v6so8915994ljk.7 for ; Mon, 11 Feb 2019 06:31:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qMY2b0yuZLADsWMepCfTCrgliMG6UcFslUIJuZiM5zw=; b=OVyUnpsa/Oq8rmPDNntBJeRK5hj15KI+IQQ0FUvMSYPbHOvBKI/YFoppyZkxRdSu35 vvbWjzz9RanSA0vEl+I+i8a+7uoq00eZW0I21a5Mn+2Ukjx1gmjj0RWk2mckxDOgIVUQ hpaIgtvUvNB+Zp6fE0chytLBaClSVXQurLeYtt6Iq2Iukvjl9LJAM8p9srP8WzByDm3s 2RVbSunurGHxJChx0HqBPWxvWz+IvEXFgrLl0vRqesoN9MXv3zivwOw+Os4XGGZ/TJFV 1snaS62I6FVmMjPZrOyB7Dqow26Ey90i6pZAa1YwSZU1y4abgNLfAdvtXEMfVhk3zl31 pdcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qMY2b0yuZLADsWMepCfTCrgliMG6UcFslUIJuZiM5zw=; b=OE2/Rqz6Xd1XFtSDVgUA4Y8dTeKcLGfE7Q7cXMEKwZ95mpOjuyQBmqCUsYjeQSbA4Z I0b61WPoQNJW52kVpxl3jBGoepGQwyvkhu1X3DESQLbKNTVDTrQGEsqqUnOgQ8VerIUC sD1IdMEY1Ple0nq2/2awAuOwQs2m/FvSPRPadSf2+dkLusZNWAHa84yVwZXbw5xJvkz+ IVpllVS1tpo2nf0vnTlc6Ot89o0BiSMU6tJHL7JR+xV6a/TICAgzjCoJv5NF0lI+kzpM irLJZplv8Mv2CInjqF+0xdUC6aDb3qxb/DRFZ5eb1YMQ8gbiY/yX1Lf893W3mDFes+Tw NhpA== X-Gm-Message-State: AHQUAuZ6i9Buc5drvGUbTTz+dveEFKznMwWtJEM1P6AhCEY144g2sLjl EayfbTjeyrDMgrO8+OqdkSkPbg== X-Google-Smtp-Source: AHgI3Ia5ScBEaXINb/FbxiIJo7geXhDMU8sTzu85n2SzKfpxAwQjwSfmMdodwFHXuCfkU93bmG13lA== X-Received: by 2002:a2e:9249:: with SMTP id v9-v6mr4775498ljg.164.1549895504147; Mon, 11 Feb 2019 06:31:44 -0800 (PST) Received: from bsz-kubuntu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id z6sm2322373lfa.87.2019.02.11.06.31.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 06:31:43 -0800 (PST) From: bsz@semihalf.com To: linux-efi@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com, ard.biesheuvel@linaro.org Cc: tweek@google.com, mingo@kernel.org, hdegoede@redhat.com, leif.lindholm@linaro.org, mw@semihalf.com, Bartosz Szczepanek Subject: [PATCH 5/5] efi/arm: Retrieve TPM event log at efi_entry Date: Mon, 11 Feb 2019 15:30:52 +0100 Message-Id: <20190211143052.3128-6-bsz@semihalf.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190211143052.3128-1-bsz@semihalf.com> References: <20190211143052.3128-1-bsz@semihalf.com> 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 From: Bartosz Szczepanek Add efi_retrieve_tpm2_eventlog() call to ARM efi_entry() function. There's no reason to assume that TPM2 EFI structures are not available on ARM architecture. Signed-off-by: Bartosz Szczepanek --- drivers/firmware/efi/libstub/arm-stub.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index eee42d5e25ee..d3af12ec32e4 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c @@ -197,6 +197,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table, /* Ask the firmware to clear memory on unclean shutdown */ efi_enable_reset_attack_mitigation(sys_table); + efi_retrieve_tpm2_eventlog(sys_table); secure_boot = efi_get_secureboot(sys_table);