Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1457431ybl; Thu, 22 Aug 2019 15:06:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxecZAoV3/ZcZImotOtYwbcXeGTgE1A36no0w4ccCExatX3ZUoCIsxTNaMHj06OmMwbVIfR X-Received: by 2002:a62:f94a:: with SMTP id g10mr1492620pfm.167.1566511603106; Thu, 22 Aug 2019 15:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566511603; cv=none; d=google.com; s=arc-20160816; b=D/Tf0p6KiGSSi5NPYt0YO9d+MFu2upT8cfISqD3KCd7G3ULlm8uRjPZoJgDfOwiwMJ wDjFJb2bYil+v+92J+KTMV0QO3qgLCwiWBa7GSoyP8lgNfx35G5W4SjHdv+Ga0tX+M0t VcYH5e7rUC8sQG3/dvyzvwQTFSi924atdZGebTPxTFYOn7B6d5n2jHDMBiqSbmLfuk76 kguPrlS2sOOlfCRAfJvEbarpHZoZCKRwUgCL9BM7LBEWof9epLPO/Zf4cFTIEI85bY+x 8cQ9F0DUBcYJ2Z8hIqzuu0A/jlxfWhiOHswmyibDq2MuANlBmFpUPG/niXod/Y+Ec61N gsdg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p7fUkkhMyQQSJQd81B/9vQWzwsCg2HNMhO9oe+Rx0Lk=; b=hT67DVkukmcl2JvM5kEQQz0sMNgFHXxV71KLKjvetMB1IX14YRGOL/fYihC50xfY+J 4/bFmWP01VgAWXiixJc7yWv1r/AyHp9PpLOZL5chPPp2ec5A84oiPvfIijA6g4cT4s9m ueMXBAghO0j34PW/7vl59Au7aug2iDvO3eB4PcA6rH0gFLJUlVPlzzazvV1Yt6m8aJtQ RB20r4E32s7x5AI6VEkFb48mj9c9A4TtytF34jZvpk3sro8x6nAC1EHF5ba2+wY7uMCh FsXwZ9naKjTyym1FB/DlDBG3ma24/MUU5puClOGMHmuZOiMyRZH793QVLgH+Wp9tytcf O3Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Yh9ezz6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21si390293pgk.492.2019.08.22.15.06.26; Thu, 22 Aug 2019 15:06:43 -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; dkim=pass header.i=@kernel.org header.s=default header.b=0Yh9ezz6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390232AbfHVRIQ (ORCPT + 99 others); Thu, 22 Aug 2019 13:08:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:57564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388772AbfHVRIO (ORCPT ); Thu, 22 Aug 2019 13:08:14 -0400 Received: from sasha-vm.mshome.net (wsip-184-188-36-2.sd.sd.cox.net [184.188.36.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 292C523404; Thu, 22 Aug 2019 17:08:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566493693; bh=E+G7d0QVYHqcRsB9iKm+JSwup6AH9Ae3hpxG49tVs2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Yh9ezz6MFE5yJpTHcynLxIx/DRNLub6zrBY1tdzaKK5J2A0tsF3WVjk6w2BkB6oX R9lEkmWeh+ywyqqrSCoZh8JL2E1dAA/aUT/js25uOr/mLsVSv6soDr7ZcGUcm8wRo5 KeM+CVB6cfQSnRZw5qZW84Rst+EBvO/hYQCH6tYw= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Roberto Sassu , Tyler Hicks , Mimi Zohar , Jarkko Sakkinen , Greg Kroah-Hartman Subject: [PATCH 5.2 001/135] KEYS: trusted: allow module init if TPM is inactive or deactivated Date: Thu, 22 Aug 2019 13:05:57 -0400 Message-Id: <20190822170811.13303-2-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190822170811.13303-1-sashal@kernel.org> References: <20190822170811.13303-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.10-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.2.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.2.10-rc1 X-KernelTest-Deadline: 2019-08-24T17:07+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roberto Sassu commit 2d6c25215ab26bb009de3575faab7b685f138e92 upstream. 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. Cc: stable@vger.kernel.org Fixes: 240730437deb ("KEYS: trusted: explicitly use tpm_chip structure...") Signed-off-by: Roberto Sassu Reviewed-by: Tyler Hicks Suggested-by: Mimi Zohar Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- security/keys/trusted.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/security/keys/trusted.c b/security/keys/trusted.c index 9a94672e7adcc..ade6991310654 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.20.1