tpmdd-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm_tis: Issue a TPM2_Shutdown for TPM2 devices.
@ 2017-04-27 18:26 Josh Zimmerman
       [not found] ` <20170427182659.403-1-joshz-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 25+ messages in thread
From: Josh Zimmerman @ 2017-04-27 18:26 UTC (permalink / raw)
  To: Peter Huewe, Marcel Selhorst, Jarkko Sakkinen, Jason Gunthorpe,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

If a TPM2 loses power without a TPM2_Shutdown command being issued, it
may lose some state that has yet to be persisted to NVRam, and will
increment the DA counter (meaning that after too many disorderly
reboots, the TPM will lock the user out).

This is a variant of https://patchwork.kernel.org/patch/9516631/.
It differs in that:
  * It only changes behavior on TPM2 devices, to avoid invoking the
  unbounded-waiting sysfs codepath that was discussed on that patch.
  * It modifies tpm_tis rather than tpm_i2c_infineon, so that it can
  change behavior for all TPM2 devices.

Signed-off-by: Josh Zimmerman <joshz-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
---
 drivers/char/tpm/tpm_tis.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index c7e1384f1b08..bd9c70b305ab 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -216,11 +216,23 @@ static void tpm_tis_pnp_remove(struct pnp_dev *dev)
 	tpm_tis_remove(chip);
 }
 
+static void tpm_tis_pnp_shutdown(struct pnp_dev *dev)
+{
+	struct tpm_chip *chip = pnp_get_drvdata(dev);
+	// TPM 2.0 requires that the TPM2_Shutdown() command be issued prior to loss of power.
+	// If it is not, the DA counter will be incremented and, eventually, the user will be
+	// locked out of their TPM.
+	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
+		tpm_tis_pnp_remove(dev);
+	}
+}
+
 static struct pnp_driver tis_pnp_driver = {
 	.name = "tpm_tis",
 	.id_table = tpm_pnp_tbl,
 	.probe = tpm_tis_pnp_init,
 	.remove = tpm_tis_pnp_remove,
+	.shutdown = tpm_tis_pnp_shutdown,
 	.driver	= {
 		.pm = &tpm_tis_pm,
 	},
-- 
2.13.0.rc0.306.g87b477812d-goog


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

end of thread, other threads:[~2017-05-08 18:32 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-27 18:26 [PATCH] tpm_tis: Issue a TPM2_Shutdown for TPM2 devices Josh Zimmerman
     [not found] ` <20170427182659.403-1-joshz-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2017-04-27 20:49   ` Jason Gunthorpe
     [not found]     ` <20170427204912.GA26330-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-04-28 12:24       ` Jarkko Sakkinen
2017-04-28 12:12   ` Jarkko Sakkinen
     [not found]     ` <20170428121226.7xnpfbxcjszrnz5d-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-28 15:27       ` Jason Gunthorpe
     [not found]         ` <20170428152748.GA32017-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-04-28 18:27           ` Josh Zimmerman
     [not found]             ` <CAHSjozC=1GgKazv5m19X6Oe321+mkMUFCfFBQ=_c7kPQ-WESDA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-28 18:43               ` Jason Gunthorpe
     [not found]                 ` <20170428184325.GA15327-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-04-28 21:32                   ` Josh Zimmerman
     [not found]                     ` <CAHSjozDRHbuHD6dPfTGMnF4j66hPV-_WiD22y5WRpawPFMQmfQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-28 21:39                       ` Jason Gunthorpe
     [not found]                         ` <20170428213905.GA19326-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-04-28 21:45                           ` Rafael J. Wysocki
     [not found]                             ` <CAJZ5v0iFkLfmeQgZyQDoKF42=RQw6q_GdK3fLgwdC9_mDbJKjg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-28 22:16                               ` Jason Gunthorpe
     [not found]                                 ` <20170428221648.GA25935-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-04-28 23:30                                   ` Josh Zimmerman
2017-05-05 22:39                                   ` Josh Zimmerman
     [not found]                                     ` <CAHSjozCROVK=ca8tO+zNC+JD3a0+hQ-54AE7jGndrrs2nG1O1A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-05 22:46                                       ` Jason Gunthorpe
     [not found]                                         ` <20170505224629.GA15229-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-05-08 18:16                                           ` Josh Zimmerman
     [not found]                                             ` <CAHSjozCaWoQuQiWJ59_UyXnrnq=eh4sucLGgJ=0me6A0NHYsBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-05-08 18:24                                               ` Jason Gunthorpe
     [not found]                                                 ` <20170508182415.GA32332-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-05-08 18:32                                                   ` Josh Zimmerman
2017-04-28 22:07                           ` Josh Zimmerman
     [not found]                             ` <CAHSjozA0-NVB1Nbr3DQ-2tsY3jVa6ADYUECfXjkNJWL3tfhWNA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-04-28 22:24                               ` Jason Gunthorpe
     [not found]                                 ` <20170428222439.GB25935-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-04-29 11:53                                   ` Jarkko Sakkinen
2017-04-29 11:52                           ` Jarkko Sakkinen
2017-04-29 11:48               ` Jarkko Sakkinen
2017-04-29 11:40           ` Jarkko Sakkinen
     [not found]             ` <20170429114013.67xwbv6xozarcieq-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-04-29 15:30               ` Jerry Snitselaar
2017-05-03 12:42                 ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).