Re: [PATCH] KEYS: The request_key() syscall should link an existing key to the dest keyring

From: Vegard Nossum
Date: Wed Apr 28 2010 - 08:04:48 EST


On 26 April 2010 16:59, David Howells <dhowells@xxxxxxxxxx> wrote:
> The request_key() system call and request_key_and_link() should make a link
> from an existing key to the destination keyring (if supplied), not just from a
> new key to the destination keyring.
>
> This can be tested by:
>
> Â Â Â Âring=`keyctl newring fred @s`
> Â Â Â Âkeyctl request2 user debug:a a
> Â Â Â Âkeyctl request user debug:a $ring
> Â Â Â Âkeyctl list $ring
>
> If it says:
>
> Â Â Â Âkeyring is empty
>
> then it didn't work. ÂIf it shows something like:
>
> Â Â Â Â1 key in keyring:
>    Â1070462727: --alswrv   0   0 user: debug:a
>
> then it did.
>
> Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
> ---
>
> Âsecurity/keys/request_key.c | Â Â9 ++++++++-
> Â1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/security/keys/request_key.c b/security/keys/request_key.c
> index ea97c31..d737cea 100644
> --- a/security/keys/request_key.c
> +++ b/security/keys/request_key.c
> @@ -339,8 +339,10 @@ static int construct_alloc_key(struct key_type *type,
>
> Âkey_already_present:
> Â Â Â Âmutex_unlock(&key_construction_mutex);
> - Â Â Â if (dest_keyring)
> + Â Â Â if (dest_keyring) {
> + Â Â Â Â Â Â Â __key_link(dest_keyring, key_ref_to_ptr(key_ref));
> Â Â Â Â Â Â Â Âup_write(&dest_keyring->sem);
> + Â Â Â }
> Â Â Â Âmutex_unlock(&user->cons_lock);
> Â Â Â Âkey_put(key);
> Â Â Â Â*_key = key = key_ref_to_ptr(key_ref);

Hi,

Just a few questions (if you don't mind).

1. Is it correct to return -EINPROGRESS in this case?

2. (Why) Shouldn't the return value of __key_link() be checked?

3. In __key_link(), shouldn't rcu_dereference() be used when accessing
keyring->payload.subscriptions?

Thanks,


Vegard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/