From: David Howells <dhowells@redhat.com>
To: keyrings@linux-nfs.org
Cc: dhowells@redhat.com, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 11/12] KEYS: keyring: Provide key preparsing
Date: Thu, 20 Mar 2014 12:06:10 +0000 [thread overview]
Message-ID: <20140320120610.21635.52036.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20140320120428.21635.13071.stgit@warthog.procyon.org.uk>
Provide key preparsing in the keyring so that we can make preparsing
mandatory. For keyrings, however, only an empty payload is permitted.
Signed-off-by: David Howells <dhowells@redhat.com>
---
security/keys/keyring.c | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 2fb2576dc644..610c50a18db0 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -73,6 +73,8 @@ static inline unsigned keyring_hash(const char *desc)
* can be treated as ordinary keys in addition to having their own special
* operations.
*/
+static int keyring_preparse(struct key_preparsed_payload *prep);
+static void keyring_free_preparse(struct key_preparsed_payload *prep);
static int keyring_instantiate(struct key *keyring,
struct key_preparsed_payload *prep);
static void keyring_revoke(struct key *keyring);
@@ -84,6 +86,8 @@ static long keyring_read(const struct key *keyring,
struct key_type key_type_keyring = {
.name = "keyring",
.def_datalen = 0,
+ .preparse = keyring_preparse,
+ .free_preparse = keyring_free_preparse,
.instantiate = keyring_instantiate,
.match = user_match,
.revoke = keyring_revoke,
@@ -123,6 +127,21 @@ static void keyring_publish_name(struct key *keyring)
}
/*
+ * Preparse a keyring payload
+ */
+static int keyring_preparse(struct key_preparsed_payload *prep)
+{
+ return prep->datalen != 0 ? -EINVAL : 0;
+}
+
+/*
+ * Free a preparse of a user defined key payload
+ */
+static void keyring_free_preparse(struct key_preparsed_payload *prep)
+{
+}
+
+/*
* Initialise a keyring.
*
* Returns 0 on success, -EINVAL if given any data.
@@ -130,17 +149,10 @@ static void keyring_publish_name(struct key *keyring)
static int keyring_instantiate(struct key *keyring,
struct key_preparsed_payload *prep)
{
- int ret;
-
- ret = -EINVAL;
- if (prep->datalen == 0) {
- assoc_array_init(&keyring->keys);
- /* make the keyring available by name if it has one */
- keyring_publish_name(keyring);
- ret = 0;
- }
-
- return ret;
+ assoc_array_init(&keyring->keys);
+ /* make the keyring available by name if it has one */
+ keyring_publish_name(keyring);
+ return 0;
}
/*
next prev parent reply other threads:[~2014-03-20 13:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-20 12:04 [PATCH 00/12] KEYS: Use preparsing in most key types David Howells
2014-03-20 12:04 ` [PATCH 01/12] KEYS: Provide a generic instantiation function David Howells
2014-03-20 12:04 ` [PATCH 02/12] KEYS: struct key_preparsed_payload should have two payload pointers David Howells
2014-03-20 12:04 ` [PATCH 03/12] KEYS: Allow expiry time to be set when preparsing a key David Howells
2014-03-20 12:05 ` [PATCH 04/12] KEYS: Call ->free_preparse() even after ->preparse() returns an error David Howells
2014-03-20 12:05 ` [PATCH 05/12] KEYS: user: Use key preparsing David Howells
2014-03-20 12:05 ` [PATCH 06/12] KEYS: Ceph: " David Howells
2014-03-20 12:05 ` [PATCH 07/12] KEYS: Ceph: Use user_match() David Howells
2014-03-20 12:05 ` [PATCH 08/12] KEYS: DNS: Use key preparsing David Howells
2014-03-20 12:05 ` [PATCH 09/12] KEYS: RxRPC: " David Howells
2014-03-20 12:05 ` [PATCH 10/12] KEYS: big_key: " David Howells
2014-03-20 12:06 ` David Howells [this message]
2014-03-20 12:06 ` [PATCH 12/12] KEYS: request_key_auth: Provide " David Howells
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=20140320120610.21635.52036.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=keyrings@linux-nfs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
/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
all inboxes | Powered by JetHome®