Commit efa64c09 authored by David Howells's avatar David Howells

KEYS: Ceph: Use key preparsing

Make use of key preparsing in Ceph so that quota size determination can take
place prior to keyring locking when a key is being added.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarSteve Dickson <steved@redhat.com>
Reviewed-by: default avatarSage Weil <sage@redhat.com>
cc: Tommi Virtanen <tommi.virtanen@dreamhost.com>
parent f9167789
...@@ -423,8 +423,7 @@ int ceph_encrypt2(struct ceph_crypto_key *secret, void *dst, size_t *dst_len, ...@@ -423,8 +423,7 @@ int ceph_encrypt2(struct ceph_crypto_key *secret, void *dst, size_t *dst_len,
} }
} }
static int ceph_key_instantiate(struct key *key, static int ceph_key_preparse(struct key_preparsed_payload *prep)
struct key_preparsed_payload *prep)
{ {
struct ceph_crypto_key *ckey; struct ceph_crypto_key *ckey;
size_t datalen = prep->datalen; size_t datalen = prep->datalen;
...@@ -435,10 +434,6 @@ static int ceph_key_instantiate(struct key *key, ...@@ -435,10 +434,6 @@ static int ceph_key_instantiate(struct key *key,
if (datalen <= 0 || datalen > 32767 || !prep->data) if (datalen <= 0 || datalen > 32767 || !prep->data)
goto err; goto err;
ret = key_payload_reserve(key, datalen);
if (ret < 0)
goto err;
ret = -ENOMEM; ret = -ENOMEM;
ckey = kmalloc(sizeof(*ckey), GFP_KERNEL); ckey = kmalloc(sizeof(*ckey), GFP_KERNEL);
if (!ckey) if (!ckey)
...@@ -450,7 +445,8 @@ static int ceph_key_instantiate(struct key *key, ...@@ -450,7 +445,8 @@ static int ceph_key_instantiate(struct key *key,
if (ret < 0) if (ret < 0)
goto err_ckey; goto err_ckey;
key->payload.data = ckey; prep->payload[0] = ckey;
prep->quotalen = datalen;
return 0; return 0;
err_ckey: err_ckey:
...@@ -459,12 +455,20 @@ static int ceph_key_instantiate(struct key *key, ...@@ -459,12 +455,20 @@ static int ceph_key_instantiate(struct key *key,
return ret; return ret;
} }
static void ceph_key_free_preparse(struct key_preparsed_payload *prep)
{
struct ceph_crypto_key *ckey = prep->payload[0];
ceph_crypto_key_destroy(ckey);
kfree(ckey);
}
static int ceph_key_match(const struct key *key, const void *description) static int ceph_key_match(const struct key *key, const void *description)
{ {
return strcmp(key->description, description) == 0; return strcmp(key->description, description) == 0;
} }
static void ceph_key_destroy(struct key *key) { static void ceph_key_destroy(struct key *key)
{
struct ceph_crypto_key *ckey = key->payload.data; struct ceph_crypto_key *ckey = key->payload.data;
ceph_crypto_key_destroy(ckey); ceph_crypto_key_destroy(ckey);
...@@ -473,7 +477,9 @@ static void ceph_key_destroy(struct key *key) { ...@@ -473,7 +477,9 @@ static void ceph_key_destroy(struct key *key) {
struct key_type key_type_ceph = { struct key_type key_type_ceph = {
.name = "ceph", .name = "ceph",
.instantiate = ceph_key_instantiate, .preparse = ceph_key_preparse,
.free_preparse = ceph_key_free_preparse,
.instantiate = generic_key_instantiate,
.match = ceph_key_match, .match = ceph_key_match,
.destroy = ceph_key_destroy, .destroy = ceph_key_destroy,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment