From patchwork Tue Mar 19 06:06:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10858843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 730CA13B5 for ; Tue, 19 Mar 2019 06:19:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 511A029540 for ; Tue, 19 Mar 2019 06:19:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44DC329556; Tue, 19 Mar 2019 06:19:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4139E29540 for ; Tue, 19 Mar 2019 06:19:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 28677211DF22E; Mon, 18 Mar 2019 23:19:02 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 388D2211DC092 for ; Mon, 18 Mar 2019 23:19:00 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 23:18:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,496,1544515200"; d="scan'208";a="126620568" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga008.jf.intel.com with ESMTP; 18 Mar 2019 23:18:59 -0700 Subject: [PATCH 1/6] security/keys/encrypted: Allow operation without trusted.ko From: Dan Williams To: keyrings@vger.kernel.org Date: Mon, 18 Mar 2019 23:06:20 -0700 Message-ID: <155297558061.2276575.9485856950730059730.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155297557534.2276575.16264199708584900090.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155297557534.2276575.16264199708584900090.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-nvdimm@lists.01.org, James Bottomley , Roberto Sassu , linux-kernel@vger.kernel.org, Mimi Zohar , David Howells , Jarkko Sakkinen Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP The trusted.ko module may fail to load. In the common case this failure is simply due to the platform missing a TPM. Teach the encrypted_keys implementation to lookup the key type by name rather than having a module dependency. Fixes: 240730437deb ("KEYS: trusted: explicitly use tpm_chip structure...") Suggested-by: James Bottomley Cc: Roberto Sassu Cc: Jarkko Sakkinen Cc: Mimi Zohar Cc: David Howells Signed-off-by: Dan Williams --- security/keys/encrypted-keys/masterkey_trusted.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/security/keys/encrypted-keys/masterkey_trusted.c b/security/keys/encrypted-keys/masterkey_trusted.c index dc3d18cae642..7560aea6438d 100644 --- a/security/keys/encrypted-keys/masterkey_trusted.c +++ b/security/keys/encrypted-keys/masterkey_trusted.c @@ -19,6 +19,7 @@ #include #include #include "encrypted.h" +#include "../internal.h" /* * request_trusted_key - request the trusted key @@ -31,9 +32,15 @@ struct key *request_trusted_key(const char *trusted_desc, const u8 **master_key, size_t *master_keylen) { struct trusted_key_payload *tpayload; + struct key_type *type; struct key *tkey; - tkey = request_key(&key_type_trusted, trusted_desc, NULL); + type = key_type_lookup("trusted"); + if (IS_ERR(type)) { + tkey = (struct key *)type; + goto error; + } + tkey = request_key(type, trusted_desc, NULL); if (IS_ERR(tkey)) goto error; @@ -44,3 +51,5 @@ struct key *request_trusted_key(const char *trusted_desc, error: return tkey; } + +MODULE_SOFTDEP("pre: trusted");