public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] TPM: Fixup pcrs sysfs file
@ 2009-09-02  3:16 Jason Gunthorpe
  2009-09-03 23:52 ` Andrew Morton
  0 siblings, 1 reply; 9+ messages in thread
From: Jason Gunthorpe @ 2009-09-02  3:16 UTC (permalink / raw)
  To: tpmdd-devel; +Cc: linux-kernel, srajiv

I'm testing the tpm_tis low level driver with a winbond WPCT200:
$ cat caps
Manufacturer: 0x57454300
TCG version: 1.2
Firmware version: 2.16

and noted that tpm_pcr_read for the pcrs sysfile file does not function.
tpm_tis_recv returned with an error because the expected reply size was
set to 14 (the request size) and the chip returned 30 bytes.

The TCG spec says the reply size is supposed to be 30 bytes.

First, the BUILD_BUG_ON was surely never correct, testing a run time
value in big endian with that macro is just wrong. I belive the intended
test was to ensure that the cmd buffer has enough space to store the
reply.

Second, the length input to transmit_cmd is the size of the reply, not
of the request. It should be 30 for READ_PCR.

With this change my chip reports all 23 pcrs.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
 drivers/char/tpm/tpm.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index a6b52d6..8ba0187 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -696,8 +696,8 @@ int __tpm_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf)
 
 	cmd.header.in = pcrread_header;
 	cmd.params.pcrread_in.pcr_idx = cpu_to_be32(pcr_idx);
-	BUILD_BUG_ON(cmd.header.in.length > READ_PCR_RESULT_SIZE);
-	rc = transmit_cmd(chip, &cmd, cmd.header.in.length,
+	BUILD_BUG_ON(sizeof(cmd) < READ_PCR_RESULT_SIZE);
+	rc = transmit_cmd(chip, &cmd, READ_PCR_RESULT_SIZE,
 			  "attempting to read a pcr value");
 
 	if (rc == 0)
-- 
1.5.4.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-09-14 18:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-02  3:16 [PATCH] TPM: Fixup pcrs sysfs file Jason Gunthorpe
2009-09-03 23:52 ` Andrew Morton
2009-09-04  1:28   ` Jason Gunthorpe
2009-09-14  2:36     ` James Morris
2009-09-14  6:25       ` Jason Gunthorpe
2009-09-14  7:11         ` Andrew Morton
2009-09-14 17:45         ` Rajiv Andrade
2009-09-14 17:52           ` Rajiv Andrade
2009-09-14 18:00           ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox