tpmdd-devel Archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Jason Gunthorpe
	<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	open list <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] tpm: fix byte order related arithmetic inconsistency in tpm_getcap()
Date: Wed, 24 May 2017 09:59:50 -0700	[thread overview]
Message-ID: <20170524165950.mdaqortjrdhtabke@intel.com> (raw)
In-Reply-To: <20170515153934.GB3433-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

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-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > > > > > 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

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

      parent reply	other threads:[~2017-05-24 16:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-07 17:50 [PATCH] tpm: fix byte order related arithmetic inconsistency in tpm_getcap() Jarkko Sakkinen
2017-05-09 14:13 ` Jarkko Sakkinen
2017-05-09 15:13   ` Jason Gunthorpe
2017-05-10 12:34     ` Jarkko Sakkinen
2017-05-10 23:41       ` Luc Van Oostenryck
2017-05-11 10:16         ` Jarkko Sakkinen
2017-05-15 11:36       ` [tpmdd-devel] " Jarkko Sakkinen
2017-05-15 15:39         ` Jason Gunthorpe
     [not found]           ` <20170515153934.GB3433-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-05-24 16:59             ` Jarkko Sakkinen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170524165950.mdaqortjrdhtabke@intel.com \
    --to=jarkko.sakkinen-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).