From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752271AbcGODRH (ORCPT ); Thu, 14 Jul 2016 23:17:07 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:35246 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751279AbcGODRE (ORCPT ); Thu, 14 Jul 2016 23:17:04 -0400 Date: Thu, 14 Jul 2016 20:17:01 -0700 From: Andrey Pronin To: Jason Gunthorpe Cc: Jarkko Sakkinen , Peter Huewe , Marcel Selhorst , tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, groeck@chromium.org, smbarber@chromium.org, dianders@chromium.org Subject: Re: [PATCH 2/2] tpm: fix byte-order for the value read by tpm2_get_tpm_pt Message-ID: <20160715031701.GA25406@apronin> References: <1468544838-9990-1-git-send-email-apronin@chromium.org> <1468544838-9990-3-git-send-email-apronin@chromium.org> <20160715031046.GC9347@obsidianresearch.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160715031046.GC9347@obsidianresearch.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 14, 2016 at 09:10:46PM -0600, Jason Gunthorpe wrote: > On Thu, Jul 14, 2016 at 06:07:18PM -0700, Andrey Pronin wrote: > > Change-Id: I7d71cd379b1a3b7659d20a1b6008216762596590 > > Signed-off-by: Andrey Pronin > > drivers/char/tpm/tpm2-cmd.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c > > index a1673dc..a88b31e 100644 > > +++ b/drivers/char/tpm/tpm2-cmd.c > > @@ -703,7 +703,7 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value, > > > > rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), desc); > > if (!rc) > > - *value = cmd.params.get_tpm_pt_out.value; > > + *value = be32_to_cpu(cmd.params.get_tpm_pt_out.value); > > Huh. > > Jarkko: Are you running sparse on the tpm stuff? The annotations look > right here, sparse should have complained on this? Andrey, did sparse > complain here or is there something more serious wrong as well?? > > Reviewed-by: Jason Gunthorpe > > Jason No, this is not sparse complaining. I tried using tpm2_get_tpm_pt() to read permanent flags and discovered that it was missing byte-ordering conversion. The only place tpm2_get_tpm_pt() was used before was in tpm2_gen_interrupt, which discarded the result. So, nobody noticed, I guess. Andrey