From 9fd165379eff957ec3a9f5059c9d5ed05e02e61a Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 22 May 2019 13:30:56 +0100 Subject: keys: sparse: Fix kdoc mismatches Fix some kdoc argument description mismatches reported by sparse and give keyring_restrict() a description. Signed-off-by: David Howells Reviewed-by: James Morris cc: Mat Martineau --- security/keys/request_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'security/keys/request_key.c') diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 75d87f9e0f49..1f234b019437 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c @@ -24,7 +24,7 @@ /** * complete_request_key - Complete the construction of a key. - * @auth_key: The authorisation key. + * @authkey: The authorisation key. * @error: The success or failute of the construction. * * Complete the attempt to construct a key. The key will be negated -- cgit From df593ee23e05cdda16c8c995e5818779431bb29f Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 30 May 2019 11:37:39 +0100 Subject: keys: Hoist locking out of __key_link_begin() Hoist the locking of out of __key_link_begin() and into its callers. This is necessary to allow the upcoming key_move() operation to correctly order taking of the source keyring semaphore, the destination keyring semaphore and the keyring serialisation lock. Signed-off-by: David Howells --- security/keys/request_key.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'security/keys/request_key.c') diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 1f234b019437..857da65e1940 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c @@ -343,7 +343,7 @@ static int construct_alloc_key(struct keyring_search_context *ctx, struct key_user *user, struct key **_key) { - struct assoc_array_edit *edit; + struct assoc_array_edit *edit = NULL; struct key *key; key_perm_t perm; key_ref_t key_ref; @@ -372,6 +372,9 @@ static int construct_alloc_key(struct keyring_search_context *ctx, set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); if (dest_keyring) { + ret = __key_link_lock(dest_keyring, &ctx->index_key); + if (ret < 0) + goto link_lock_failed; ret = __key_link_begin(dest_keyring, &ctx->index_key, &edit); if (ret < 0) goto link_prealloc_failed; @@ -423,6 +426,8 @@ link_check_failed: return ret; link_prealloc_failed: + __key_link_end(dest_keyring, &ctx->index_key, edit); +link_lock_failed: mutex_unlock(&user->cons_lock); key_put(key); kleave(" = %d [prelink]", ret); -- cgit