From patchwork Fri Dec 3 03:58:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 520181 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp340275imb; Thu, 2 Dec 2021 19:55:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMmnpiHYp1lJwIBKcc8FTtniPGKx46Sc4SPULhzyekDffip+S1OSG1hhTeeyk5DHYEZUdM X-Received: by 2002:aa7:df9a:: with SMTP id b26mr22603415edy.107.1638503712527; Thu, 02 Dec 2021 19:55:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638503712; cv=none; d=google.com; s=arc-20160816; b=kCy3+OiYxCx4XnA/SHe0nN4ayV/yyEIpl6kyuwcOSsfupx5JGfSkrvmpMPtmatmpN+ +4VdVu1t+5Nt7HjeV/dERbGQTfQgVCFM5UP1PMdXmEBA6Ga8/zlcYjMLxlHAnv9suD71 L09YqWv1BZHX5khHs3BVlqLGgeQDLaqo5XTh7gLpJ/FkYL5rKAMvCZCROvHquGtYdO1f tPPTIZd7Kp7oINDX+63G0kqdxc5Cg9GCxJduk/jen0vcAvz0PGu6wXjCNTwrqz5hmARM 9+4g0zxum9P/q4vHurtUUnejCc42tD+5VdhryQeHb1oz3lmjeXMLoAB0Hj1KRyQ77cym KGxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=PjeEgqGuWSuhB/+vrig2LM1FErcEwda+t2mT9RS4me8=; b=vTYUVZRTkC1Rua1ynwN7VWi7gQ/vpAgTgPzR2Vv7BhTPVF0StXTsxdNntBLbVsc3Vg NeDBev6mLR3YwfaqDGeH2jXNyJmF0G9ogs+D7XzBzyQs1QwGGRyoKICiGjVfTEv/sdHf jDscIOnZv5ksgYB+aMSZUigtg6/nLZllDx4vzWtcqLDl0Yof/95vxBjr6v5ssgEjnW7x 8M25fEpGXyBjduZT8Zhx2oFG/tWLjZW++si/Pm3A2O3yn7nzSf0Yg58gmS9poH+x/DTU 8m+acCoEiJ+NOGL3hKza5lQVVnO/DAnupvWxxJkk5rRV+snE3lifSKYblsOzDaR1q9SN Y6xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="OVq/lr4r"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a8si2794234edy.288.2021.12.02.19.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 19:55:12 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="OVq/lr4r"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3BDC581435; Fri, 3 Dec 2021 04:54:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="OVq/lr4r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E6A2E80605; Fri, 3 Dec 2021 04:54:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3291F80605 for ; Fri, 3 Dec 2021 04:54:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pg1-x530.google.com with SMTP id f125so1830273pgc.0 for ; Thu, 02 Dec 2021 19:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PjeEgqGuWSuhB/+vrig2LM1FErcEwda+t2mT9RS4me8=; b=OVq/lr4ruEC3KG0sDPtr6g6pKFMPkl97eQMtPuKUi3nmgS1RNGCDMuB9n6Jg8Y16S8 syJ34RUYPQTmCENvT/D4TcGhus0/Dj5nnOXNxKWix9rsyI68PdeGKH5q7deNercjRim6 msldKCZtHzLudGl8fr6rx26NwFHvgX/wNYhLaLVY8m8qtGMTECz5TMpj4ManOKOCH9Se ItYUrdnFv1fKHMTrH/EIM2X8YF50/qQwB3vYEm3N81qb5lfaRtFVZ5DMC5GjtPjsx7T+ Kqw6V2nNLqgV5OpP64ULB1/Jk3gJnNC3OVPyAETvdAAxOsNT2okofLJDi3mRRYutUvfc rOxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PjeEgqGuWSuhB/+vrig2LM1FErcEwda+t2mT9RS4me8=; b=wIVKDAqSVIxYbzgmkfsW3qnWaUb6fgjQ6HruaFZ1F9UFmtTZ3B7qDTZv1t2rPmfcFg Y+g4aeoMMVHfjSzyMsWlZIlQ5xl574avaF7k8yPbNtb4csPShiEM23CwSsVcrnYnOItd jm7+TiYNVQvQKibbzJt0NRnKu6hlW9LcREObFLtbj1tSSfB9RTcc4YF518PsiCcRsc7l VTAM6j9AwWv+3FhDZ/428ejEZtILCnG0C48wq85M0KK2qd/8yVl0hd46BNz/D3WDfn4b yYg7a0RXc+c7nLCchzwc2r40GFaND76uhkHe4jrxgU+kT5NFpI6wModWI9gKuvIupDlJ pLYA== X-Gm-Message-State: AOAM533qziGiTUB09D1ie4c9sXGEEU4siF1N0EtYc8jQxNW/aWHrGpAP fDgtSwtFjDAZkcoZ6NVzEG7pmWfAqOQiHw== X-Received: by 2002:a63:903:: with SMTP id 3mr2691929pgj.356.1638503683704; Thu, 02 Dec 2021 19:54:43 -0800 (PST) Received: from localhost.localdomain ([2400:2411:502:a100:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id y32sm1301334pfa.145.2021.12.02.19.54.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 19:54:43 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Masahisa Kojima , Alexander Graf Subject: [PATCH 2/3] efi_loader: check tcg2 protocol installation outside the TCG protocol Date: Fri, 3 Dec 2021 12:58:14 +0900 Message-Id: <20211203035815.27433-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211203035815.27433-1-masahisa.kojima@linaro.org> References: <20211203035815.27433-1-masahisa.kojima@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean There are functions that calls tcg2_agile_log_append() outside of the TCG protocol invocation (e.g tcg2_measure_pe_image). These functions must to check that TCG2 protocol is installed. If not, measurement shall be skipped. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- lib/efi_loader/efi_tcg2.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 6dbdd35f29..2b7b7cbbae 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -972,6 +972,9 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size, IMAGE_NT_HEADERS32 *nt; struct efi_handler *handler; + if (!is_tcg2_protocol_installed()) + return EFI_SUCCESS; + ret = platform_get_tpm2_device(&dev); if (ret != EFI_SUCCESS) return ret; @@ -2189,6 +2192,9 @@ efi_status_t efi_tcg2_measure_efi_app_invocation(struct efi_loaded_image_obj *ha u32 event = 0; struct smbios_entry *entry; + if (!is_tcg2_protocol_installed()) + return EFI_SUCCESS; + if (tcg2_efi_app_invoked) return EFI_SUCCESS; @@ -2239,6 +2245,9 @@ efi_status_t efi_tcg2_measure_efi_app_exit(void) efi_status_t ret; struct udevice *dev; + if (!is_tcg2_protocol_installed()) + return EFI_SUCCESS; + ret = platform_get_tpm2_device(&dev); if (ret != EFI_SUCCESS) return ret; @@ -2264,6 +2273,12 @@ efi_tcg2_notify_exit_boot_services(struct efi_event *event, void *context) EFI_ENTRY("%p, %p", event, context); event_log.ebs_called = true; + + if (!is_tcg2_protocol_installed()) { + ret = EFI_SUCCESS; + goto out; + } + ret = platform_get_tpm2_device(&dev); if (ret != EFI_SUCCESS) goto out; @@ -2293,6 +2308,9 @@ efi_status_t efi_tcg2_notify_exit_boot_services_failed(void) struct udevice *dev; efi_status_t ret; + if (!is_tcg2_protocol_installed()) + return EFI_SUCCESS; + ret = platform_get_tpm2_device(&dev); if (ret != EFI_SUCCESS) goto out;