From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795903015; b=BScZ9THwH0DjsvNsMxO3kBbkaeRCVvQs0Y2PwI732Si8Mus+MYDn3uILZ9lwoFTSScIm KJKLXfnAnj/F4z9cFJ1bjLYjABBM/jMMcTzMC4IHmp3B3KSaWCCCL0oYsFqKWwAM8ql/C gXNuUN9recj09eDt0x5CH99apMGieWJiijxfcGmSW8njoZminmSmIZgmz05gAsSIZ7l+9 QzaEQfd3bJ5ugzu+YFVAtLJYAeoIP3T1IZirxb+EUTgxq4ZJf9XTVPrW9WqCbBgHsMH8m 4EWk7SADnS30i+7wtpSs+ayq5stJN+MZ+8CUR0YbnE/dyr8Lefy0D0ktFbcDiZ+NE/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795903015; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=ckJKF95/oQtqNhFPVFlEGqDFM5F8CpGFh4qi3pk2QRc=; b=AEpHYr3w8WJPH97h0Uwvk8x3CxW8nuc8LJwnwYgUTBU+NQdYNXn5UMZSDifR8RgXhCC8 D8K73j3Uvi5PUu2NjQmJHH2xUZDGZQJ4z1zeuIwmr3+h8dOVgZ8Y1oAcBsWxFiv4+rFqw tScDaTOc1PsRXJV9Ob6GT1eiWlx3AfgUFKlnzIvD4S5FbobfVmoS3peaqoF9cZI0m0Un5 qGPfjprIaATUqn5CBSad+WAax5EpOft4Zz0zsTdxzNUj7mCyeS86Iecrl13HMaoUtBieQ mkROcJbUbyj+QKNNnumG8W/ZK/c9hQ0lfuD2XhrnALlq5AVrbEx3TSnvhfzlkqS0VRQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nps2SOqy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id 8F8DE606A31C; Sat, 28 Nov 2026 21:56:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nps2SOqy Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 919611F0092C; Sat, 28 Nov 2026 21:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795903015; bh=ckJKF95/oQtqNhFPVFlEGqDFM5F8CpGFh4qi3pk2QRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nps2SOqyo1nXVcw/UJW9PhtyoDekla2nwoDtL1Eolta0uzeh70VkYfgxnCp+NDLYT wairmx6Za7Ucb/lkx7DWnjAUwDCIK2HO84UeLtPu7U+XOh6YS6CsIpW1vLv0dG8sfb qJX22jGwYoBwtCzGbVEe+pWPRE9I3Fj4+WhX0aVZawFqhqmOTSiuLJVRLdyqgOx7Fv XFmdWU+9Lh/6N+BK8zoGMFO+pH7t6o4cmBC5+2YJ39GD1JrSmkDmpdD0mvam/qXkmt M43Za2TQ8uc4InDje7Gi1P6+UoNqN83GibadqiiaflP08AEKcm3sIBEwT9XNuFzYzV 9ESoq0zqbSpmQ== From: Jarkko Sakkinen To: keyrings@vger.kernel.org Cc: Jarkko Sakkinen , dm-devel@lists.linux.dev, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Ahmad Fatoum , Alasdair Kergon , Andrew Morton , Benjamin Marzinski , David Gstir , David Howells , David Laight , "David S. Miller" , David Woodhouse , Eric Biggers , Herbert Xu , Ignat Korchagin , James Bottomley , James Morris , James Prestwood , Jason Gunthorpe , Jonathan Corbet , Jonathan McDowell , Lukas Wunner , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Mike Snitzer , Mikulas Patocka , Mimi Zohar , Paul Moore , Peter Huewe , Randy Dunlap , "Serge E. Hallyn" , Shuah Khan , Sumit Garg Subject: [PATCH v6 05/18] KEYS: trusted: Remove dead branch from tpm2_unseal_cmd Date: Sat, 28 Nov 2026 23:56:07 +0200 Message-ID: <20261128215621.2253928-6-jarkko@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261128215621.2253928-1-jarkko@kernel.org> References: <20261128215621.2253928-1-jarkko@kernel.org> X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit TPM2_Unseal requires TPM2_ST_SESSIONS, and tpm2_unseal_cmd() always does set up either password or HMAC session. Remove the branch in tpm2_unseal_cmd() conditionally setting TPM2_ST_NO_SESSIONS. It is faulty but luckily it is never exercised at run-time, and thus does not cause regressions. Reviewed-by: Jonathan McDowell Signed-off-by: Jarkko Sakkinen --- security/keys/trusted-keys/trusted_tpm2.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c index 2f7c8e571522..32d90a1f8357 100644 --- a/security/keys/trusted-keys/trusted_tpm2.c +++ b/security/keys/trusted-keys/trusted_tpm2.c @@ -470,10 +470,8 @@ static int tpm2_unseal_cmd(struct tpm_chip *chip, u32 blob_handle) { struct trusted_key_tpm *private = options->private; - struct tpm_header *head; struct tpm_buf *buf __free(kfree) = NULL; u16 data_len; - int offset; u8 *data; int rc; @@ -517,15 +515,9 @@ static int tpm2_unseal_cmd(struct tpm_chip *chip, tpm_buf_append_u16(buf, private->blobauth_len); tpm_buf_append(buf, private->blobauth, private->blobauth_len); - if (tpm2_chip_auth(chip)) { + if (tpm2_chip_auth(chip)) tpm_buf_append_hmac_session(chip, buf, TPM2_SA_ENCRYPT, NULL, 0); - } else { - offset = buf->handles * 4 + TPM_HEADER_SIZE; - head = (struct tpm_header *)buf->data; - if (tpm_buf_length(buf) == offset) - head->tag = cpu_to_be16(TPM2_ST_NO_SESSIONS); - } } rc = tpm_buf_fill_hmac_session(chip, buf); -- 2.47.3