Re: Private namespaces

From: Andries Brouwer (aebr@win.tue.nl)
Date: Sat Apr 19 2003 - 11:21:47 EST


On Sat, Apr 19, 2003 at 09:52:39AM -0500, Florin Iucha wrote:

> I have compiled the sample program on 2.5.67-pre6 and it fails with
> clone: Cannot allocate memory
> when run as a regular user. Is there a workaround?

Well, the comment says

"Exercise Play with this in several situations. You may have to be root."

and the source says

        if (! (flags & CLONE_NEWNS))
                return 0;

        if (!capable(CAP_SYS_ADMIN)) {
                put_namespace(namespace);
                return -EPERM;
        }

so there is not much hope for a regular user.

Now you ask: but why ENOMEM?
That is a tiny flaw in the kernel source.
I suppose

--- fork.c~ Tue Mar 25 04:54:46 2003
+++ fork.c Sat Apr 19 18:21:44 2003
@@ -873,7 +873,8 @@
                goto bad_fork_cleanup_sighand;
        if (copy_mm(clone_flags, p))
                goto bad_fork_cleanup_signal;
- if (copy_namespace(clone_flags, p))
+ retval = copy_namespace(clone_flags, p);
+ if (retval)
                goto bad_fork_cleanup_mm;
        retval = copy_thread(0, clone_flags, stack_start, stack_size, p, regs);
        if (retval)

would fix that.

Andries

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Apr 23 2003 - 22:00:26 EST