Set cred->user_ns in key_replace_session_keyring
authorSerge E. Hallyn <serge@hallyn.com>
Thu, 26 May 2011 20:25:05 +0000 (15:25 -0500)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 26 May 2011 20:49:19 +0000 (13:49 -0700)
Since this cred was not created with copy_creds(), it needs to get
initialized.  Otherwise use of syscall(__NR_keyctl, KEYCTL_SESSION_TO_PARENT);
can lead to a NULL deref.  Thanks to Robert for finding this.

But introduced by commit 47a150edc2a ("Cache user_ns in struct cred").

Signed-off-by: Serge E. Hallyn <serge.hallyn@canonical.com>
Reported-by: Robert Święcki <robert@swiecki.net>
Cc: David Howells <dhowells@redhat.com>
Cc: stable@kernel.org (2.6.39)
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
security/keys/process_keys.c

index 6c0480db8885b6393b8f4bfea75b8d35ce3015d3..a3063eb3dc232a16eab45161e28f0c88fc642841 100644 (file)
@@ -847,6 +847,7 @@ void key_replace_session_keyring(void)
        new-> sgid      = old-> sgid;
        new->fsgid      = old->fsgid;
        new->user       = get_uid(old->user);
+       new->user_ns    = new->user->user_ns;
        new->group_info = get_group_info(old->group_info);
 
        new->securebits = old->securebits;