From nobody Sun Feb 8 07:57:03 2026 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 EC2B0C61D85 for ; Tue, 21 Nov 2023 21:17:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234308AbjKUVRg (ORCPT ); Tue, 21 Nov 2023 16:17:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231362AbjKUVRd (ORCPT ); Tue, 21 Nov 2023 16:17:33 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 744751A3 for ; Tue, 21 Nov 2023 13:17:30 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B58E1C433C7; Tue, 21 Nov 2023 21:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700601450; bh=JhIxIpxRqOX9d+TKHEN9Y5MeVUPXrIM8NDLV56PQmNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KvhgJxUF/j8r4lIGvHz3JkwvPzaA1rQ4UurCNmN32gFTB78zRqsI5z9Bra8nTuHzf pp4js2QeICOUkbnuFlfqAkY4cnrk0WppEgFp0RYKQ6Jo6FhQ6a73JKWvACweJFVCeW LjTrJxp1F0PTMKzmL6dBfjtOBYl+2pKXQwAN5zhRW7MxeerPhgIRYd7kJn/AN6H6Y2 EqRGcj9wBPiPMb4zeZ1bx8nT/vNNF4gqLp5yjw9qX6J+AV6gk7WpcKj0MsCQW/fvM4 rhnDNij/E1udLwdoVNg4FrcCgbRF5XfnBIrlA35G2iYOOvTPvJlp143vubqvZdoMNg QHv144LCrWBKg== 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 , Peter Huewe , James Bottomley , Paul Moore , James Morris , "Serge E. Hallyn" , Julien Gomes Subject: [PATCH v4 2/8] tpm: Remove tpm_send() Date: Tue, 21 Nov 2023 23:17:11 +0200 Message-ID: <20231121211717.31681-3-jarkko@kernel.org> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231121211717.31681-1-jarkko@kernel.org> References: <20231121211717.31681-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 --- 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.42.1