From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754245AbdBASkb (ORCPT ); Wed, 1 Feb 2017 13:40:31 -0500 Received: from mga02.intel.com ([134.134.136.20]:30251 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752972AbdBASk2 (ORCPT ); Wed, 1 Feb 2017 13:40:28 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,321,1477983600"; d="scan'208";a="1101753167" Date: Wed, 1 Feb 2017 20:40:06 +0200 From: Jarkko Sakkinen To: tpmdd-devel@lists.sourceforge.net Cc: linux-security-module@vger.kernel.org, Peter Huewe , Marcel Selhorst , Jason Gunthorpe , open list Subject: Re: [PATCH] tpm: fix type issues in tpm_getcap() Message-ID: <20170201184006.p6iqgshipdcfuovo@intel.com> References: <20170201175347.2035-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170201175347.2035-1-jarkko.sakkinen@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.6.2-neo (2016-08-21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 01, 2017 at 07:53:47PM +0200, Jarkko Sakkinen wrote: > There are two type issues associated with tpm_getcap(). > > You must not do arithmetic with __be32 or __le32 types because sometimes > it results incorrect results. Calculations must be done only with data > that is in CPU byte order. This commit migrates tpm_getcap() to struct > tpm_buf in order to sort out these issues. > > The second issue is with struct cap_t as the size of the type bool is > assumed to be one byte. This commit sorts out the issue by changing the > type to u8. > > Signed-off-by: Jarkko Sakkinen > --- > v2: > - Use struct tpm_buf. > - Merge the type change of 'owned' to this patch. > drivers/char/tpm/tpm-interface.c | 33 ++++++++++++++++++--------------- > drivers/char/tpm/tpm.h | 15 +-------------- > 2 files changed, 19 insertions(+), 29 deletions(-) > > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c > index 423938e..7af1e8c 100644 > --- a/drivers/char/tpm/tpm-interface.c > +++ b/drivers/char/tpm/tpm-interface.c > @@ -480,31 +480,34 @@ static const struct tpm_input_header tpm_getcap_header = { > ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap, > const char *desc, size_t min_cap_length) Last two parameters are in the wrong order (different than tpm_transmit_cmd). /Jarkko