Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2816792rwb; Fri, 11 Nov 2022 15:35:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7beW20z2x+l+CQdnF4lguZ7hqYagXUv4pbC0OrLFuSM0eO4dT+Y6LWvlq0MR1IEmg8bYr1 X-Received: by 2002:a17:906:1613:b0:7a2:fa90:924 with SMTP id m19-20020a170906161300b007a2fa900924mr3645746ejd.674.1668209752998; Fri, 11 Nov 2022 15:35:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668209752; cv=none; d=google.com; s=arc-20160816; b=buhLThAb3W6b6pJKjx3PBfapcXab03+0mf4X/05/nJZEjmo6Ik6cWObMlc8/F48QQW 8dXtTsIQ4Bp+vTgHeExlHX5avMWhtjPPTgvscPHQRqHBUYcViYV9iDNKHp9EJMocO5FD qDBMFySkpDLKuNjO2d9MQZpoZlysHtdIh9HaX6/R04wt3SzoZd/SmtwRj+KPeko06Bhl x3ZdUc8vcNpKRrvL6cJ4e5zCihBQPyRv1EahdB1q32QhkuV5v2tLyuHf9JWHHQULhsyq xLiKWrhDN968rhvnZhQDfdaBn0j1dYt+G2d6+Txe8W21qVJ9CHe5oUdWOTIa6MJgH5c2 JAzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=umKbLV2/EXZSPaYxETTXWSWJawSRXPaw3y+JZwX20lI=; b=HJA2EDzQxpZkyq+fcniUGbNSxLbxk2YHCEXASjKyNoaARkjwzS+pVmyuafz0JLXb1U /o/x7qj+1o0PnzebuHJrrQQWg351yScJ1XfPlJTSFpSH8cH8KOBAptADs43gVnrKZIP0 tarbFtr5wfw/StxjJASLCKA4QZsR4w3qWDIilDQlR5Vd4t707v9i2/LLZCyB4inRnjiP O0nZ46OPa/9LMUYNmm2emKuA/D7OuzIlqCM3YmRLG9OyK4qJkvypmYTPMtERSClnJLE6 Jbr4Ki6eYZF2OK5SEeU5xJJ9atWmB64l/qRs+HWDUGcoEXPpPsPDFxSdxx5L32pQhe9i +2Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=caf3ZVx7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a1709064ac100b007ae832c0b69si2484401ejt.512.2022.11.11.15.35.31; Fri, 11 Nov 2022 15:35:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=caf3ZVx7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234442AbiKKXTx (ORCPT + 90 others); Fri, 11 Nov 2022 18:19:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234234AbiKKXTn (ORCPT ); Fri, 11 Nov 2022 18:19:43 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 139897C8DB for ; Fri, 11 Nov 2022 15:19:42 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id b11so5634764pjp.2 for ; Fri, 11 Nov 2022 15:19:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=umKbLV2/EXZSPaYxETTXWSWJawSRXPaw3y+JZwX20lI=; b=caf3ZVx77TUd/TSgsUc0cN1uLK47M4itGZYebR27a13N/Z2JzTfqVYjOC9h+WirTco lKkEQRen0/mapYmtM8GXHzcEaTmhRrTCxcMpwUASU8hDhSzV2yDgUbQQTPnpDC1jYdWX lme/EKkQAtd03mv97kvvwNxMv0POgWVAGbpwA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=umKbLV2/EXZSPaYxETTXWSWJawSRXPaw3y+JZwX20lI=; b=jIt6M2j2wL1vnXPhzUI3O1+wQrP6edx03Q7oRmU3ENhUKVkbMW5881VaaroIlgBpNS Ylnlf/5yR7dpFt4mqNclmXWAhE4M3y+5UtqtCtvKY+4q/+wTAfXqWLWaAl9WlDieGKrg zOc0XT28+oyaehcJRCDXsnGdsSLwfWWg9TypLPsquBap91O/E+yJ5qO8uKSU6peUO3Lt QE3SADL/NM/TK+bG+IxYYM7t/vjByxIChnRrg0bUuo2n0tz/N2JGx0ChNHbKHmDiBr6y jVNxnOVzfzuPPxHy5+ocdajnXl+rFqJm1B3nGOYC+EyRBKgzCfRjQmTd264H1hmgvWNK S8OQ== X-Gm-Message-State: ANoB5pn6vm5GX29tueBU3otvN2kxxQJ3tu6EA2FgAdKuxZAf26JsXFrA Vqw8pqDxmt+x0p/zVx/3fcl5TGxMb68J9vky X-Received: by 2002:a17:902:f608:b0:17d:5e67:c523 with SMTP id n8-20020a170902f60800b0017d5e67c523mr4595938plg.115.1668208781497; Fri, 11 Nov 2022 15:19:41 -0800 (PST) Received: from evgreen-glaptop.lan ([98.45.28.95]) by smtp.gmail.com with ESMTPSA id x128-20020a623186000000b0056da2ad6503sm2106900pfx.39.2022.11.11.15.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 15:19:41 -0800 (PST) From: Evan Green To: linux-kernel@vger.kernel.org Cc: corbet@lwn.net, linux-integrity@vger.kernel.org, Eric Biggers , gwendal@chromium.org, dianders@chromium.org, apronin@chromium.org, Pavel Machek , Ben Boeckel , rjw@rjwysocki.net, jejb@linux.ibm.com, Kees Cook , dlunev@google.com, zohar@linux.ibm.com, Matthew Garrett , jarkko@kernel.org, linux-pm@vger.kernel.org, Evan Green , Jason Gunthorpe , Peter Huewe Subject: [PATCH v5 02/11] tpm: Export and rename tpm2_find_and_validate_cc() Date: Fri, 11 Nov 2022 15:16:27 -0800 Message-Id: <20221111151451.v5.2.I7bbedcf5efd3f1c72c32d6002faed086c5ed31c7@changeid> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221111231636.3748636-1-evgreen@chromium.org> References: <20221111231636.3748636-1-evgreen@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Export tpm_find_and_validate_cc() since it will be needed by an upcoming change allowing access to certain PCRs to be restricted to the kernel. In order to export it consistently, and because it's a tpm2-only function, rename it to tpm2_find_and_validate_cc(). Signed-off-by: Evan Green Reviewed-by: Kees Cook Acked-by: Jarkko Sakkinen --- (no changes since v3) Changes in v3: - Split find_and_validate_cc() export to its own patch (Jarkko) - Rename tpm_find_and_validate_cc() to tpm2_find_and_validate_cc(). drivers/char/tpm/tpm.h | 3 +++ drivers/char/tpm/tpm2-space.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 24ee4e1cc452a0..f1e0f490176f01 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -231,6 +231,9 @@ int tpm2_find_cc(struct tpm_chip *chip, u32 cc); int tpm2_init_space(struct tpm_space *space, unsigned int buf_size); void tpm2_del_space(struct tpm_chip *chip, struct tpm_space *space); void tpm2_flush_space(struct tpm_chip *chip); +int tpm2_find_and_validate_cc(struct tpm_chip *chip, + struct tpm_space *space, + const void *cmd, size_t len); int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd, size_t cmdsiz); int tpm2_commit_space(struct tpm_chip *chip, struct tpm_space *space, void *buf, diff --git a/drivers/char/tpm/tpm2-space.c b/drivers/char/tpm/tpm2-space.c index ffb35f0154c16c..ca34cc006e7f8d 100644 --- a/drivers/char/tpm/tpm2-space.c +++ b/drivers/char/tpm/tpm2-space.c @@ -262,9 +262,9 @@ static int tpm2_map_command(struct tpm_chip *chip, u32 cc, u8 *cmd) return 0; } -static int tpm_find_and_validate_cc(struct tpm_chip *chip, - struct tpm_space *space, - const void *cmd, size_t len) +int tpm2_find_and_validate_cc(struct tpm_chip *chip, + struct tpm_space *space, + const void *cmd, size_t len) { const struct tpm_header *header = (const void *)cmd; int i; @@ -306,7 +306,7 @@ int tpm2_prepare_space(struct tpm_chip *chip, struct tpm_space *space, u8 *cmd, if (!space) return 0; - cc = tpm_find_and_validate_cc(chip, space, cmd, cmdsiz); + cc = tpm2_find_and_validate_cc(chip, space, cmd, cmdsiz); if (cc < 0) return cc; -- 2.38.1.431.g37b22c650d-goog