Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755646AbdC1M4F (ORCPT ); Tue, 28 Mar 2017 08:56:05 -0400 Received: from mga09.intel.com ([134.134.136.24]:29814 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755487AbdC1Mz5 (ORCPT ); Tue, 28 Mar 2017 08:55:57 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,236,1486454400"; d="scan'208";a="839278968" Date: Tue, 28 Mar 2017 15:47:30 +0300 From: Jarkko Sakkinen To: Alexander.Steffen@infineon.com Cc: tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, peterhuewe@gmx.de, tpmdd@selhorst.net, jgunthorpe@obsidianresearch.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tpm: do handle area size validation only when TPM space used Message-ID: <20170328124730.4adgqyzglbkjksdi@intel.com> References: <20170326210815.21252-1-jarkko.sakkinen@iki.fi> <20170328102453.hvyc3a4vmrk3lyzu@intel.com> <93b2b783656c400ebea13a9eeec48097@MUCSE603.infineon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <93b2b783656c400ebea13a9eeec48097@MUCSE603.infineon.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 Content-Length: 2525 Lines: 75 On Tue, Mar 28, 2017 at 11:27:53AM +0000, Alexander.Steffen@infineon.com wrote: > Yes, this fixes the issue for me. Thanks. > > Alexander Great. I will squash this to the infrastructure patch. Thank you. /Jarkko > > -----Original Message----- > > From: Jarkko Sakkinen [mailto:jarkko.sakkinen@linux.intel.com] > > Sent: Tuesday, March 28, 2017 12:25 PM > > To: Steffen Alexander (IFAG CCS ESS D SW A) > > Cc: tpmdd-devel@lists.sourceforge.net; linux-security- > > module@vger.kernel.org; Peter Huewe; Marcel Selhorst; Jason Gunthorpe; > > open list > > Subject: Re: [PATCH] tpm: do handle area size validation only when TPM > > space used > > > > So do you need this or not? > > > > /Jarkko > > > > On Mon, Mar 27, 2017 at 12:08:15AM +0300, Jarkko Sakkinen wrote: > > > In order to not cause backwards compatibility issues with > > > /dev/tpm0 disable handle area size validation if tpm_transmit is not > > > called with a TPM space. > > > > > > Signed-off-by: Jarkko Sakkinen > > > --- > > > drivers/char/tpm/tpm-interface.c | 9 +++++++-- > > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/char/tpm/tpm-interface.c > > > b/drivers/char/tpm/tpm-interface.c > > > index bf0c3fa..158c1db 100644 > > > --- a/drivers/char/tpm/tpm-interface.c > > > +++ b/drivers/char/tpm/tpm-interface.c > > > @@ -328,7 +328,9 @@ unsigned long tpm_calc_ordinal_duration(struct > > > tpm_chip *chip, } EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration); > > > > > > -static bool tpm_validate_command(struct tpm_chip *chip, const u8 > > > *cmd, > > > +static bool tpm_validate_command(struct tpm_chip *chip, > > > + struct tpm_space *space, > > > + const u8 *cmd, > > > size_t len) > > > { > > > const struct tpm_input_header *header = (const void *)cmd; @@ - > > 340,6 > > > +342,9 @@ static bool tpm_validate_command(struct tpm_chip *chip, > > const u8 *cmd, > > > if (len < TPM_HEADER_SIZE) > > > return false; > > > > > > + if (!space) > > > + return true; > > > + > > > if (chip->flags & TPM_CHIP_FLAG_TPM2 && chip->nr_commands) { > > > cc = be32_to_cpu(header->ordinal); > > > > > > @@ -386,7 +391,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct > > tpm_space *space, > > > unsigned long stop; > > > bool need_locality; > > > > > > - if (!tpm_validate_command(chip, buf, bufsiz)) > > > + if (!tpm_validate_command(chip, space, buf, bufsiz)) > > > return -EINVAL; > > > > > > if (bufsiz > TPM_BUFSIZE) > > > -- > > > 2.9.3 > > > >