From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751621AbdAWVrr (ORCPT ); Mon, 23 Jan 2017 16:47:47 -0500 Received: from mga03.intel.com ([134.134.136.65]:49813 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751082AbdAWVrp (ORCPT ); Mon, 23 Jan 2017 16:47:45 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,275,1477983600"; d="scan'208";a="57320575" Date: Mon, 23 Jan 2017 23:44:35 +0200 From: Jarkko Sakkinen To: Stefan Berger Cc: tpmdd-devel@lists.sourceforge.net, open list , linux-security-module@vger.kernel.org Subject: Re: [tpmdd-devel] [PATCH RFC v4 1/5] tpm: validate TPM 2.0 commands Message-ID: <20170123214435.6aa75rgy6b3gdfpv@intel.com> References: <20170122234438.12102-1-jarkko.sakkinen@linux.intel.com> <20170122234438.12102-2-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Sun, Jan 22, 2017 at 09:02:17PM -0500, Stefan Berger wrote: > On 01/22/2017 06:44 PM, Jarkko Sakkinen wrote: > > @@ -1025,8 +1029,60 @@ int tpm2_auto_startup(struct tpm_chip *chip) > > } > > } > > > > + rc = tpm2_get_tpm_pt(chip, TPM_PT_TOTAL_COMMANDS, &nr_commands, NULL); > > + if (rc) > > + goto out; > > + > > + /* sanity check */ > > + if (nr_commands > INT_MAX) { > > + rc = -E2BIG; > > + goto out; > > + } > > + > > + chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands, > > + GFP_KERNEL); > > + > > + rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY); > > + if (rc) > > + goto out; > > + > > + tpm_buf_append_u32(&buf, TPM2_CAP_COMMANDS); > > + tpm_buf_append_u32(&buf, TPM2_CC_FIRST); > > + tpm_buf_append_u32(&buf, nr_commands); > > + > > + rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, 0, 0, NULL); > > You should probably pass the min_rsp_body_size as 5 + 4 + nr_commands * 4 Thanks. I'll put 9 + 4 * nr_commands as the expected size. /Jarkko