Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp471337ima; Fri, 1 Feb 2019 06:14:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN4rXDbf9O2kuFpvBDqw994y2Fa5z3sLmE/JGnd+qJLcmOQfJMdJ1pPqKp9zo/vabwduJyMS X-Received: by 2002:a63:9501:: with SMTP id p1mr35842797pgd.149.1549030451786; Fri, 01 Feb 2019 06:14:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549030451; cv=none; d=google.com; s=arc-20160816; b=Te1XHEw4FEn8hk2usVNM5uy0X/BwGGQoG8nM8nAnbq/MAEUgRakZSYxdNAlQ2fzLHP p2ETNvUWHxW4lnII0xtlqbw9e/TM4hwVEHeGlaUuXx7Q89nYJo1htcv/piMSbZO/HfQu tIXZb3LwA1ONCyDtL6JrAAIfkW+mu5zZ7xsN3z567ORmWubQ96mxOqM3czzjNRE6dWJh /HhoMi883f4Ra+n8tFq5xfJSf11PqY7X40fd16A1bCn7amvSFfltpmyR8CGBqbVfVP58 HFCyYVXEbtCbK6kUTR6wjetNGurgD2lMVbpYdlzHUIyg1i1wEgOsP3VAcBBks/0S5W0L efpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ydV68KF9BodNl147jznJuY2u3YnbUeF/SvZYZtuSnSI=; b=E2oXxMvTP9QKFVbbEgH3F951F9kABHsFYZquI87vDP2cgg5J85biTtX6KZMwaOGgRJ Glyyotl5Usx81spj1bOwHinmS6xbtHkQ8Re4oQtZmWQTARGqIqpx1Qj37e2SRthqydAr /tDNWuTRomtceY/YGHfYYoPvLIGFhXjFdr4zbZ++eXCjRnUeNnEXAgWTwqzViZpUFQD8 DUHzrmtpY2IXsZZnL5AYEZxMgYQL8zGiST14oCcf42hBcXdCHcJw7UkaOnOqBHkRg+O4 Dzq8r8AdZi0vH2V60+SHmPF8tpfxUGqxR61Kb2Hynezx+7sacKTqXWyvZcQGffP+aAEJ OsRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h191si6972939pgc.302.2019.02.01.06.13.32; Fri, 01 Feb 2019 06:14:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729448AbfBANe4 (ORCPT + 99 others); Fri, 1 Feb 2019 08:34:56 -0500 Received: from mga02.intel.com ([134.134.136.20]:5975 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbfBANe4 (ORCPT ); Fri, 1 Feb 2019 08:34:56 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2019 05:34:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,548,1539673200"; d="scan'208";a="135058337" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.172]) by orsmga001.jf.intel.com with ESMTP; 01 Feb 2019 05:34:51 -0800 Date: Fri, 1 Feb 2019 15:34:51 +0200 From: Jarkko Sakkinen To: Roberto Sassu Cc: zohar@linux.ibm.com, david.safford@ge.com, monty.wiseman@ge.com, matthewgarrett@google.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, silviu.vlasceanu@huawei.com Subject: Re: [PATCH v9 1/6] tpm: dynamically allocate the allocated_banks array Message-ID: <20190201133451.GA17861@linux.intel.com> References: <20190201100641.26936-1-roberto.sassu@huawei.com> <20190201100641.26936-2-roberto.sassu@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190201100641.26936-2-roberto.sassu@huawei.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 01, 2019 at 11:06:36AM +0100, Roberto Sassu wrote: > This patch renames active_banks (member of tpm_chip) to allocated_banks, > stores the number of allocated PCR banks in nr_allocated_banks (new member > of tpm_chip), and replaces the static array with a pointer to a dynamically > allocated array. > > tpm2_get_pcr_allocation() determines if a PCR bank is allocated by checking > the mask in the TPML_PCR_SELECTION structure returned by the TPM for > TPM2_Get_Capability(). If a bank is not allocated, the TPM returns that > bank in TPML_PCR_SELECTION, with all bits in the mask set to zero. In this > case, the bank is not included in chip->allocated_banks, to avoid that TPM > driver users unnecessarily calculate a digest for that bank. > > One PCR bank with algorithm set to SHA1 is always allocated for TPM 1.x. > > As a consequence of the introduction of nr_allocated_banks, > tpm_pcr_extend() does not check anymore if the algorithm stored in tpm_chip > is equal to zero. > > Signed-off-by: Roberto Sassu > Tested-by: Jarkko Sakkinen Reviewed-by: Jarkko Sakkinen /Jarkko