Re: [PATCH v11 00/16] Remove nested TPM operations

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

 



On 2/7/19 8:51 PM, Stefan Berger wrote:
On 2/7/19 7:33 PM, Jarkko Sakkinen wrote:
On Thu, Feb 07, 2019 at 06:29:43PM -0500, Stefan Berger wrote:
On 2/7/19 4:29 PM, Jarkko Sakkinen wrote:



diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index e74c5b7b64bf..52afe20cc8a1 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -799,7 +799,9 @@ int tpm2_probe(struct tpm_chip *chip)
      tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES);
      tpm_buf_append_u32(&buf, TPM_PT_TOTAL_COMMANDS);
      tpm_buf_append_u32(&buf, 1);
+    tpm_chip_start(chip);
      rc = tpm_transmit_cmd(chip, &buf, 0, NULL);
+    tpm_chip_stop(chip);
Thanks Stefan! I added call to tpm_tis_core as tpm2-cmd.c is to be kept
out of chip management common case being that you call tpm_try_get_ops(),
do 1-N TPM commands and release with tpm_put_ops(). These functions take
care starting and stopping the chip.

I fixed the 2nd issue in the master.

You also need to export the tpm_chip_start/stop symbols.


Master now seems to (still) have a problem when rmmod'ing:

A TPM error (325) occurred stopping the TPM. This happens at the same patch where I had to add the tpm_chip_start/stop above.



Here's my current overall patch against your master. I suppose the other tpm2_shutdown() for power management doesn't need the chip start ?

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 9865776ee2cd..f7147706a9c3 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -115,6 +115,7 @@ int tpm_chip_start(struct tpm_chip *chip)

     return 0;
 }
+EXPORT_SYMBOL_GPL(tpm_chip_start);

 /**
  * tpm_chip_stop() - power off the TPM
@@ -131,7 +132,7 @@ void tpm_chip_stop(struct tpm_chip *chip)
     if (chip->ops->clk_enable)
         chip->ops->clk_enable(chip, false);
 }
-
+EXPORT_SYMBOL_GPL(tpm_chip_stop);

 /**
  * tpm_try_get_ops() - Get a ref to the tpm_chip
@@ -474,8 +475,11 @@ static void tpm_del_char_device(struct tpm_chip *chip)

     /* Make the driver uncallable. */
     down_write(&chip->ops_sem);
-    if (chip->flags & TPM_CHIP_FLAG_TPM2)
+    if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+        tpm_chip_start(chip, 0);
         tpm2_shutdown(chip, TPM2_SU_CLEAR);
+        tpm_chip_stop(chip, 0);
+    }
     chip->ops = NULL;
     up_write(&chip->ops_sem);
 }
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 02e8cffd1163..fcd845ad8c3c 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -124,6 +124,8 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
         dev_err(&chip->dev, "tpm_transmit: tpm_recv: error %d\n", rc);
     } else if (len < TPM_HEADER_SIZE || len != be32_to_cpu(header->length))
         rc = -EFAULT;
+    else
+        rc = 0;

     return rc ? rc : len;
 }







  /Jarkko






[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