Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp876871img; Thu, 21 Mar 2019 10:47:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbR7TYsSDQf6PNnS8CyKPpPAkulJw5wDUvl3EmvfbeH89mfN59IG5wu3otBd2/YndCwfHr X-Received: by 2002:a62:e904:: with SMTP id j4mr4492312pfh.174.1553190467084; Thu, 21 Mar 2019 10:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553190467; cv=none; d=google.com; s=arc-20160816; b=uAUrPxDeoweRGyGB46/sp70YNY91Ky3j/nTYWebQaYfMf30oxYk4TLUKUuM9O5OzGJ 7kzrv+yGMmkf2osx/emE7rwy2bxpQS8PiW7xH6r7ghYQnGDZsDFo3St6tQ9TQaAf2UFZ SDhTSkoJUxqg2sqSSG4l6nm5YJCq25WxZyI0c4mtELMmdhjam5ceeK4cwrNqWsZmDAH2 B4xowjlLvt+kX3iRrKDTOkyqLuS9D0C8GMIapQ9bLW+ciO07VECN0vAlSUXgpRXOlBHA 7PH0ZSdy1IVoGSyl6FQv5BWUtXLLjXGjRINuyaueh1F1pG/xGwpbqn8/Yyk5mLO40bsO /2Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=3SpMTAttdq8bL6t0Ez9oLLQ6VaDA7d8Ti9MRElCqggw=; b=fulfup4iC0CKfqznvExedZHxDAVo/MYI/Lu8Bnvry11RsVUggJ4OAUxF2hBJofBJLH cVmdEW4BuurwZkVjj/As4uyNU//F/+Lj+iVPGkq0uSVjMvEHe+zgRyRgsKmRlNeR5Lqo vy9okidapqTBFfyqq/Lk8WjPUEitcbLHraHCeoyMEqSXCdp/CFBk6yAu59CZkQIl+Ijy NWqtdu1zJbaD4cpoH+E3dG84BO40byEDIiULnv0F99i8uKEq3zzOknM/leBMeFXFIWGx oWCs4KlX7s+iMjx7NbCjew8lue2S3U86BAL6f8hsHdEzoFLgp28IcLi72uZMeHIzQHkf 0Bdg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e68si4698777pgc.552.2019.03.21.10.47.29; Thu, 21 Mar 2019 10:47:47 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728846AbfCURqF (ORCPT + 99 others); Thu, 21 Mar 2019 13:46:05 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:32911 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728766AbfCURp6 (ORCPT ); Thu, 21 Mar 2019 13:45:58 -0400 Received: from LHREML711-CAH.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id 34F6F9CFE424EED2123A; Thu, 21 Mar 2019 17:45:51 +0000 (GMT) Received: from [10.204.65.148] (10.204.65.148) by smtpsuk.huawei.com (10.201.108.34) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 21 Mar 2019 17:45:43 +0000 Subject: Re: [PATCH] security/keys/trusted: Allow operation without hardware TPM To: Dan Williams , Jarkko Sakkinen CC: James Bottomley , Mimi Zohar , David Howells , , linux-nvdimm , Linux Kernel Mailing List , Silviu Vlasceanu References: <155295271345.1945351.6465460744078693578.stgit@dwillia2-desk3.amr.corp.intel.com> <20190321135451.GD4603@linux.intel.com> <809e827b-fdbe-fbb8-8acf-2878ae9f7777@huawei.com> From: Roberto Sassu Message-ID: Date: Thu, 21 Mar 2019 18:45:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.204.65.148] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Thanks Roberto -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Jian LI, Yanli SHI