Commit 1f8f5cf6e4f038552a3e47b66085452c08556d71

Authored by David Howells
Committed by Linus Torvalds
1 parent 3ad4f59705

KEYS: Make request key instantiate the per-user keyrings

Make request_key() instantiate the per-user keyrings so that it doesn't oops
if it needs to get hold of the user session keyring because there isn't a
session keyring in place.

Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Steve French <smfrench@gmail.com>
Tested-by: Rutger Nijlunsing <rutger.nijlunsing@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 3 changed files with 6 additions and 1 deletions Side-by-side Diff

security/keys/internal.h
... ... @@ -107,6 +107,7 @@
107 107  
108 108 extern struct key *find_keyring_by_name(const char *name, bool skip_perm_check);
109 109  
  110 +extern int install_user_keyrings(struct task_struct *tsk);
110 111 extern int install_thread_keyring(struct task_struct *tsk);
111 112 extern int install_process_keyring(struct task_struct *tsk);
112 113  
security/keys/process_keys.c
... ... @@ -40,7 +40,7 @@
40 40 /*
41 41 * install user and user session keyrings for a particular UID
42 42 */
43   -static int install_user_keyrings(struct task_struct *tsk)
  43 +int install_user_keyrings(struct task_struct *tsk)
44 44 {
45 45 struct user_struct *user = tsk->user;
46 46 struct key *uid_keyring, *session_keyring;
security/keys/request_key.c
... ... @@ -74,6 +74,10 @@
74 74  
75 75 kenter("{%d},{%d},%s", key->serial, authkey->serial, op);
76 76  
  77 + ret = install_user_keyrings(tsk);
  78 + if (ret < 0)
  79 + goto error_alloc;
  80 +
77 81 /* allocate a new session keyring */
78 82 sprintf(desc, "_req.%u", key->serial);
79 83