aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/keyctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/keys/keyctl.c')
-rw-r--r--security/keys/keyctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index b2b0998d6abd..60924f6a52db 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -1272,6 +1272,7 @@ long keyctl_session_to_parent(void)
1272 keyring_r = NULL; 1272 keyring_r = NULL;
1273 1273
1274 me = current; 1274 me = current;
1275 rcu_read_lock();
1275 write_lock_irq(&tasklist_lock); 1276 write_lock_irq(&tasklist_lock);
1276 1277
1277 parent = me->real_parent; 1278 parent = me->real_parent;
@@ -1304,7 +1305,8 @@ long keyctl_session_to_parent(void)
1304 goto not_permitted; 1305 goto not_permitted;
1305 1306
1306 /* the keyrings must have the same UID */ 1307 /* the keyrings must have the same UID */
1307 if (pcred->tgcred->session_keyring->uid != mycred->euid || 1308 if ((pcred->tgcred->session_keyring &&
1309 pcred->tgcred->session_keyring->uid != mycred->euid) ||
1308 mycred->tgcred->session_keyring->uid != mycred->euid) 1310 mycred->tgcred->session_keyring->uid != mycred->euid)
1309 goto not_permitted; 1311 goto not_permitted;
1310 1312
@@ -1319,6 +1321,7 @@ long keyctl_session_to_parent(void)
1319 set_ti_thread_flag(task_thread_info(parent), TIF_NOTIFY_RESUME); 1321 set_ti_thread_flag(task_thread_info(parent), TIF_NOTIFY_RESUME);
1320 1322
1321 write_unlock_irq(&tasklist_lock); 1323 write_unlock_irq(&tasklist_lock);
1324 rcu_read_unlock();
1322 if (oldcred) 1325 if (oldcred)
1323 put_cred(oldcred); 1326 put_cred(oldcred);
1324 return 0; 1327 return 0;
@@ -1327,6 +1330,7 @@ already_same:
1327 ret = 0; 1330 ret = 0;
1328not_permitted: 1331not_permitted:
1329 write_unlock_irq(&tasklist_lock); 1332 write_unlock_irq(&tasklist_lock);
1333 rcu_read_unlock();
1330 put_cred(cred); 1334 put_cred(cred);
1331 return ret; 1335 return ret;
1332 1336