From patchwork Tue Mar 19 06:06:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10858849 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 F20C315AC for ; Tue, 19 Mar 2019 06:19:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE5282914A for ; Tue, 19 Mar 2019 06:19:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2A732930A; Tue, 19 Mar 2019 06:19:17 +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 775B42914A for ; Tue, 19 Mar 2019 06:19:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6E39A211DF242; Mon, 18 Mar 2019 23:19:17 -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=134.134.136.20; helo=mga02.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 63C43211DC092 for ; Mon, 18 Mar 2019 23:19:16 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2019 23:19:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,496,1544515200"; d="scan'208";a="132778389" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga008.fm.intel.com with ESMTP; 18 Mar 2019 23:19:15 -0700 Subject: [PATCH 4/6] security/keys/ecryptfs: Drop direct dependency on key_type_encrypted From: Dan Williams To: keyrings@vger.kernel.org Date: Mon, 18 Mar 2019 23:06:36 -0700 Message-ID: <155297559625.2276575.11539296499176067525.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, ecryptfs@vger.kernel.org, linux-kernel@vger.kernel.org, Tyler Hicks Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Lookup the key type by name and protect ecryptfs from encrypted_keys.ko module load failures, and cleanup the configuration dependencies on the definition of the ecryptfs_get_encrypted_key() helper. Cc: Tyler Hicks Cc: Signed-off-by: Dan Williams --- fs/ecryptfs/ecryptfs_kernel.h | 22 +--------------------- fs/ecryptfs/keystore.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index e74cb2a0b299..3106d23d95f0 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h @@ -87,13 +87,12 @@ struct ecryptfs_page_crypt_context { } param; }; -#if defined(CONFIG_ENCRYPTED_KEYS) || defined(CONFIG_ENCRYPTED_KEYS_MODULE) static inline struct ecryptfs_auth_tok * ecryptfs_get_encrypted_key_payload_data(struct key *key) { struct encrypted_key_payload *payload; - if (key->type != &key_type_encrypted) + if (strcmp(key->type->name, "encrypted") != 0) return NULL; payload = key->payload.data[0]; @@ -103,25 +102,6 @@ ecryptfs_get_encrypted_key_payload_data(struct key *key) return (struct ecryptfs_auth_tok *)payload->payload_data; } -static inline struct key *ecryptfs_get_encrypted_key(char *sig) -{ - return request_key(&key_type_encrypted, sig, NULL); -} - -#else -static inline struct ecryptfs_auth_tok * -ecryptfs_get_encrypted_key_payload_data(struct key *key) -{ - return NULL; -} - -static inline struct key *ecryptfs_get_encrypted_key(char *sig) -{ - return ERR_PTR(-ENOKEY); -} - -#endif /* CONFIG_ENCRYPTED_KEYS */ - static inline struct ecryptfs_auth_tok * ecryptfs_get_key_payload_data(struct key *key) { diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index e74fe84d0886..52a01dd57f4a 100644 --- a/fs/ecryptfs/keystore.c +++ b/fs/ecryptfs/keystore.c @@ -1619,6 +1619,17 @@ parse_tag_11_packet(unsigned char *data, unsigned char *contents, return rc; } +static struct key *ecryptfs_get_encrypted_key(char *sig) +{ + struct key_type *type; + struct key *key; + + type = key_type_lookup("encrypted"); + if (IS_ERR(type)) + return (struct key *) type; + return request_key(type, sig, NULL); +} + int ecryptfs_keyring_auth_tok_for_sig(struct key **auth_tok_key, struct ecryptfs_auth_tok **auth_tok, char *sig) @@ -2542,3 +2553,4 @@ ecryptfs_add_global_auth_tok(struct ecryptfs_mount_crypt_stat *mount_crypt_stat, return 0; } +MODULE_SOFTDEP("pre: encrypted_keys");