From patchwork Tue Dec 7 05:15:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 521617 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp5711421imb; Mon, 6 Dec 2021 21:11:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbwlgzKo8zrl6vykX4p0EfSd2JgO0bZbUhyV5iP/87w1jkRzmqoezkFdln/nb8JTwjs4AE X-Received: by 2002:a50:e0c4:: with SMTP id j4mr5599724edl.239.1638853894013; Mon, 06 Dec 2021 21:11:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638853894; cv=none; d=google.com; s=arc-20160816; b=GEzLO/EgB/AROf4UOalq3Aq7ieQ1uD0jNG/ov+LsYPfkb2VAA1uIRiSC/ViF/b02tF BgnYmLqQttisDPSvYvLC4Cy24sE/lAu9j+aSxWnDvwTx4wCrytDeuC7++GkyPegURsTI Q2wFuhFeXCdnc1Wjg8JzMxcxMq+hu1Dje6N+d04L4eyOvLJO2XCJoWohduikT5/dVXF4 Gw1dRLxQhSpC/ZVcLER3V8KgVXFUpKnTb8iDKsyD/uQ/2+rnVD/DETuC8NOy2Qd5kpYS Xi3OFiSOyvPkzx2PUtRhH6leVvYMXrAEz6GmB8cPVCkKTfPL1Zr5YmCwHfepTo1sBYVS o+Nw== 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=2zBP+B0gjXmBLFHI97p4G8as/h1mPry1Kf6nmtw8DjE=; b=FvWWo4kcoA8zylLJR4jOL0SQpvU6/YOOM1soXGUCoRBg7dolmq0wlRqwjmW0kkHCgg peNxvtynvVpWhLodWSUF53Jn7OTTlNIYFi1Fp6QNV6HEG33KSzELJUuPjZk66jjLT/gs Ptv+TtWHoBSrVmR5kTuf4UEBiTBDaxyx0cKp1R7VQdxWtwC10ovXz9pg41BADeDYw+r5 xyo5PaWiVrf38X2adOnHstkuyhEmbt/N62mdjcIMWT+ErGZ2iO9JybGKh0mm7/TMu0qR rdB7U7i0EzVTEbggQaykgBcfuQwWzShyZ1gbgGbqdecNEp6ZTKCsz4nOoEDIhd/Sgtor X94g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="M0hnMl/6"; 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 nc41si26299203ejc.520.2021.12.06.21.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 21:11:34 -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="M0hnMl/6"; 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 B62D5833E3; Tue, 7 Dec 2021 06:11:25 +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="M0hnMl/6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9E881833C3; Tue, 7 Dec 2021 06:11:20 +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-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) (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 A3FBA83084 for ; Tue, 7 Dec 2021 06:11:15 +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-pl1-x636.google.com with SMTP id b11so8582752pld.12 for ; Mon, 06 Dec 2021 21:11:15 -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=2zBP+B0gjXmBLFHI97p4G8as/h1mPry1Kf6nmtw8DjE=; b=M0hnMl/6HBn0jGOsOiJD64PKjSh790zmxtyOH2Q77YK0QHmKWkxTq39M7g1gX05yZR VkXemtJBWmtu5LMPU3326IMG2FBxx6JWy5mHiVMHRdLu16LlfJnWMrvnVBU4LbUkL/Ar 64T4OwcQzRAOs5kUsNX3N/MHM2SR6M6jCC8o0yKsNi/G3PupgJA2WUPD6oDK0Mwd8fNb /QQvIN5xPaob4kSyrZYGuv6IoRvWl1FkuQohxxzJYxQuPpU5JoPBnSwQupbYN8FhrN/9 qLnWVjdeT3gGyLkGqERtdrjivqMV0jYwEf4Wh/G2eQYGFcivAGXDvJxrtjabp2IAPVvf mCEw== 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=2zBP+B0gjXmBLFHI97p4G8as/h1mPry1Kf6nmtw8DjE=; b=bpbBW+XmxwwRZaCHDYxA1X+OAXlLJyyEc19p6hBhfC/TNWcVy+FI/jt8ewmRD00Zbv rUlPBMTxfdjnH66dhrWxRLsRlJuevzKG2wtf53ZwWiFlXLl95gMVPleBp8Q5OIPMDHMp KFwyW7a6JTmoA2AGJCZpYNIc6OGgoMA6evmjvr/tMSzfeR4lC/1ReO+mu9RbQxiyCP1w Zui7eryqyXZvT+D7A7ybcJADogIkLu3BhIiwX3lHQrC5I/rMOBcIZ/4wFqcp0ULwXVPc 3qSCLGX6OcLPX8MO7K1LEY95gaqMEhwVnULroH4sTb73LFFwdl1jHb9lfdyx5sRkRGyt WqHg== X-Gm-Message-State: AOAM533/uXeVxNahINziDvd+fzBPjhY6Pjfzmmed9zkwHa/cC4IIWMuj WjtOVGF69AnDK2P76uY3Hj66IPFel3deBQ== X-Received: by 2002:a17:90b:97:: with SMTP id bb23mr3883718pjb.201.1638853874152; Mon, 06 Dec 2021 21:11:14 -0800 (PST) Received: from localhost.localdomain ([2400:2411:502:a100:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id q10sm11975516pfk.180.2021.12.06.21.11.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 21:11:13 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Masahisa Kojima , Alexander Graf Subject: [PATCH v2 2/3] efi_loader: check tcg2 protocol installation outside the TCG protocol Date: Tue, 7 Dec 2021 14:15:32 +0900 Message-Id: <20211207051533.5597-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211207051533.5597-1-masahisa.kojima@linaro.org> References: <20211207051533.5597-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 --- No update since v1 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 bdfd9a37b5..59bce85028 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;