keys: fix an RCU warning
Fix the following RCU warning: =================================================== [ INFO: suspicious rcu_dereference_check() usage. ] --------------------------------------------------- security/keys/request_key.c:116 invoked rcu_dereference_check() without protection! This was caused by doing: [root@andromeda ~]# keyctl newring fred @s 539196288 [root@andromeda ~]# keyctl request2 user a a 539196288 request_key: Required key not available Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
ccdb40048b
commit
93b4a44f3a
|
@ -68,7 +68,8 @@ static int call_sbin_request_key(struct key_construction *cons,
|
|||
{
|
||||
const struct cred *cred = current_cred();
|
||||
key_serial_t prkey, sskey;
|
||||
struct key *key = cons->key, *authkey = cons->authkey, *keyring;
|
||||
struct key *key = cons->key, *authkey = cons->authkey, *keyring,
|
||||
*session;
|
||||
char *argv[9], *envp[3], uid_str[12], gid_str[12];
|
||||
char key_str[12], keyring_str[3][12];
|
||||
char desc[20];
|
||||
|
@ -112,10 +113,12 @@ static int call_sbin_request_key(struct key_construction *cons,
|
|||
if (cred->tgcred->process_keyring)
|
||||
prkey = cred->tgcred->process_keyring->serial;
|
||||
|
||||
if (cred->tgcred->session_keyring)
|
||||
sskey = rcu_dereference(cred->tgcred->session_keyring)->serial;
|
||||
else
|
||||
sskey = cred->user->session_keyring->serial;
|
||||
rcu_read_lock();
|
||||
session = rcu_dereference(cred->tgcred->session_keyring);
|
||||
if (!session)
|
||||
session = cred->user->session_keyring;
|
||||
sskey = session->serial;
|
||||
rcu_read_unlock();
|
||||
|
||||
sprintf(keyring_str[2], "%d", sskey);
|
||||
|
||||
|
|
Loading…
Reference in New Issue