aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajiv Andrade <srajiv@linux.vnet.ibm.com>2012-04-24 16:38:17 -0400
committerRajiv Andrade <srajiv@linux.vnet.ibm.com>2012-06-12 17:53:49 -0400
commit24ebe6670de3d1f0dca11c9eb372134c7ab05503 (patch)
treef6cc7d88cc239a7ac49ba8ea94efa28f98430803
parentcbb2d5e459f4e10b3f1d11c23c31aa5d7c21e34c (diff)
TPM: chip disabled state erronously being reported as error
tpm_do_selftest() attempts to read a PCR in order to decide if one can rely on the TPM being used or not. The function that's used by __tpm_pcr_read() does not expect the TPM to be disabled or deactivated, and if so, reports an error. It's fine if the TPM returns this error when trying to use it for the first time after a power cycle, but it's definitely not if it already returned success for a previous attempt to read one of its PCRs. The tpm_do_selftest() was modified so that the driver only reports this return code as an error when it really is. Reported-and-tested-by: Paul Bolle <pebolle@tiscali.nl> Cc: Stable <stable@vger.kernel.org> Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
-rw-r--r--drivers/char/tpm/tpm.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index ad7c7320dd1b..08427abf5fa5 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -827,10 +827,10 @@ EXPORT_SYMBOL_GPL(tpm_pcr_extend);
827int tpm_do_selftest(struct tpm_chip *chip) 827int tpm_do_selftest(struct tpm_chip *chip)
828{ 828{
829 int rc; 829 int rc;
830 u8 digest[TPM_DIGEST_SIZE];
831 unsigned int loops; 830 unsigned int loops;
832 unsigned int delay_msec = 1000; 831 unsigned int delay_msec = 1000;
833 unsigned long duration; 832 unsigned long duration;
833 struct tpm_cmd_t cmd;
834 834
835 duration = tpm_calc_ordinal_duration(chip, 835 duration = tpm_calc_ordinal_duration(chip,
836 TPM_ORD_CONTINUE_SELFTEST); 836 TPM_ORD_CONTINUE_SELFTEST);
@@ -845,7 +845,15 @@ int tpm_do_selftest(struct tpm_chip *chip)
845 return rc; 845 return rc;
846 846
847 do { 847 do {
848 rc = __tpm_pcr_read(chip, 0, digest); 848 /* Attempt to read a PCR value */
849 cmd.header.in = pcrread_header;
850 cmd.params.pcrread_in.pcr_idx = cpu_to_be32(0);
851 rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE);
852
853 if (rc < TPM_HEADER_SIZE)
854 return -EFAULT;
855
856 rc = be32_to_cpu(cmd.header.out.return_code);
849 if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) { 857 if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) {
850 dev_info(chip->dev, 858 dev_info(chip->dev,
851 "TPM is disabled/deactivated (0x%X)\n", rc); 859 "TPM is disabled/deactivated (0x%X)\n", rc);