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: 13040933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D2C3C4167E for ; Fri, 11 Nov 2022 23:19:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234387AbiKKXTo (ORCPT ); Fri, 11 Nov 2022 18:19:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234237AbiKKXTn (ORCPT ); Fri, 11 Nov 2022 18:19:43 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F001C7C8CD for ; Fri, 11 Nov 2022 15:19:41 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id k5so5612274pjo.5 for ; Fri, 11 Nov 2022 15:19:41 -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=ICNY25pfQnNJYcV1eACc3lHSxzM0PpadN/D5X/VliA3cWIwDfWiTPPL96U0y5o0ubR uzSJ53D9g4L3Zhik+FDvX4ixGegFQvAMRRUdMXizX1uDWDNwGZnrfXoywVfiOsQZfijn Ob32Td28aeU/b9xUSUZICUsNwoYludG8rCjXhPofx/ZRuuqtp37fI7HPvdQGiEndJVCL IoSftTBGBNNSWrZwyyzpNP+EZq217OcLmC5ycLWv+k9PtNzHuergBkDZJB+b2hh3R0ty Zu2uM08+wInmwtoABmxlDfsFcGK6jII2n5n55+AoI+eyD4+4GLh8wOPsfwHivF0voHKn 2Ssg== X-Gm-Message-State: ANoB5pmwdOg9872+wb3sEB5ye5KIWEBnvRPAR3315WAa1dU7lCLln+qU pNNTfSTP6me8knbYFggecDuLgA== X-Google-Smtp-Source: AA0mqf7ewcvA0K1J4/tma0HbDwKrHuk9MedjIZ+JGbi/UiJngTEOp2O8W0m61z2UZVKPVkDgT7k7Aw== 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 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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;