From nobody Wed Dec 17 17:23:02 2025 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 98A85C61D97 for ; Fri, 24 Nov 2023 02:03:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbjKXCCz (ORCPT ); Thu, 23 Nov 2023 21:02:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbjKXCCr (ORCPT ); Thu, 23 Nov 2023 21:02:47 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12D9810DB for ; Thu, 23 Nov 2023 18:02:48 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58686C433C7; Fri, 24 Nov 2023 02:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700791367; bh=3Y6FhYUfs1OMTK8TpsSil3XSBqWxbXFTm8ChxAufa00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CS57FfiF6xyUpfkjxKHWVusOK8aWst3DmyHJFLm6QPQxMFqMuOr8gK4jYcD6TXcMr DfWnvezfb1RcUBgtfGeIcYJl+OIW7ZxB4hvmJbRVxitbKSXjrKDjAWJTF7wL5sXumv AlyrtCew6k1NuChpTHy/e8ssXjo2Ppf+sgIffvqNgKm/vfZWNyvT/AtBUvBbsPhlN4 nE02hD89e9aah8t/i8TNksbTR/fUl2D08TkglYm/aW6OkchJ3LwevtExVY4MXsDoOj Tg3Gqes2Q7FKVewC+Rtp4fK+PlKpB3DRaVC3sA5dcN5CcqyuIsGtGzt9C84U92ltpj HSgQ0HoGsxXsw== From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jarkko Sakkinen , James Bottomley , William Roberts , Stefan Berger , David Howells , Jason Gunthorpe , Mimi Zohar , Mario Limonciello , Jerry Snitselaar Subject: [PATCH v6 2/8] tpm: Remove tpm_send() Date: Fri, 24 Nov 2023 04:02:31 +0200 Message-ID: <20231124020237.27116-3-jarkko@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231124020237.27116-1-jarkko@kernel.org> References: <20231124020237.27116-1-jarkko@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Open code the last remaining call site for tpm_send(). Signed-off-by: Jarkko Sakkinen Reviewed-by: Stefan Berger --- v1 [2023-11-21]: A new patch. --- drivers/char/tpm/tpm-interface.c | 25 ----------------------- include/linux/tpm.h | 5 ----- security/keys/trusted-keys/trusted_tpm1.c | 14 +++++++++++-- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interf= ace.c index 66b16d26eecc..163ae247bff2 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -342,31 +342,6 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, } EXPORT_SYMBOL_GPL(tpm_pcr_extend); =20 -/** - * tpm_send - send a TPM command - * @chip: a &struct tpm_chip instance, %NULL for the default chip - * @cmd: a TPM command buffer - * @buflen: the length of the TPM command buffer - * - * Return: same as with tpm_transmit_cmd() - */ -int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen) -{ - struct tpm_buf buf; - int rc; - - chip =3D tpm_find_get_ops(chip); - if (!chip) - return -ENODEV; - - buf.data =3D cmd; - rc =3D tpm_transmit_cmd(chip, &buf, 0, "attempting to a send a command"); - - tpm_put_ops(chip); - return rc; -} -EXPORT_SYMBOL_GPL(tpm_send); - int tpm_auto_startup(struct tpm_chip *chip) { int rc; diff --git a/include/linux/tpm.h b/include/linux/tpm.h index 6588ca87cf93..d9d645e9c52c 100644 --- a/include/linux/tpm.h +++ b/include/linux/tpm.h @@ -422,7 +422,6 @@ extern int tpm_pcr_read(struct tpm_chip *chip, u32 pcr_= idx, struct tpm_digest *digest); extern int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, struct tpm_digest *digests); -extern int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen); extern int tpm_get_random(struct tpm_chip *chip, u8 *data, size_t max); extern struct tpm_chip *tpm_default_chip(void); void tpm2_flush_context(struct tpm_chip *chip, u32 handle); @@ -443,10 +442,6 @@ static inline int tpm_pcr_extend(struct tpm_chip *chip= , u32 pcr_idx, return -ENODEV; } =20 -static inline int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen) -{ - return -ENODEV; -} static inline int tpm_get_random(struct tpm_chip *chip, u8 *data, size_t m= ax) { return -ENODEV; diff --git a/security/keys/trusted-keys/trusted_tpm1.c b/security/keys/trus= ted-keys/trusted_tpm1.c index aa108bea6739..37bce84eef99 100644 --- a/security/keys/trusted-keys/trusted_tpm1.c +++ b/security/keys/trusted-keys/trusted_tpm1.c @@ -356,17 +356,27 @@ static int TSS_checkhmac2(unsigned char *buffer, */ int trusted_tpm_send(unsigned char *cmd, size_t buflen) { + struct tpm_buf buf; int rc; =20 if (!chip) return -ENODEV; =20 + rc =3D tpm_try_get_ops(chip); + if (rc) + return rc; + + buf.flags =3D 0; + buf.data =3D cmd; dump_tpm_buf(cmd); - rc =3D tpm_send(chip, cmd, buflen); + rc =3D tpm_transmit_cmd(chip, &buf, 4, "sending data"); dump_tpm_buf(cmd); + if (rc > 0) - /* Can't return positive return codes values to keyctl */ + /* TPM error */ rc =3D -EPERM; + + tpm_put_ops(chip); return rc; } EXPORT_SYMBOL_GPL(trusted_tpm_send); --=20 2.43.0