Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2973056ybh; Mon, 5 Aug 2019 09:49:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzk5RZt27LRYv9PLV/6JXKzX3BQsWzf2fFDk4ytta3by5X8t4HpTC0Z+MqtlWLvrbHQhrZ1 X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr19197589pjz.117.1565023793889; Mon, 05 Aug 2019 09:49:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565023793; cv=none; d=google.com; s=arc-20160816; b=ZgvbU3dvJxhtMROuNaVfWM/pVf+dMxn+XmGpzF8Wfue874Ph5AQMDeXlicolZxEFSz HwLMuIfz2djHGMXsefS8OwgWXNxl/IA8uIFfW8XGiqC7wuCgzFgiztD2AL/adk5acRTh M9bP77rTDBf5gLxohvqiXdK7jXeiIPyllSZ1UuMaY7EoOn1aUu6ynl5CTgd1DXmlvnZ0 oLWQ7OTNj9HzHuBaUMAf1n+f5LNLNEGHoi/hSvymzE6NBhK26anBigtI6se6HCFi+5UM 2490Ov5Wf0Fv62qBSj3oIkcE3tRu6Ibz34OCbEVg18yFC7tdcNqv6rK3/Za5Z6BR4yVA Fx5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=fBTSIhvA0Lk5VcBXqANvIdbJCeGDl0xfApFAVb6NviA=; b=VIGZShoJYYcNbrNWSeIrANRInUBLe5ACwbqwqd74hr97Td+W7mZ/lHmcv08as6KbV/ kltrel+V4u3xjwjwmtFkQlCouy9wE5OhCNwkZSza/1PSbIw6QzWCet0zMi0hmU/Tso7G rHEO/2TwwNZpFiCQHCb7ARmC1m/hxZs8wJegzr/2AfqLPdAiTOQdf3U+O+wddsIls3Tq CZLmrWc0hUg1xws/a5qDZyi5j3SPMyMtBRH91E+d6i3Ida/rQcHV9Gmxm79urJ55kbWX K0pOuPa2xsnPRZUQlFF5bkbixnIzPckn3t3uk+Nu2Zyxw6lm8HVeDfb9gSj4XGSRokoe Eabg== 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 m10si12715926pjl.77.2019.08.05.09.49.38; Mon, 05 Aug 2019 09:49:53 -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 S1729901AbfHEQs2 (ORCPT + 99 others); Mon, 5 Aug 2019 12:48:28 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:33116 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728800AbfHEQs1 (ORCPT ); Mon, 5 Aug 2019 12:48:27 -0400 Received: from LHREML711-CAH.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id D46F277450129614A781; Mon, 5 Aug 2019 17:48:25 +0100 (IST) Received: from roberto-HP-EliteDesk-800-G2-DM-65W.huawei.com (10.204.65.154) by smtpsuk.huawei.com (10.201.108.34) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 5 Aug 2019 17:48:18 +0100 From: Roberto Sassu To: , , , , CC: , , , , , , , Roberto Sassu Subject: [PATCH v3] KEYS: trusted: allow module init if TPM is inactive or deactivated Date: Mon, 5 Aug 2019 18:44:27 +0200 Message-ID: <20190805164427.17408-1-roberto.sassu@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.204.65.154] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit c78719203fc6 ("KEYS: trusted: allow trusted.ko to initialize w/o a TPM") allows the trusted module to be loaded even if a TPM is not found, to avoid module dependency problems. However, trusted module initialization can still fail if the TPM is inactive or deactivated. tpm_get_random() returns an error. This patch removes the call to tpm_get_random() and instead extends the PCR specified by the user with zeros. The security of this alternative is equivalent to the previous one, as either option prevents with a PCR update unsealing and misuse of sealed data by a user space process. Even if a PCR is extended with zeros, instead of random data, it is still computationally infeasible to find a value as input for a new PCR extend operation, to obtain again the PCR value that would allow unsealing. Fixes: 240730437deb ("KEYS: trusted: explicitly use tpm_chip structure...") Signed-off-by: Roberto Sassu Reviewed-by: Tyler Hicks Suggested-by: Mimi Zohar --- security/keys/trusted.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/security/keys/trusted.c b/security/keys/trusted.c index 9a94672e7adc..ade699131065 100644 --- a/security/keys/trusted.c +++ b/security/keys/trusted.c @@ -1228,24 +1228,11 @@ static int __init trusted_shash_alloc(void) static int __init init_digests(void) { - u8 digest[TPM_MAX_DIGEST_SIZE]; - int ret; - int i; - - ret = tpm_get_random(chip, digest, TPM_MAX_DIGEST_SIZE); - if (ret < 0) - return ret; - if (ret < TPM_MAX_DIGEST_SIZE) - return -EFAULT; - digests = kcalloc(chip->nr_allocated_banks, sizeof(*digests), GFP_KERNEL); if (!digests) return -ENOMEM; - for (i = 0; i < chip->nr_allocated_banks; i++) - memcpy(digests[i].digest, digest, TPM_MAX_DIGEST_SIZE); - return 0; } -- 2.17.1