From nobody Sat Feb 7 11:31:31 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D44AB2F12A5; Sun, 25 Jan 2026 19:26:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769369167; cv=none; b=O0BayPaFe/HRKld8FTSFsx0IvbHirYAmZbt7bMGSZEwBvdkbc7ZB57A4yIxzYZGIH1wI5JpzH1NGTXA5/MDjKiHV6JrVN9otNA5o5IdNe/2Qwdq+H/kDB9IcScqvPo383/ShLohbR3YdKM9YyBIHhJq907/HI5caddEyOIhuGUA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769369167; c=relaxed/simple; bh=5edvRXiZtKuCqYiyovDpX6TJD/qNz0z+e7B/kJJvrgk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FERsqGdVcdaKHKqRi6RF0uktgyTJ3ddI7kHyrkrab8DmponNc31plCn6BMn0hppUIf3nQ1DNPA6zeyJx5gryU5hi/70jA89KhwvmeSOV8JxfusSaCswAJf2SBQBGCwfEHq20hIyNWfl5RWcVq8sSXNT1E7XyesBCzGXxaZ/LV1g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b1t1gwLw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b1t1gwLw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29489C4CEF1; Sun, 25 Jan 2026 19:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769369167; bh=5edvRXiZtKuCqYiyovDpX6TJD/qNz0z+e7B/kJJvrgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b1t1gwLw9B7EfCjDkrDVNY1HcosD7na6FOwZj2ckixl4xtS+5U6NrLKnqCD/yS1Uk WoTIm8hpBIA/pFJgolKmOgYBrHWy4vbfFtiBJH2PRiEdmCaX1MVt8U3oMqck6Ip00v 28dpdWSJ/x/V1VFlyoexVbO6wbQebvI+/1WRaeBkQo/mUvkTuqcnF8Z76SGgXAq0Xh xLKsnCCszI7wrJm51uySQ3EqeO4oLeEsyZfVq9eGUvhkCSO/H7uGBD0IrhXXmEYpMI tA5rnviJ6nMDWyu0MkOSAhn5sZf++9w+s9brH7jHSiih9Eo9iQIRqAzRIAJODJOFhT WHWOQUp4M2DHQ== From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Cc: Jarkko Sakkinen , Jonathan McDowell , James Bottomley , Mimi Zohar , David Howells , Paul Moore , James Morris , "Serge E. Hallyn" , keyrings@vger.kernel.org (open list:KEYS-TRUSTED), linux-security-module@vger.kernel.org (open list:SECURITY SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v9 06/11] KEYS: trusted: Remove dead branch from tpm2_unseal_cmd Date: Sun, 25 Jan 2026 21:25:16 +0200 Message-ID: <20260125192526.782202-7-jarkko@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260125192526.782202-1-jarkko@kernel.org> References: <20260125192526.782202-1-jarkko@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/trus= ted-keys/trusted_tpm2.c index 4894aae6ef70..ec84ea945d3b 100644 --- a/security/keys/trusted-keys/trusted_tpm2.c +++ b/security/keys/trusted-keys/trusted_tpm2.c @@ -451,10 +451,8 @@ static int tpm2_unseal_cmd(struct tpm_chip *chip, struct trusted_key_options *options, u32 blob_handle) { - struct tpm_header *head; struct tpm_buf buf; u16 data_len; - int offset; u8 *data; int rc; =20 @@ -495,14 +493,8 @@ static int tpm2_unseal_cmd(struct tpm_chip *chip, tpm_buf_append_u16(&buf, options->blobauth_len); tpm_buf_append(&buf, options->blobauth, options->blobauth_len); =20 - if (tpm2_chip_auth(chip)) { + if (tpm2_chip_auth(chip)) tpm_buf_append_hmac_session(chip, &buf, TPM2_SA_ENCRYPT, NULL, 0); - } else { - offset =3D buf.handles * 4 + TPM_HEADER_SIZE; - head =3D (struct tpm_header *)buf.data; - if (tpm_buf_length(&buf) =3D=3D offset) - head->tag =3D cpu_to_be16(TPM2_ST_NO_SESSIONS); - } } =20 rc =3D tpm_buf_fill_hmac_session(chip, &buf); --=20 2.52.0