Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1641573 > unrolled thread

Re: [tpmdd-devel] [PATCH] tpm: fix byte order related arithmetic inconsistency in tpm_getcap()

Started byJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
First post2017-05-15 13:40 +0200
Last post2017-05-24 19:10 +0200
Articles 3 — 2 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.


Contents

  Re: [tpmdd-devel] [PATCH] tpm: fix byte order related arithmetic  inconsistency in tpm_getcap() Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-05-15 13:40 +0200
    Re: [tpmdd-devel] [PATCH] tpm: fix byte order related arithmetic  inconsistency in tpm_getcap() Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-05-15 17:40 +0200
      Re: [tpmdd-devel] [PATCH] tpm: fix byte order related arithmetic  inconsistency in tpm_getcap() Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-05-24 19:10 +0200

#1641573 — Re: [tpmdd-devel] [PATCH] tpm: fix byte order related arithmetic inconsistency in tpm_getcap()

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2017-05-15 13:40 +0200
SubjectRe: [tpmdd-devel] [PATCH] tpm: fix byte order related arithmetic inconsistency in tpm_getcap()
Message-ID<tHmw1-7yP-1@gated-at.bofh.it>
On Wed, May 10, 2017 at 03:34:58PM +0300, Jarkko Sakkinen wrote:
> On Tue, May 09, 2017 at 09:13:08AM -0600, Jason Gunthorpe wrote:
> > On Tue, May 09, 2017 at 05:13:53PM +0300, Jarkko Sakkinen wrote:
> > > On Sun, May 07, 2017 at 08:50:02PM +0300, Jarkko Sakkinen wrote:
> > > > You should not do arithmetic with __be32 or __le32 types because
> > > > sometimes it results incorrect results. Calculations must be done only
> > > > with integers that are in in the CPU byte order. This commit migrates
> > > > tpm_getcap() to struct tpm_buf in order to sort out these issues.
> > > > 
> > > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > Now this should work as Robertos patches move byte order conversion
> > > > where it should be. Sadly I'm out of reach to my Dell E6400 laptop
> > > > that I use for TPM 1.2 testing.
> > > >  drivers/char/tpm/tpm-interface.c | 30 ++++++++++++++++--------------
> > > >  drivers/char/tpm/tpm.h           | 13 -------------
> > > >  2 files changed, 16 insertions(+), 27 deletions(-)
> > > 
> > > I've now tested this with TPM 1.2. Any complains?
> > 
> > Seems reasonable, but which linke had the problematic arithmetic?
> > 
> > Jason
> 
> Arithmetic should work but it's not a good practice to do additions,
> substractions or multiplications in any other byte order than the CPU
> byte order.
> 
> sparse also complains about this.

Can I get your Reviewed-by for this one?

/Jarkko

[toc] | [next] | [standalone]


#1641823

FromJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Date2017-05-15 17:40 +0200
Message-ID<tHqgh-1xf-19@gated-at.bofh.it>
In reply to#1641573
On Mon, May 15, 2017 at 02:36:02PM +0300, Jarkko Sakkinen wrote:
> On Wed, May 10, 2017 at 03:34:58PM +0300, Jarkko Sakkinen wrote:
> > On Tue, May 09, 2017 at 09:13:08AM -0600, Jason Gunthorpe wrote:
> > > On Tue, May 09, 2017 at 05:13:53PM +0300, Jarkko Sakkinen wrote:
> > > > On Sun, May 07, 2017 at 08:50:02PM +0300, Jarkko Sakkinen wrote:
> > > > > You should not do arithmetic with __be32 or __le32 types because
> > > > > sometimes it results incorrect results. Calculations must be done only
> > > > > with integers that are in in the CPU byte order. This commit migrates
> > > > > tpm_getcap() to struct tpm_buf in order to sort out these issues.
> > > > > 
> > > > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > > Now this should work as Robertos patches move byte order conversion
> > > > > where it should be. Sadly I'm out of reach to my Dell E6400 laptop
> > > > > that I use for TPM 1.2 testing.
> > > > >  drivers/char/tpm/tpm-interface.c | 30 ++++++++++++++++--------------
> > > > >  drivers/char/tpm/tpm.h           | 13 -------------
> > > > >  2 files changed, 16 insertions(+), 27 deletions(-)
> > > > 
> > > > I've now tested this with TPM 1.2. Any complains?
> > > 
> > > Seems reasonable, but which linke had the problematic arithmetic?
> > > 
> > > Jason
> > 
> > Arithmetic should work but it's not a good practice to do additions,
> > substractions or multiplications in any other byte order than the CPU
> > byte order.
> > 
> > sparse also complains about this.
> 
> Can I get your Reviewed-by for this one?

Sure, but I'm still wondering what the sparse warning was?

Jason

[toc] | [prev] | [next] | [standalone]


#1649774

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2017-05-24 19:10 +0200
Message-ID<tKHXk-58r-11@gated-at.bofh.it>
In reply to#1641823
On Mon, May 15, 2017 at 09:39:34AM -0600, Jason Gunthorpe wrote:
> On Mon, May 15, 2017 at 02:36:02PM +0300, Jarkko Sakkinen wrote:
> > On Wed, May 10, 2017 at 03:34:58PM +0300, Jarkko Sakkinen wrote:
> > > On Tue, May 09, 2017 at 09:13:08AM -0600, Jason Gunthorpe wrote:
> > > > On Tue, May 09, 2017 at 05:13:53PM +0300, Jarkko Sakkinen wrote:
> > > > > On Sun, May 07, 2017 at 08:50:02PM +0300, Jarkko Sakkinen wrote:
> > > > > > You should not do arithmetic with __be32 or __le32 types because
> > > > > > sometimes it results incorrect results. Calculations must be done only
> > > > > > with integers that are in in the CPU byte order. This commit migrates
> > > > > > tpm_getcap() to struct tpm_buf in order to sort out these issues.
> > > > > > 
> > > > > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > > > > > Now this should work as Robertos patches move byte order conversion
> > > > > > where it should be. Sadly I'm out of reach to my Dell E6400 laptop
> > > > > > that I use for TPM 1.2 testing.
> > > > > >  drivers/char/tpm/tpm-interface.c | 30 ++++++++++++++++--------------
> > > > > >  drivers/char/tpm/tpm.h           | 13 -------------
> > > > > >  2 files changed, 16 insertions(+), 27 deletions(-)
> > > > > 
> > > > > I've now tested this with TPM 1.2. Any complains?
> > > > 
> > > > Seems reasonable, but which linke had the problematic arithmetic?
> > > > 
> > > > Jason
> > > 
> > > Arithmetic should work but it's not a good practice to do additions,
> > > substractions or multiplications in any other byte order than the CPU
> > > byte order.
> > > 
> > > sparse also complains about this.
> > 
> > Can I get your Reviewed-by for this one?
> 
> Sure, but I'm still wondering what the sparse warning was?
> 
> Jason

This type of errors

drivers/char/tpm//tpm-interface.c:492:42: warning: bad assignment (-=) to restricted __be32

/Jarkko

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web