Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp526654img; Fri, 22 Mar 2019 03:13:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnwC+mk6bdKdXb9mB1+S7Ch4iZk95JXBilvfn25Hh1s6HUwUwYkz6nGMaTMSfeAaJK8Jnx X-Received: by 2002:a63:e813:: with SMTP id s19mr8018190pgh.12.1553249622778; Fri, 22 Mar 2019 03:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553249622; cv=none; d=google.com; s=arc-20160816; b=NtScsqfzxUeoCKUcECMP6xaLsvxOjaaAqw4Igh7a9gNNEjDRms9qoWaa/MyRh77Ytr ZvHIMUrJOLtP0+Ykp5/HwEXegxBCljCDNwO89PvzVG/SglnSTV/Aoh6YRBocB50LIGIs tESM28GUkb5s6EQp3hKuKwGNdeIfg4yMPz7y4mEZkHbfVKEtsuut2zdH8rSz+hePMYvl 7aOd4eQwi4ALW12WjuAKoDJjmXuK0NfO3h0Kyq/7xu1iXsL0lxPQxiC6zq+JDUyBnSO9 sxNSSfivhhKQQ1ucz1oLc1Z2HSrXgG6/h8ecuDT9ZYIPZnCZNrf3t0uwgfMe6QHeV+W5 89CQ== 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=8LKJPaDn0zNMjWOVAtAdK/Ilu0aDCdppcDb2AivLPsE=; b=jgNzXoN6jGrm/d8CKybJiyo9cMByFJDLpUD/MBGqKlDtbk3uNzl1PDeO/bK/3nXkPy OotF3nyAb6wH6w+rLqomvYxW4WwfRMHRbl3Grs13CqeI6wLXHDQ7fjjGcBbl2dM/WvXg 4rhrwlTlyPnV62NIcKf12SvpkuwLgowFFJbMncDUYPaEFLoYVPjIGD1SvUNk4A+Z4ZV9 JknorQwYyxutj4d9Tm9AFFzzZxqbF9/6vpCv9Np2ye8+/jt82qX6Sce7VVYtusnG1yy4 1dTIgVkXMjc4ftpTYA2TPJ8jm5DpOkALMHX/L3U/fkll6ULDKeTKtsktqpKRvMC7VhKD Hh9Q== 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 196si6272675pgb.22.2019.03.22.03.13.28; Fri, 22 Mar 2019 03:13:42 -0700 (PDT) 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 S1728038AbfCVKMf (ORCPT + 99 others); Fri, 22 Mar 2019 06:12:35 -0400 Received: from mga06.intel.com ([134.134.136.31]:49211 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727858AbfCVKMf (ORCPT ); Fri, 22 Mar 2019 06:12:35 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Mar 2019 03:12:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,256,1549958400"; d="scan'208";a="124918269" Received: from vanderss-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.254.199]) by orsmga007.jf.intel.com with ESMTP; 22 Mar 2019 03:12:29 -0700 Date: Fri, 22 Mar 2019 12:12:27 +0200 From: Jarkko Sakkinen To: Roberto Sassu Cc: Dan Williams , James Bottomley , Mimi Zohar , David Howells , keyrings@vger.kernel.org, linux-nvdimm , Linux Kernel Mailing List , Silviu Vlasceanu Subject: Re: [PATCH] security/keys/trusted: Allow operation without hardware TPM Message-ID: <20190322101227.GB3122@linux.intel.com> References: <155295271345.1945351.6465460744078693578.stgit@dwillia2-desk3.amr.corp.intel.com> <20190321135451.GD4603@linux.intel.com> <809e827b-fdbe-fbb8-8acf-2878ae9f7777@huawei.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.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, Mar 21, 2019 at 06:45:47PM +0100, Roberto Sassu wrote: > On 3/21/2019 5:30 PM, Dan Williams wrote: > > On Thu, Mar 21, 2019 at 7:27 AM Roberto Sassu wrote: > > > > > > On 3/21/2019 2:54 PM, Jarkko Sakkinen wrote: > > > > On Mon, Mar 18, 2019 at 04:45:13PM -0700, Dan Williams wrote: > > > > > Rather than fail initialization of the trusted.ko module, arrange for > > > > > the module to load, but rely on trusted_instantiate() to fail > > > > > trusted-key operations. > > > > > > > > > > Fixes: 240730437deb ("KEYS: trusted: explicitly use tpm_chip structure...") > > > > > Cc: Roberto Sassu > > > > > Cc: Jarkko Sakkinen > > > > > Cc: James Bottomley > > > > > Cc: Jarkko Sakkinen > > > > > Cc: Mimi Zohar > > > > > Cc: David Howells > > > > > Signed-off-by: Dan Williams > > > > > > > > It should check for chip in each function that uses TPM now that > > > > the code does not rely on default chip. Otherwise, the semantics > > > > are kind of inconsistent. > > > > > > If no other TPM function can be used before a successful key > > > instantiate, checking for a chip only in trusted_instantiate() seems > > > sufficient. Then, the same chip will be used by all TPM functions until > > > module unloading, since we incremented the reference count. > > > > > > I would suggest to move the tpm_default_chip() and init_digests() calls > > > to trusted_instantiate() to restore the old behavior of init_trusted(). > > > > > > trusted_instantiate() should look like: > > > --- > > > if (!chip) { > > > chip = tpm_default_chip(); > > > if (!chip) > > > return -ENODEV; > > > } > > > > > > if (!digests) { > > > ret = init_digests(); > > > if (ret < 0) > > > return ret; > > > } > > > > This patch already achieves that because tpm_find_get_ops() will fail > > and cause tpm_is_tpm2() to return NULL. > > In addition, the changes I proposed would allow users to create trusted > keys if a TPM is added later. CONFIG_TRUSTED_KEYS=y and > CONFIG_TCG_TPM=m is a valid configuration. > > Jarkko, Dan's patch seems sufficient to fix the issue. He could include > the changes I proposed in his patch. What is your opinion? Agreed. /Jarkko