Skip to contentSkip to conversation

tpm: Fix TPM 1.2 Shutdown sequence to prevent future TPM operations

PATCH Applied Douglas Anderson 2 participants 5 messages Jun 10, 2019 – Jun 14, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: Fix TPM 1.2 Shutdown sequence to prevent future TPM operations

From: Vadim Sukhomlinov <[email protected]>

TPM 2.0 Shutdown involve sending TPM2_Shutdown to TPM chip and disabling future TPM operations. TPM 1.2 behavior was different, future TPM operations weren't disabled, causing rare issues. This patch ensures that future TPM operations are disabled.

[dianders: resolved merge conflicts with mainline]

---

 drivers/char/tpm/tpm-chip.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm-chip.c +3 -3
index 8804c9e916fd..f566fa8bf704 100644
@@ -294,15 +294,15 @@ static int tpm_class_shutdown(struct device *dev)
 {
 	struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);
 
+	down_write(&chip->ops_sem);
 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
-		down_write(&chip->ops_sem);
 		if (!tpm_chip_start(chip)) {
 			tpm2_shutdown(chip, TPM2_SU_CLEAR);
 			tpm_chip_stop(chip);
 		}
-		chip->ops = NULL;
-		up_write(&chip->ops_sem);
 	}
+	chip->ops = NULL;
+	up_write(&chip->ops_sem);
 
 	return 0;
 }
Signature · 1 line
2.22.0.rc2.383.gf4fbbf30c2-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Douglas Anderson

From: Vadim Sukhomlinov <[email protected]>

TPM 2.0 Shutdown involve sending TPM2_Shutdown to TPM chip and disabling future TPM operations. TPM 1.2 behavior was different, future TPM operations weren't disabled, causing rare issues. This patch ensures that future TPM operations are disabled.

[dianders: resolved merge conflicts with mainline]

Nice catch. Thank you.

/Jarkko

#2 lore raw
Quoted 8 lines · Jarkko Sakkinen
Quoted 7 lines · Douglas Anderson

From: Vadim Sukhomlinov <[email protected]>

TPM 2.0 Shutdown involve sending TPM2_Shutdown to TPM chip and disabling future TPM operations. TPM 1.2 behavior was different, future TPM operations weren't disabled, causing rare issues. This patch ensures that future TPM operations are disabled.

Quoted 7 lines
Quoted 3 lines
[dianders: resolved merge conflicts with mainline]

Nice catch. Thank you.

Applied to my master branch. I also added a fixes tag.

Can you check that it looks legit to you?

/Jarkko

#3 lore raw

Hi,

Quoted 14 lines · Jarkko Sakkinen
Quoted 12 lines · Jarkko Sakkinen
Quoted 10 lines · Douglas Anderson

From: Vadim Sukhomlinov <[email protected]>

TPM 2.0 Shutdown involve sending TPM2_Shutdown to TPM chip and disabling future TPM operations. TPM 1.2 behavior was different, future TPM operations weren't disabled, causing rare issues. This patch ensures that future TPM operations are disabled.

[dianders: resolved merge conflicts with mainline]
Quoted 7 lines
Quoted 3 lines

Nice catch. Thank you.

Applied to my master branch. I also added a fixes tag.

Can you check that it looks legit to you?

Found the patch in your tree at
<http://git.infradead.org/users/jjs/linux-tpmdd.git/commit/41f15a4f02092d531fb34b42a06e9a1603a7df27>.
I'm decidedly a non-expert here, mostly just wrangling a patch that someone else came up with. :-) ...but let's see...

I think you're asking if the "Fixes" looks sane. I guess it depends on what you're trying to accomplish. Certainly what you've tagged in "Fixes" marks the point where it would be easiest to backport this fix to. ...but I think the problem is much older than that patch.

As I understand it, this problem has existed for much longer. I believe that ${SUBJECT} patch evolved from an investigation that Luigi Semenzato did back in 2013 when we got back some Chromebooks whose TPMs claimed that they had been "attacked". Said another way, I believe it is an evolution of the patch <https://crrev.com/c/57988>
("CHROMIUM: workaround for Infineon TPM broken defensive timeout").

...so technically someone ought to want this on all old kernels. Maybe keep the "Cc: stable" but remove the "Fixes"?

-Doug

#4 lore raw
Quoted 17 lines · Doug Anderson

Found the patch in your tree at
<http://git.infradead.org/users/jjs/linux-tpmdd.git/commit/41f15a4f02092d531fb34b42a06e9a1603a7df27>.
I'm decidedly a non-expert here, mostly just wrangling a patch that someone else came up with. :-) ...but let's see...

I think you're asking if the "Fixes" looks sane. I guess it depends on what you're trying to accomplish. Certainly what you've tagged in "Fixes" marks the point where it would be easiest to backport this fix to. ...but I think the problem is much older than that patch.

As I understand it, this problem has existed for much longer. I believe that ${SUBJECT} patch evolved from an investigation that Luigi Semenzato did back in 2013 when we got back some Chromebooks whose TPMs claimed that they had been "attacked". Said another way, I believe it is an evolution of the patch <https://crrev.com/c/57988>
("CHROMIUM: workaround for Infineon TPM broken defensive timeout").

Quoted 2 lines

...so technically someone ought to want this on all old kernels. Maybe keep the "Cc: stable" but remove the "Fixes"?

I guess that is what we have to do then.

/Jarkko