From patchwork Fri Sep 3 01:55:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 506467 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp594497jai; Thu, 2 Sep 2021 18:54:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMn1krZAHuH/KifJhUbgN0A03RXz6mSJI4wqNLwtdY0IWjAsAYUqUWAg5+dOFrfefSOlRv X-Received: by 2002:a17:906:e88:: with SMTP id p8mr1313189ejf.103.1630634093668; Thu, 02 Sep 2021 18:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630634093; cv=none; d=google.com; s=arc-20160816; b=ZO9HDwCRD8UeoHRsM/r8yAcvfZU8Jz493bnIuNhRgiz1Ne3fUpZ8xUKNpoFOkr91FH Falb0ZncWVbIQfdegJQxRCsC7dtJPdnLW46bMO4vw6/bA8ymApNvxKtvnXn4qAk5tgP3 Il+FH1OEukgv9p8vMkBlLcyqLwb5HIMf9UPALtMJiR5IC1qMmFzcWa2qV71CZejmDmu0 g3lVzlczweAeZKU1VS/+n3lQs7R2tcXcNF6ehM2PcfXnxojnwOsKiGXjgHN/VnZUw+8r kUCFvWEpkTN6ijd6CJTcbNMStXFntZJzWrMwwrNC19LLY98E7qN7Z52WN9dPsygD8Bpc G7Rg== 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:to:from:dkim-signature; bh=/sL6paaxDvmhePTPatoUwetXffPc4WRPBeRMw5NP3qI=; b=qtSfrdrrpZ5xsDQ0GntVZ9Frgw15luDFOFQ2iBT242AwwLNpooGXeUjEPbYP/Hku/c MZHbu5jXAN4y6RGSIFZ123cadmEbJcL+hPGPlThK2cJhhWO337FS6B60YpnnADsmMWQS KwMmkX4yfYV3T1wcNOAfMIeowJD1FCTTg+5818Pb84fUnWUFg1wBvPaXFap+8EilL+Xp D/RN6HPZDLlZzmB2BKD5WBpB8YudFsHB7xH/EqTS+1z3txjQAAjJRIevoVxoIygfb8SB 9Osl9BzZbwQlBRXXhBkTEyinLoNs3eezhGKSW7Mq1VTIOSJSqp0Y1gF9gsHw2gt1zMxd aZMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n8ZikKdR; 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 cw8si3703375edb.355.2021.09.02.18.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 18:54:53 -0700 (PDT) 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=n8ZikKdR; 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 047E183520; Fri, 3 Sep 2021 03:54:29 +0200 (CEST) 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="n8ZikKdR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C17DD800AA; Fri, 3 Sep 2021 03:54:20 +0200 (CEST) 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-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (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 CCCA4834F6 for ; Fri, 3 Sep 2021 03:54:14 +0200 (CEST) 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-pf1-x42a.google.com with SMTP id 7so3080067pfl.10 for ; Thu, 02 Sep 2021 18:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=/sL6paaxDvmhePTPatoUwetXffPc4WRPBeRMw5NP3qI=; b=n8ZikKdRsR7YtOaMXOD5yzcWOGDcJUfgU3qnPK/CEs7s9UrtQQb8KkTO2mYWGLq3NR /lFlS82oaIIAio90LzLVcI1uinDNMhJWhhIXj/gH5lsQPQ4TwI8zDctnz/tvAT7kYzTn AnVwaz926iw6xCMxaXQea5O0fbcJ2cs0a5ChUzZ0tAE3pfiy8vdEyXcfylKfVG03MkB4 GwphJsJlw/Y52AJiosP2B9R0gv9bKs3Awytn2MZ5cuR4HtoBstTnw8BleL8B3ABXKfUs BRIC8pKpzThveYJ8Du+89VEaokAZUbAiZlwZAugkl9s5iAEbLbiwJIsrfV35EMw/Hg3l hMSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=/sL6paaxDvmhePTPatoUwetXffPc4WRPBeRMw5NP3qI=; b=lk1ZSv4tfgXKPpGk6VR3h4Z5qiMLOCSdkXwRR+ljWJqgzpJLn+SW3KvBKusVQ1pX7S zUweVmTAYnO3KmilEmhqcWd0Stc8+czH1LxCdOiJ19kgX2rxiS6rHp5jlTDaQ0rs7jcn Qtm3Dms8x+a4HL7++tER6jAQDREu8RIQTpbYy6+kJMlP0QHZwMV5AghvMjzuYa6+tGVi Vikc1+ystyqin02X+tjOOp9jlDieZDyKYjCUv8K54QHaR74GYFPS5BCEHtTY7F3cblfw 3d2Qr++NFYvzVi00fH5MxLLhg55BP++Ys/1NJeqwz3idql4DRLtMxk9Z0BRlBW6FswRQ SNnw== X-Gm-Message-State: AOAM530eZcDctf5NRITWZ1Xsw+/T73FiZI1lk9xRr3Q69mytIt6f/zvi mXDkPh0SVK91BY9Jh0DbQJNCAw== X-Received: by 2002:a63:1e4e:: with SMTP id p14mr1263272pgm.261.1630634053063; Thu, 02 Sep 2021 18:54:13 -0700 (PDT) Received: from localhost.localdomain ([2400:2411:502:a100:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id g37sm4182198pgl.94.2021.09.02.18.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 18:54:12 -0700 (PDT) From: Masahisa Kojima To: Heinrich Schuchardt , Alexander Graf , Ilias Apalodimas , Simon Glass , AKASHI Takahiro , u-boot@lists.denx.de Subject: [PATCH 3/3] efi_loader: fix efi_tcg2_hash_log_extend_event() parameter check Date: Fri, 3 Sep 2021 10:55:52 +0900 Message-Id: <20210903015552.17180-4-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210903015552.17180-1-masahisa.kojima@linaro.org> References: <20210903015552.17180-1-masahisa.kojima@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 TCG EFI Protocol Specification defines that PCRIndex parameter passed from caller must be 0 to 23. TPM2_MAX_PCRS is currently used to check the range of PCRIndex, but TPM2_MAX_PCRS is tpm2 device dependent and may have larger value. This commit newly adds EFI_TCG2_MAX_PCR_INDEX macro, it is used to check the range of PCRIndex parameter. Signed-off-by: Masahisa Kojima --- include/efi_tcg2.h | 2 ++ lib/efi_loader/efi_tcg2.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Ilias Apalodimas Acked-by: Heinrich Schuchardt diff --git a/include/efi_tcg2.h b/include/efi_tcg2.h index 45788d55d5..b647361d44 100644 --- a/include/efi_tcg2.h +++ b/include/efi_tcg2.h @@ -28,6 +28,8 @@ #define EFI_TCG2_EXTEND_ONLY 0x0000000000000001 #define PE_COFF_IMAGE 0x0000000000000010 +#define EFI_TCG2_MAX_PCR_INDEX 23 + /* Algorithm Registry */ #define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001 #define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002 diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index c4e9f61fd6..b268a02976 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -958,7 +958,7 @@ efi_tcg2_hash_log_extend_event(struct efi_tcg2_protocol *this, u64 flags, goto out; } - if (efi_tcg_event->header.pcr_index > TPM2_MAX_PCRS) { + if (efi_tcg_event->header.pcr_index > EFI_TCG2_MAX_PCR_INDEX) { ret = EFI_INVALID_PARAMETER; goto out; }