[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240716161348.99858-1-jarkko@kernel.org>
Date: Tue, 16 Jul 2024 19:13:46 +0300
From: Jarkko Sakkinen <jarkko@...nel.org>
To: linux-integrity@...r.kernel.org
Cc: Jarkko Sakkinen <jarkko@...nel.org>,
stable@...r.kernel.org,
James Bottomley <James.Bottomley@...senPartnership.com>,
Mimi Zohar <zohar@...ux.ibm.com>,
David Howells <dhowells@...hat.com>,
Paul Moore <paul@...l-moore.com>,
James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
keyrings@...r.kernel.org,
linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] tpm: Fix alignment of buf->handles
tpm_buf_append_name() has the following snippet in the beginning:
if (!tpm2_chip_auth(chip)) {
tpm_buf_append_u32(buf, handle);
/* count the number of handles in the upper bits of flags */
buf->handles++;
return;
}
The claim in the comment is wrong, and the comment is in the wrong place
as it should not be anyway a concern of the "call site". So in essence
it is lying about the code.
Fix the alignment to be aligned with the claim in the comment and remove
the comment.
Cc: stable@...r.kernel.org # v6.10+
Fixes: 699e3efd6c64 ("tpm: Add HMAC session start and end functions")
Signed-off-by: Jarkko Sakkinen <jarkko@...nel.org>
---
drivers/char/tpm/tpm2-sessions.c | 1 -
include/linux/tpm.h | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/char/tpm/tpm2-sessions.c b/drivers/char/tpm/tpm2-sessions.c
index d3521aadd43e..02fc5d4ff535 100644
--- a/drivers/char/tpm/tpm2-sessions.c
+++ b/drivers/char/tpm/tpm2-sessions.c
@@ -238,7 +238,6 @@ void tpm_buf_append_name(struct tpm_chip *chip, struct tpm_buf *buf,
if (!tpm2_chip_auth(chip)) {
tpm_buf_append_u32(buf, handle);
- /* count the number of handles in the upper bits of flags */
buf->handles++;
return;
}
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index e93ee8d936a9..4b55298520b5 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -374,10 +374,10 @@ enum tpm_buf_flags {
* A string buffer type for constructing TPM commands.
*/
struct tpm_buf {
- u32 flags;
+ u16 flags;
+ u16 handles;
u32 length;
u8 *data;
- u8 handles;
};
enum tpm2_object_attributes {
--
2.45.2
Powered by blists - more mailing lists