aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/user_namespace.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2011-11-17 00:52:53 -0500
committerEric W. Biederman <ebiederm@xmission.com>2012-04-07 19:55:52 -0400
commit0093ccb68f3753c0ba4d74c89d7e0f444b8d6123 (patch)
treea6fc0ea2a6dfc338fa8fc7126005f40109ef8dce /kernel/user_namespace.c
parentc4a4d603796c727b9555867571f89483be9c565e (diff)
cred: Refcount the user_ns pointed to by the cred.
struct user_struct will shortly loose it's user_ns reference so make the cred user_ns reference a proper reference complete with reference counting. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'kernel/user_namespace.c')
-rw-r--r--kernel/user_namespace.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index f084083a0fd3..58bb8781a778 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -24,7 +24,7 @@ static struct kmem_cache *user_ns_cachep __read_mostly;
24 */ 24 */
25int create_user_ns(struct cred *new) 25int create_user_ns(struct cred *new)
26{ 26{
27 struct user_namespace *ns; 27 struct user_namespace *ns, *parent_ns = new->user_ns;
28 struct user_struct *root_user; 28 struct user_struct *root_user;
29 int n; 29 int n;
30 30
@@ -57,8 +57,10 @@ int create_user_ns(struct cred *new)
57#endif 57#endif
58 /* tgcred will be cleared in our caller bc CLONE_THREAD won't be set */ 58 /* tgcred will be cleared in our caller bc CLONE_THREAD won't be set */
59 59
60 /* root_user holds a reference to ns, our reference can be dropped */ 60 /* Leave the reference to our user_ns with the new cred */
61 put_user_ns(ns); 61 new->user_ns = ns;
62
63 put_user_ns(parent_ns);
62 64
63 return 0; 65 return 0;
64} 66}