From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964826AbdEOLgI (ORCPT ); Mon, 15 May 2017 07:36:08 -0400 Received: from mga05.intel.com ([192.55.52.43]:46957 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934164AbdEOLgG (ORCPT ); Mon, 15 May 2017 07:36:06 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,344,1491289200"; d="scan'208";a="100742790" Date: Mon, 15 May 2017 14:36:02 +0300 From: Jarkko Sakkinen To: Jason Gunthorpe Cc: linux-security-module@vger.kernel.org, tpmdd-devel@lists.sourceforge.net, open list Subject: Re: [tpmdd-devel] [PATCH] tpm: fix byte order related arithmetic inconsistency in tpm_getcap() Message-ID: <20170515113602.2jypna4keatq73qy@intel.com> References: <20170507175002.9558-1-jarkko.sakkinen@linux.intel.com> <20170509141353.klo7lilef4qiqfoc@intel.com> <20170509151308.GA13586@obsidianresearch.com> <20170510123458.fh3ef3c55y2wiu35@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170510123458.fh3ef3c55y2wiu35@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > > > 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