Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1451703 > unrolled thread
| Started by | Andrey Pronin <apronin@chromium.org> |
|---|---|
| First post | 2016-07-28 06:00 +0200 |
| Last post | 2016-08-09 10:20 +0200 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v3 0/2] tpm: add optional max xfer size check Andrey Pronin <apronin@chromium.org> - 2016-07-28 06:00 +0200
[PATCH v3 1/2] tpm_tis_core: add optional max xfer size check Andrey Pronin <apronin@chromium.org> - 2016-07-28 06:00 +0200
Re: [PATCH v3 1/2] tpm_tis_core: add optional max xfer size check Dmitry Torokhov <dtor@chromium.org> - 2016-07-29 01:00 +0200
Re: [PATCH v3 1/2] tpm_tis_core: add optional max xfer size check Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-08-09 10:20 +0200
[PATCH v3 2/2] tpm_tis_spi: add max xfer size Andrey Pronin <apronin@chromium.org> - 2016-07-28 06:00 +0200
Re: [PATCH v3 2/2] tpm_tis_spi: add max xfer size Dmitry Torokhov <dtor@chromium.org> - 2016-07-29 01:00 +0200
Re: [PATCH v3 2/2] tpm_tis_spi: add max xfer size Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-08-09 10:20 +0200
| From | Andrey Pronin <apronin@chromium.org> |
|---|---|
| Date | 2016-07-28 06:00 +0200 |
| Subject | [PATCH v3 0/2] tpm: add optional max xfer size check |
| Message-ID | <rZKEh-AR-1@gated-at.bofh.it> |
This patchset introduces an optional maximum transfer size that can be specified by a tpm driver. Setting the max_xfer_size helps to catch the cases when burstcnt is incorrectly reported by the device (e.g. >64 for spi - happened in practice) and gracefully handle such situations. v2: removed unnecessary accessors in tpm_tis_core.h, fixed style v3: simplified logic: simply cap the burstcnt at max_xfer_size, don't attempt to re-request from tpm. Andrey Pronin (2): tpm_tis_core: add optional max xfer size check tpm_tis_spi: add max xfer size drivers/char/tpm/tpm_tis_core.c | 9 ++++++++- drivers/char/tpm/tpm_tis_core.h | 1 + drivers/char/tpm/tpm_tis_spi.c | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) -- 2.6.6
[toc] | [next] | [standalone]
| From | Andrey Pronin <apronin@chromium.org> |
|---|---|
| Date | 2016-07-28 06:00 +0200 |
| Subject | [PATCH v3 1/2] tpm_tis_core: add optional max xfer size check |
| Message-ID | <rZKEh-AR-5@gated-at.bofh.it> |
| In reply to | #1451703 |
If tpm reports a bigger burstcnt than allowed by the physical protocol,
set burstcnt to the max allowed value.
In practice, seen in case of xfer issues (e.g. in spi interface case,
lost header causing flow control issues and wrong values returned on read
from TPM_STS). Without catching, causes the physical layer to reject xfer.
Signed-off-by: Andrey Pronin <apronin@chromium.org>
---
drivers/char/tpm/tpm_tis_core.c | 9 ++++++++-
drivers/char/tpm/tpm_tis_core.h | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index f22caf8..7c4fa0c 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -168,8 +168,15 @@ static int get_burstcount(struct tpm_chip *chip)
return rc;
burstcnt = (value >> 8) & 0xFFFF;
- if (burstcnt)
+ if (burstcnt) {
+ if (priv->phy_ops->max_xfer_size &&
+ (burstcnt > priv->phy_ops->max_xfer_size)) {
+ dev_warn(&chip->dev,
+ "Bad burstcnt read: %d\n", burstcnt);
+ burstcnt = priv->phy_ops->max_xfer_size;
+ }
return burstcnt;
+ }
msleep(TPM_TIMEOUT);
} while (time_before(jiffies, stop));
return -EBUSY;
diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
index 9191aab..58e8b14 100644
--- a/drivers/char/tpm/tpm_tis_core.h
+++ b/drivers/char/tpm/tpm_tis_core.h
@@ -102,6 +102,7 @@ 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);
+ u16 max_xfer_size;
};
static inline int tpm_tis_read_bytes(struct tpm_tis_data *data, u32 addr,
--
2.6.6
[toc] | [prev] | [next] | [standalone]
| From | Dmitry Torokhov <dtor@chromium.org> |
|---|---|
| Date | 2016-07-29 01:00 +0200 |
| Subject | Re: [PATCH v3 1/2] tpm_tis_core: add optional max xfer size check |
| Message-ID | <s02rw-4gN-9@gated-at.bofh.it> |
| In reply to | #1451704 |
On Wed, Jul 27, 2016 at 08:49:56PM -0700, Andrey Pronin wrote:
> If tpm reports a bigger burstcnt than allowed by the physical protocol,
> set burstcnt to the max allowed value.
>
> In practice, seen in case of xfer issues (e.g. in spi interface case,
> lost header causing flow control issues and wrong values returned on read
> from TPM_STS). Without catching, causes the physical layer to reject xfer.
>
> Signed-off-by: Andrey Pronin <apronin@chromium.org>
> ---
> drivers/char/tpm/tpm_tis_core.c | 9 ++++++++-
> drivers/char/tpm/tpm_tis_core.h | 1 +
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index f22caf8..7c4fa0c 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -168,8 +168,15 @@ static int get_burstcount(struct tpm_chip *chip)
> return rc;
>
> burstcnt = (value >> 8) & 0xFFFF;
> - if (burstcnt)
> + if (burstcnt) {
> + if (priv->phy_ops->max_xfer_size &&
> + (burstcnt > priv->phy_ops->max_xfer_size)) {
This does not actually need parentheses, otehrwise:
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
> + dev_warn(&chip->dev,
> + "Bad burstcnt read: %d\n", burstcnt);
> + burstcnt = priv->phy_ops->max_xfer_size;
> + }
> return burstcnt;
> + }
> msleep(TPM_TIMEOUT);
> } while (time_before(jiffies, stop));
> return -EBUSY;
> diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
> index 9191aab..58e8b14 100644
> --- a/drivers/char/tpm/tpm_tis_core.h
> +++ b/drivers/char/tpm/tpm_tis_core.h
> @@ -102,6 +102,7 @@ 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);
> + u16 max_xfer_size;
> };
>
> static inline int tpm_tis_read_bytes(struct tpm_tis_data *data, u32 addr,
> --
> 2.6.6
>
--
Dmitry
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2016-08-09 10:20 +0200 |
| Subject | Re: [PATCH v3 1/2] tpm_tis_core: add optional max xfer size check |
| Message-ID | <s4aqt-51O-1@gated-at.bofh.it> |
| In reply to | #1451704 |
On Wed, Jul 27, 2016 at 08:49:56PM -0700, Andrey Pronin wrote:
> If tpm reports a bigger burstcnt than allowed by the physical protocol,
> set burstcnt to the max allowed value.
>
> In practice, seen in case of xfer issues (e.g. in spi interface case,
> lost header causing flow control issues and wrong values returned on read
> from TPM_STS). Without catching, causes the physical layer to reject xfer.
>
> Signed-off-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
I don't have hardware to test this. Someone should validate that it
does not break anything. Christophe, are you able to do this?
/Jarkko
> ---
> drivers/char/tpm/tpm_tis_core.c | 9 ++++++++-
> drivers/char/tpm/tpm_tis_core.h | 1 +
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index f22caf8..7c4fa0c 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -168,8 +168,15 @@ static int get_burstcount(struct tpm_chip *chip)
> return rc;
>
> burstcnt = (value >> 8) & 0xFFFF;
> - if (burstcnt)
> + if (burstcnt) {
> + if (priv->phy_ops->max_xfer_size &&
> + (burstcnt > priv->phy_ops->max_xfer_size)) {
> + dev_warn(&chip->dev,
> + "Bad burstcnt read: %d\n", burstcnt);
> + burstcnt = priv->phy_ops->max_xfer_size;
> + }
> return burstcnt;
> + }
> msleep(TPM_TIMEOUT);
> } while (time_before(jiffies, stop));
> return -EBUSY;
> diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
> index 9191aab..58e8b14 100644
> --- a/drivers/char/tpm/tpm_tis_core.h
> +++ b/drivers/char/tpm/tpm_tis_core.h
> @@ -102,6 +102,7 @@ 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);
> + u16 max_xfer_size;
> };
>
> static inline int tpm_tis_read_bytes(struct tpm_tis_data *data, u32 addr,
> --
> 2.6.6
>
[toc] | [prev] | [next] | [standalone]
| From | Andrey Pronin <apronin@chromium.org> |
|---|---|
| Date | 2016-07-28 06:00 +0200 |
| Subject | [PATCH v3 2/2] tpm_tis_spi: add max xfer size |
| Message-ID | <rZKEh-AR-11@gated-at.bofh.it> |
| In reply to | #1451703 |
Reject burstcounts larger than 64 bytes reported by tpm.
SPI Hardware Protocol defined in section 6.4 of TCG PTP
Spec supports up to 64 bytes of data in a transaction.
Signed-off-by: Andrey Pronin <apronin@chromium.org>
---
drivers/char/tpm/tpm_tis_spi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
index dbaad9c..b103373 100644
--- a/drivers/char/tpm/tpm_tis_spi.c
+++ b/drivers/char/tpm/tpm_tis_spi.c
@@ -206,6 +206,7 @@ static const struct tpm_tis_phy_ops tpm_spi_phy_ops = {
.read16 = tpm_tis_spi_read16,
.read32 = tpm_tis_spi_read32,
.write32 = tpm_tis_spi_write32,
+ .max_xfer_size = MAX_SPI_FRAMESIZE,
};
static int tpm_tis_spi_probe(struct spi_device *dev)
--
2.6.6
[toc] | [prev] | [next] | [standalone]
| From | Dmitry Torokhov <dtor@chromium.org> |
|---|---|
| Date | 2016-07-29 01:00 +0200 |
| Subject | Re: [PATCH v3 2/2] tpm_tis_spi: add max xfer size |
| Message-ID | <s02rw-4gN-7@gated-at.bofh.it> |
| In reply to | #1451707 |
On Wed, Jul 27, 2016 at 08:49:57PM -0700, Andrey Pronin wrote:
> Reject burstcounts larger than 64 bytes reported by tpm.
> SPI Hardware Protocol defined in section 6.4 of TCG PTP
> Spec supports up to 64 bytes of data in a transaction.
>
> Signed-off-by: Andrey Pronin <apronin@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
> ---
> drivers/char/tpm/tpm_tis_spi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
> index dbaad9c..b103373 100644
> --- a/drivers/char/tpm/tpm_tis_spi.c
> +++ b/drivers/char/tpm/tpm_tis_spi.c
> @@ -206,6 +206,7 @@ static const struct tpm_tis_phy_ops tpm_spi_phy_ops = {
> .read16 = tpm_tis_spi_read16,
> .read32 = tpm_tis_spi_read32,
> .write32 = tpm_tis_spi_write32,
> + .max_xfer_size = MAX_SPI_FRAMESIZE,
> };
>
> static int tpm_tis_spi_probe(struct spi_device *dev)
> --
> 2.6.6
>
--
Dmitry
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2016-08-09 10:20 +0200 |
| Subject | Re: [PATCH v3 2/2] tpm_tis_spi: add max xfer size |
| Message-ID | <s4aqt-51O-13@gated-at.bofh.it> |
| In reply to | #1452159 |
On Thu, Jul 28, 2016 at 03:53:16PM -0700, Dmitry Torokhov wrote:
> On Wed, Jul 27, 2016 at 08:49:57PM -0700, Andrey Pronin wrote:
> > Reject burstcounts larger than 64 bytes reported by tpm.
> > SPI Hardware Protocol defined in section 6.4 of TCG PTP
> > Spec supports up to 64 bytes of data in a transaction.
> >
> > Signed-off-by: Andrey Pronin <apronin@chromium.org>
>
> Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
/Jarkko
> > ---
> > drivers/char/tpm/tpm_tis_spi.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/char/tpm/tpm_tis_spi.c b/drivers/char/tpm/tpm_tis_spi.c
> > index dbaad9c..b103373 100644
> > --- a/drivers/char/tpm/tpm_tis_spi.c
> > +++ b/drivers/char/tpm/tpm_tis_spi.c
> > @@ -206,6 +206,7 @@ static const struct tpm_tis_phy_ops tpm_spi_phy_ops = {
> > .read16 = tpm_tis_spi_read16,
> > .read32 = tpm_tis_spi_read32,
> > .write32 = tpm_tis_spi_write32,
> > + .max_xfer_size = MAX_SPI_FRAMESIZE,
> > };
> >
> > static int tpm_tis_spi_probe(struct spi_device *dev)
> > --
> > 2.6.6
> >
>
> --
> Dmitry
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web