summaryrefslogtreecommitdiffstats
path: root/kernel/user_namespace.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2011-11-16 21:52:53 -0800
committerEric W. Biederman <ebiederm@xmission.com>2012-04-07 16:55:52 -0700
commit0093ccb68f3753c0ba4d74c89d7e0f444b8d6123 (patch)
treea6fc0ea2a6dfc338fa8fc7126005f40109ef8dce /kernel/user_namespace.c
parentc4a4d603796c727b9555867571f89483be9c565e (diff)
downloadblackbird-op-linux-0093ccb68f3753c0ba4d74c89d7e0f444b8d6123.tar.gz
blackbird-op-linux-0093ccb68f3753c0ba4d74c89d7e0f444b8d6123.zip
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;
*/
int create_user_ns(struct cred *new)
{
- struct user_namespace *ns;
+ struct user_namespace *ns, *parent_ns = new->user_ns;
struct user_struct *root_user;
int n;
@@ -57,8 +57,10 @@ int create_user_ns(struct cred *new)
#endif
/* tgcred will be cleared in our caller bc CLONE_THREAD won't be set */
- /* root_user holds a reference to ns, our reference can be dropped */
- put_user_ns(ns);
+ /* Leave the reference to our user_ns with the new cred */
+ new->user_ns = ns;
+
+ put_user_ns(parent_ns);
return 0;
}
OpenPOWER on IntegriCloud