Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp476750imu; Thu, 8 Nov 2018 10:58:18 -0800 (PST) X-Google-Smtp-Source: AJdET5etZgzK8o/fDwcecrXYysXC4kFiWdmp/Q1ki8vjok+lsrzy7NicBRhdq2zKoPmuDU2pwg5R X-Received: by 2002:a63:f047:: with SMTP id s7mr4674810pgj.441.1541703498406; Thu, 08 Nov 2018 10:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541703498; cv=none; d=google.com; s=arc-20160816; b=nFc8zlyMB0HjJ7/3CiF/23olvurDG0itF6KuYkGUM3xXfYO52OTpAiOatgPpFPMY/L ofRuu2fHUHrHjDCPuAfRkaPnjPPtpN+KxKgLd3o8ZCb5toVxG6LmBYI/IpwnPkRmeR+3 N7eQKjmQOjhqlkQsMHzMBOgrFViYN7yzyZydhvcYOGVssUMpdX4zS7LaY6fk7uHW5VwC naZpARKypFQFYpRuZfXnkoFizwdABEb9vnv/8dQa4CgO1kRletaMElUljh4Qi3VPwl/d w95jXq4aidUepoGpTdSM6pdZYWPqepgWUVb7gtRthrYovocNs53AwePb4ZcIOaACxMnG SiQw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=EdtSvC+01t1cn19VrTDzEIG2lE629uuUlK1LmOYdnpU=; b=wDnmvnwcZ5cYrOuyzrkTV6iVwDNu4ItlfjLQr+LG7Z69KjF7IQHX9yDCEXunFkn3hb qncsDhckEN0JGayUAoopxB5+bEuWJ02sO7lk8XnAiXR24r366Jj8tfowUmg8XhmAhBtf anHZR2ZCld40xvaCTscsVUzT0PhJKQsukZ3VWcZc9b8Bn+ujAIpYZM8zFmtMPyFlUurR Y6qG9sXsgN74CDcGTBiZek8ns28UHsl00dH48gDM3LtHljU7FBXIBBQlV8Crb+EeNYoe XMjmswRZHr3zWnfQvlW1P60dgRsgW1tV1w7z4k+NxdoreBBCrS74AgeegpD9Ewo6hdYO 7r5g== 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 j185-v6si5255732pfc.186.2018.11.08.10.58.01; Thu, 08 Nov 2018 10:58:18 -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 S1727080AbeKIEeY (ORCPT + 99 others); Thu, 8 Nov 2018 23:34:24 -0500 Received: from mga05.intel.com ([192.55.52.43]:50651 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726751AbeKIEeY (ORCPT ); Thu, 8 Nov 2018 23:34:24 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Nov 2018 10:57:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,480,1534834800"; d="scan'208";a="279494759" Received: from smartikx-mobl2.ger.corp.intel.com (HELO localhost) ([10.249.254.135]) by fmsmga006.fm.intel.com with ESMTP; 08 Nov 2018 10:57:30 -0800 Date: Thu, 8 Nov 2018 20:57:29 +0200 From: Jarkko Sakkinen To: Mimi Zohar Cc: Nayna Jain , Roberto Sassu , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, silviu.vlasceanu@huawei.com, Ken Goldman , Kenneth Goldman Subject: Re: [PATCH v4 1/6] tpm: dynamically allocate active_banks array Message-ID: <20181108185729.GB20608@linux.intel.com> References: <20181106150159.1136-1-roberto.sassu@huawei.com> <20181106150159.1136-2-roberto.sassu@huawei.com> <98482eee-6e91-1666-1ce2-cfa94a33efc2@linux.ibm.com> <086944ab-dd56-5522-af26-e9bb545556fd@linux.ibm.com> <20181108152124.GE14072@linux.intel.com> <1541690993.4502.26.camel@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1541690993.4502.26.camel@linux.ibm.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 Thu, Nov 08, 2018 at 10:29:53AM -0500, Mimi Zohar wrote: > On Thu, 2018-11-08 at 17:21 +0200, Jarkko Sakkinen wrote: > > On Thu, Nov 08, 2018 at 07:20:51PM +0530, Nayna Jain wrote: > > > Based on a discussion with Ken, the count in the TPML_PCR_SELECTION returns > > > the number of possible algorithms supported. In the example below, two > > > possible algorithms - SHA1 and SHA256 - are returned. > > > > > > # /usr/local/bin/tssgetcapability -cap 5 > > > 2 PCR selections > > > ????hash TPM_ALG_SHA1 > > > ????TPMS_PCR_SELECTION length 3 > > > ????ff ff ff > > > ????hash TPM_ALG_SHA256 > > > ????TPMS_PCR_SELECTION length 3 > > > ????00 00 00 > > > > > > The pcr_select fields - "ff ff ff" and "00 00 00" - are bit masks for the > > > enabled PCRs. The SHA1 bank is enabled for all PCRs (0-23), while the SHA256 > > > bank is not enabled. > > > > > > The current code works, but it unnecessarily extends some banks. Instead of > > > basing the number of active banks on the number of algorithms returned, it > > > should be based on the pcr_select field. > > > > > > ?? - Mimi & Nayna > > > > I would just allocate array of the size of possible banks and grow > > nr_active_banks for active algorithms to keep the code simple because > > we are talking about insignificant amount of wasted space (might be > > even zero bytes given how kernel allocators works)> > > That's fine. ?Remember the memory is just one concern, but the other > concerns are the performance of calculating the unneeded hash and the > TPM performance of including it in the PCR extend. The driver would initialize only as many entries as are active array and set nr_active_banks accordingly. /Jarkko