lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220407111849.5676-2-LinoSanfilippo@gmx.de>
Date:   Thu,  7 Apr 2022 13:18:45 +0200
From:   Lino Sanfilippo <LinoSanfilippo@....de>
To:     peterhuewe@....de, jarkko@...nel.org, jgg@...pe.ca,
        =robh+dt@...nel.org
Cc:     devicetree@...r.kernel.org, linux-integrity@...r.kernel.org,
        linux-kernel@...r.kernel.org, stefanb@...ux.ibm.com,
        p.rosenberger@...bus.com, lukas@...ner.de,
        Lino Sanfilippo <LinoSanfilippo@....de>
Subject: [PATCH 1/5] tpm: add functions to set and unset the tpm chips reset state

Currently it is not possible to set the tpm chips reset state from within
the driver. This is problematic if the chip is still in reset after the
system comes up. This may e.g. happen if the reset line is pulled into
reset state by a pin configuration in the device tree.

To handle this case extend tpm_tis_phy_ops by the two functions "set_reset"
and "unset_reset" which may optionally be defined by a tpm driver.
If defined call "unset_reset" at chip startup before the first tpm command
is issued. Also if defined call "set_reset" at chip shutdown after the tpm2
shutdown command has been sent.

Signed-off-by: Lino Sanfilippo <LinoSanfilippo@....de>
---
 drivers/char/tpm/tpm-chip.c     | 5 +++++
 drivers/char/tpm/tpm_tis_core.c | 3 +++
 drivers/char/tpm/tpm_tis_core.h | 2 ++
 3 files changed, 10 insertions(+)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index 783d65fc71f0..c1b79ba9159d 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -24,6 +24,7 @@
 #include <linux/tpm_eventlog.h>
 #include <linux/hw_random.h>
 #include "tpm.h"
+#include "tpm_tis_core.h"
 
 DEFINE_IDR(dev_nums_idr);
 static DEFINE_MUTEX(idr_lock);
@@ -286,6 +287,7 @@ static void tpm_dev_release(struct device *dev)
 static int tpm_class_shutdown(struct device *dev)
 {
 	struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);
+	struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
 
 	down_write(&chip->ops_sem);
 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
@@ -297,6 +299,9 @@ static int tpm_class_shutdown(struct device *dev)
 	chip->ops = NULL;
 	up_write(&chip->ops_sem);
 
+	if (priv->phy_ops->set_reset)
+		priv->phy_ops->set_reset(priv);
+
 	return 0;
 }
 
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index dc56b976d816..11e5e045f3a7 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -952,6 +952,9 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 
 	dev_set_drvdata(&chip->dev, priv);
 
+	if (priv->phy_ops->unset_reset)
+		priv->phy_ops->unset_reset(priv);
+
 	rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor);
 	if (rc < 0)
 		return rc;
diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
index 3be24f221e32..f1a67445a5c5 100644
--- a/drivers/char/tpm/tpm_tis_core.h
+++ b/drivers/char/tpm/tpm_tis_core.h
@@ -105,6 +105,8 @@ struct tpm_tis_data {
 };
 
 struct tpm_tis_phy_ops {
+	int (*set_reset)(struct tpm_tis_data *data);
+	int (*unset_reset)(struct tpm_tis_data *data);
 	int (*read_bytes)(struct tpm_tis_data *data, u32 addr, u16 len,
 			  u8 *result);
 	int (*write_bytes)(struct tpm_tis_data *data, u32 addr, u16 len,
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ