diff options
Diffstat (limited to 'security/keys/process_keys.c')
-rw-r--r-- | security/keys/process_keys.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c index a3063eb3dc23..1068cb1939b3 100644 --- a/security/keys/process_keys.c +++ b/security/keys/process_keys.c | |||
@@ -270,7 +270,7 @@ static int install_session_keyring(struct key *keyring) | |||
270 | if (!new) | 270 | if (!new) |
271 | return -ENOMEM; | 271 | return -ENOMEM; |
272 | 272 | ||
273 | ret = install_session_keyring_to_cred(new, NULL); | 273 | ret = install_session_keyring_to_cred(new, keyring); |
274 | if (ret < 0) { | 274 | if (ret < 0) { |
275 | abort_creds(new); | 275 | abort_creds(new); |
276 | return ret; | 276 | return ret; |
@@ -589,12 +589,22 @@ try_again: | |||
589 | ret = install_user_keyrings(); | 589 | ret = install_user_keyrings(); |
590 | if (ret < 0) | 590 | if (ret < 0) |
591 | goto error; | 591 | goto error; |
592 | ret = install_session_keyring( | 592 | if (lflags & KEY_LOOKUP_CREATE) |
593 | cred->user->session_keyring); | 593 | ret = join_session_keyring(NULL); |
594 | else | ||
595 | ret = install_session_keyring( | ||
596 | cred->user->session_keyring); | ||
594 | 597 | ||
595 | if (ret < 0) | 598 | if (ret < 0) |
596 | goto error; | 599 | goto error; |
597 | goto reget_creds; | 600 | goto reget_creds; |
601 | } else if (cred->tgcred->session_keyring == | ||
602 | cred->user->session_keyring && | ||
603 | lflags & KEY_LOOKUP_CREATE) { | ||
604 | ret = join_session_keyring(NULL); | ||
605 | if (ret < 0) | ||
606 | goto error; | ||
607 | goto reget_creds; | ||
598 | } | 608 | } |
599 | 609 | ||
600 | rcu_read_lock(); | 610 | rcu_read_lock(); |