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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 25 Jun 2020 17:46:44 +0300
From:   amirmizi6@...il.com
To:     Eyal.Cohen@...oton.com, jarkko.sakkinen@...ux.intel.com,
        oshrialkoby85@...il.com, alexander.steffen@...ineon.com,
        robh+dt@...nel.org,
        "benoit.houyere@...com--to=mark.rutland"@arm.com,
        peterhuewe@....de, christophe-h.richard@...com, jgg@...pe.ca,
        arnd@...db.de, gregkh@...uxfoundation.org
Cc:     devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-integrity@...r.kernel.org, oshri.alkoby@...oton.com,
        tmaimon77@...il.com, gcwilson@...ibm.com, kgoldman@...ibm.com,
        Dan.Morav@...oton.com, oren.tanami@...oton.com,
        shmulik.hager@...oton.com, amir.mizinski@...oton.com,
        Amir Mizinski <amirmizi6@...il.com>,
        Christophe Ricard <christophe-h.ricard@...com>
Subject: [PATCH v12 4/9] tpm: tpm_tis: Add verify_data_integrity handle to tpm_tis_phy_ops

From: Amir Mizinski <amirmizi6@...il.com>

When using I2C bus protocol, the TPM has the ability to report data
integrity on incoming or outgoing command parameter bytes.
According to the TCG specs, if this data validation functionality is
enabled via the TPM_DATA_CSUM_ENABLE register, the TPM will update the
TPM_DATA_CSUM register after reception of the last command byte and after
the last response byte has been read.

Data integrity is checked if a "verify_data_integrity" handle is defined in
"tpm_tis_phy_ops".

Co-developed-by: Christophe Ricard <christophe-h.ricard@...com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@...com>
Signed-off-by: Amir Mizinski <amirmizi6@...il.com>
---
 drivers/char/tpm/tpm_tis_core.c | 14 ++++++++++++++
 drivers/char/tpm/tpm_tis_core.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index e136467..347c020 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -347,6 +347,13 @@ static int __tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count)
 		return size;
 	}
 
+	if (priv->phy_ops->verify_data_integrity)
+		if (!priv->phy_ops->verify_data_integrity(priv, buf,
+							  size)) {
+			size = -EIO;
+			return size;
+		}
+
 	return size;
 }
 
@@ -419,6 +426,13 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
 		return rc;
 	}
 
+	if (priv->phy_ops->verify_data_integrity) {
+		if (!priv->phy_ops->verify_data_integrity(priv, buf, len)) {
+			rc = -EIO;
+			return rc;
+		}
+	}
+
 	return 0;
 }
 
diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
index 6cc6b76..cd97c01 100644
--- a/drivers/char/tpm/tpm_tis_core.h
+++ b/drivers/char/tpm/tpm_tis_core.h
@@ -107,6 +107,8 @@ struct tpm_tis_phy_ops {
 	int (*read16)(struct tpm_tis_data *data, u32 addr, u16 *result);
 	int (*read32)(struct tpm_tis_data *data, u32 addr, u32 *result);
 	int (*write32)(struct tpm_tis_data *data, u32 addr, u32 src);
+	bool (*verify_data_integrity)(struct tpm_tis_data *data, const u8 *buf,
+				      size_t len);
 };
 
 static inline int tpm_tis_read_bytes(struct tpm_tis_data *data, u32 addr,
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ