From: Dan Williams <dan.j.williams@intel.com>
To: keyrings@vger.kernel.org
Cc: Tyler Hicks <tyhicks@canonical.com>,
ecryptfs@vger.kernel.org, vishal.l.verma@intel.com,
linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] security/keys/ecryptfs: Drop direct dependency on key_type_encrypted
Date: Mon, 18 Mar 2019 23:06:36 -0700 [thread overview]
Message-ID: <155297559625.2276575.11539296499176067525.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <155297557534.2276575.16264199708584900090.stgit@dwillia2-desk3.amr.corp.intel.com>
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 <tyhicks@canonical.com>
Cc: <ecryptfs@vger.kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
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");
next prev parent reply other threads:[~2019-03-19 6:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 6:06 [PATCH 0/6] security/keys/encrypted: Break module dependency chain Dan Williams
2019-03-19 6:06 ` [PATCH 1/6] security/keys/encrypted: Allow operation without trusted.ko Dan Williams
2019-03-19 6:06 ` [PATCH 2/6] security/keys/encrypted: Clean up request_trusted_key() Dan Williams
2019-03-20 0:06 ` Mimi Zohar
2019-03-20 0:20 ` Dan Williams
2019-03-20 1:10 ` Mimi Zohar
2019-03-20 1:34 ` Dan Williams
2019-03-20 1:37 ` Dan Williams
2019-03-20 2:35 ` Mimi Zohar
2019-03-20 5:48 ` Dan Williams
2019-03-20 12:06 ` Mimi Zohar
2019-03-20 15:27 ` Dan Williams
2019-03-19 6:06 ` [PATCH 3/6] libnvdimm/security: Drop direct dependency on key_type_encrypted Dan Williams
2019-03-19 16:46 ` Dave Jiang
2019-03-19 6:06 ` Dan Williams [this message]
2019-03-19 6:06 ` [PATCH 5/6] security/integrity/evm: " Dan Williams
2019-03-19 6:06 ` [PATCH 6/6] security/keys/encrypted: Drop export of key_type_encrypted Dan Williams
2019-03-19 21:01 ` [PATCH 0/6] security/keys/encrypted: Break module dependency chain Dan Williams
2019-03-19 21:08 ` James Bottomley
2019-03-19 21:23 ` Dan Williams
2019-03-20 1:20 ` Mimi Zohar
2019-03-21 13:45 ` Jarkko Sakkinen
2019-03-21 13:48 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=155297559625.2276575.11539296499176067525.stgit@dwillia2-desk3.amr.corp.intel.com \
--to=dan.j.williams@intel.com \
--cc=ecryptfs@vger.kernel.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=tyhicks@canonical.com \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).