]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
user namespaces: let user_ns be cloned with fairsched
authorSerge E. Hallyn <serue@us.ibm.com>
Wed, 3 Dec 2008 19:17:06 +0000 (13:17 -0600)
committerJames Morris <jmorris@namei.org>
Sun, 7 Dec 2008 22:16:22 +0000 (09:16 +1100)
(These two patches are in the next-unacked branch of
git://git.kernel.org/pub/scm/linux/kernel/git/sergeh/userns-2.6.
If they get some ACKs, then I hope to feed this into security-next.
After these two, I think we're ready to tackle userns+capabilities)

Fairsched creates a per-uid directory under /sys/kernel/uids/.
So when you clone(CLONE_NEWUSER), it tries to create
/sys/kernel/uids/0, which already exists, and you get back
-ENOMEM.

This was supposed to be fixed by sysfs tagging, but that
was postponed (ok, rejected until sysfs locking is fixed).
So, just as with network namespaces, we just don't create
those directories for user namespaces other than the init.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
kernel/user.c

index 97202cb29adc333869f160819e1d4167f5576ff6..6c924bc48c08c043828a4e48ff56e8c225e30bca 100644 (file)
@@ -246,6 +246,8 @@ static int uids_user_create(struct user_struct *up)
        int error;
 
        memset(kobj, 0, sizeof(struct kobject));
+       if (up->user_ns != &init_user_ns)
+               return 0;
        kobj->kset = uids_kset;
        error = kobject_init_and_add(kobj, &uids_ktype, NULL, "%d", up->uid);
        if (error) {
@@ -281,6 +283,8 @@ static void remove_user_sysfs_dir(struct work_struct *w)
        unsigned long flags;
        int remove_user = 0;
 
+       if (up->user_ns != &init_user_ns)
+               return;
        /* Make uid_hash_remove() + sysfs_remove_file() + kobject_del()
         * atomic.
         */