From patchwork Fri Nov 11 23:16:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evan Green X-Patchwork-Id: 19046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1015446wru; Fri, 11 Nov 2022 15:20:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf4bVLGOT5Q9WY7BFQHJLd3MS2x7b13vXHn2zvBNKNhEaISRHeREWsKKtoHCQNhlP9BjhTaG X-Received: by 2002:a63:2212:0:b0:46b:1091:16e0 with SMTP id i18-20020a632212000000b0046b109116e0mr3408089pgi.587.1668208832550; Fri, 11 Nov 2022 15:20:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668208832; cv=none; d=google.com; s=arc-20160816; b=kv7RhREZSk05YgHCgIEwPdxAdMGqZi+bAk6qtFcFxZ70SD1qsOd6MCJqrcHjLoAYSi szn/rmt8YZD8XqmW/A/kwvkHjzRVntVrCA2pLX67xsgwz9iw7FgYB1mNbTrtUKaCK8Po U6RLvePe5cF4US2I71iilvK91SRPQXQk1bX/7pMDxN+71bF0TCAI5DUmccyvuYmylcv2 DyXK+ufKpXEZs+bVCcsaZb7z5cjWqP8FMTTydjOHuiQWt30VrsF/ZI7+zJutnGof9lN8 itIZKwp6rM8gaz1c+uIZ1FZ7YM8az3NTK/5Dk3DtbiHCSSD6DKUYZhNkjkhsPfJ2zlmR X41Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 13-20020a17090a08cd00b00217d892ab40si7785902pjn.29.2022.11.11.15.20.19; Fri, 11 Nov 2022 15:20:32 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749243745210792702?= X-GMAIL-MSGID: =?utf-8?q?1749243745210792702?= 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;