[PATCH] tpm: Fix alignment of buf->handles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx # v6.10+
Fixes: 699e3efd6c64 ("tpm: Add HMAC session start and end functions")
Signed-off-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
---
 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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux