unprivileged mount/umount
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · Miklos Szeredi
How about a new clone option "
CLONE_NOSUID"?
IMO, the clone call ist the wrong place to create namespaces. It should be deprecated by a mkdir/chdir-like interface.
Signature · 1 line
Incoming fire has the right of way.
Quoted 4 lines · Bodo Eggert
Quoted 1 line
How about a new clone option "
CLONE_NOSUID"?IMO, the clone call ist the wrong place to create namespaces. It should be deprecated by a mkdir/chdir-like interface.
And the mkdir/chdir interface already exists, see "cd /proc/NNN/root".
There are some small quirks to fix, should we decide that's the way to go. But it's basically there.
File descriptors keep track of the namespace (actually vfsmnt) where they were opened. Today, if you pass a directory file descriptor from one process to another, you're granting access to see the other's namespace.
That's why /proc/NNN/root works (with small fixes) in much the way you'd expect.
-- Jamie
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
How about a new clone option "
CLONE_NOSUID"?IMO, the clone call ist the wrong place to create namespaces. It should be deprecated by a mkdir/chdir-like interface.
And the mkdir/chdir interface already exists, see "cd
/proc/NNN/root".
That's the chdir part.
The mkdir part is clone() or unshare().
How else do you propose to create new namespaces?
Miklos
Quoted 10 lines · Miklos Szeredi
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
How about a new clone option "
CLONE_NOSUID"?IMO, the clone call ist the wrong place to create namespaces. It should be deprecated by a mkdir/chdir-like interface.
And the mkdir/chdir interface already exists, see "cd
/proc/NNN/root".That's the chdir part.
The mkdir part is
clone()orunshare().
Right, sys_unshare(), as per Janak's patch. Does it lack anything which you would need?
Quoted 1 line
How else do you propose to create new namespaces?
thanks,
-serge
Quoted 7 lines · On Wed, 11 May 2005 [email protected] wrote:
Quoted 5 lines · Miklos Szeredi
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
How about a new clone option "
CLONE_NOSUID"?IMO, the clone call ist the wrong place to create namespaces. It should be deprecated by a mkdir/chdir-like interface.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
And the mkdir/chdir interface already exists, see "cd
/proc/NNN/root".That's the chdir part.
The mkdir part is
clone()orunshare().Right,
sys_unshare(), as per Janak's patch. Does it lack anything which you would need?
e.g.
create_persistent_namespace(char* name) destroy_persistent_namespace(char* name) list_persistent_namespaces(char * prefix, uint flags)
# flags & 1: 1=list all namespaces minus prefix # 0=trim names at the first slash after stripping prefix
Signature · 3 lines
Funny quotes:
27. If people from Poland are called Poles, why aren't people from Holland
called Holes?Quoted 7 lines
e.g.
create_persistent_namespace(char* name)destroy_persistent_namespace(char* name)list_persistent_namespaces(char * prefix, uint flags)# flags & 1: 1=list all namespaces minus prefix # 0=trim names at the first slash after stripping prefix
Just create a namespacefs :)
Mkdir creates a new namespace, rmdir removes a namespace, chroot switches to the namespace. No new interfaces needed.
Miklos
Quoted 2 lines · [email protected] wrote:
Right,
sys_unshare(), as per Janak's patch. Does it lack anything which you would need?
For creating new namespaces to be held by a daemon for handing out to user processes on demand, it's no more convenient than clone(). Neither of them provide a facility to create multiple namespaces as first-class objects, without switching to them.
-- Jamie
Quoted 6 lines · Jamie Lokier
Quoted 2 lines · [email protected] wrote:
Right,
sys_unshare(), as per Janak's patch. Does it lack anything which you would need?For creating new namespaces to be held by a daemon for handing out to user processes on demand, it's no more convenient than
clone().
I see.
My use for namespaces is to simply customize the fs view on login, so sys_unshare is more convenient than clone because it now allows a pam library to switch namespaces, which was either impossible or hard to do using clone. Making namespaces first-class objects should also work, since the namespaces can just be set up in advance and then entered from inside a pam library.
Still I'd agree with Eric. It'd be good to see just how much we can do with the ability to clone a namespace outside of clone(). Going back to the daemon handing out namespaces... why can't you just take your earlier example of /var/namespaces/NS1, etc, where you just create a bunch of fs trees under the /var/namespaces directory using bind mounts, and then login or pam does
sys_unshare(CLONE_NEWNS); chdir(/var/namespaces/NS3) pivot_root(/var/namespaces/NS3, tmp) umount(tmp, MNT_DETACH) chroot .
?
No daemon needed...
thanks,
-serge
Quoted 8 lines · Miklos Szeredi
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
How about a new clone option "
CLONE_NOSUID"?IMO, the clone call ist the wrong place to create namespaces. It should be deprecated by a mkdir/chdir-like interface.
And the mkdir/chdir interface already exists, see "cd
/proc/NNN/root".That's the chdir part.
What if proc filesystem is removed from the kernel?
Ability to access some other namespace through the proc filesystem does not look clean. I think it should be cleanly supported through VFS.
Also cd'ing into a new namespace just allows you to browse through the other namespace. But it does not effectively change the process's namespace. Things like mount in the other namespace will be failed by check_mount() anyway.
I think, we need sys calls like sys_cdnamespace() which switches to a new namespace.
Effectively the process's current->namespace has to be modified, for the process to be effectively work in the new namespace.
Quoted 2 lines
The mkdir part is
clone()orunshare().
clone/unshare will give you the ability to share/unshare a know
namespace. But to share some arbitrary namespace to which a process has access rights to.
Quoted 2 lines
How else do you propose to create new namespaces?
RP
Quoted 5 lines
Miklos
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines
What if proc filesystem is removed from the kernel?
Ability to access some other namespace through the proc filesystem does not look clean. I think it should be cleanly supported through VFS.
Quoted 7 lines
Also cd'ing into a new namespace just allows you to browse through the other namespace. But it does not effectively change the process's namespace. Things like mount in the other namespace will be failed by
check_mount()anyway.I think, we need sys calls like
sys_cdnamespace()which switches to a new namespace.
Jamie's proposal was to make chroot() swich namespace.
Quoted 2 lines
Effectively the process's
current->namespacehas to be modified, for the process to be effectively work in the new namespace.
current->namespace could be dropped altogether, and current->current->fs->rootmnt->mnt_namespace could be used instead.
It's a nice logical extension of chroot(), without needing new syscalls.
Miklos
Quoted 4 lines · Ram
What if proc filesystem is removed from the kernel?
Ability to access some other namespace through the proc filesystem does not look clean. I think it should be cleanly supported through VFS.
You don't have to use /proc/NNN/root - that's just one convenient way to do it.
Other ways are
run_in_namespace mount -t bind / /var/namespaces/$NAME
and
clone + open("/") + pass to parent using unix socket
which I think both work already.
Quoted 4 lines
Also cd'ing into a new namespace just allows you to browse through the other namespace. But it does not effectively change the process's namespace. Things like mount in the other namespace will be failed by
check_mount()anyway.
That's correct.
Quoted 2 lines
I think, we need sys calls like
sys_cdnamespace()which switches to a new namespace.
Can you give a reason why sys_chdir() shouldn't have that behaviour?
Quoted 2 lines
Effectively the process's
current->namespacehas to be modified, for the process to be effectively work in the new namespace.
Or just remove current->namespace. It's entire purpose seems to be to prevent namespaces from being first class objects. The idea of "current namespace" is adequately represented by current->fs->mnt_root->mnt_namespace IMHO.
-- Jamie
Quoted 24 lines · Jamie Lokier
Quoted 4 lines · Ram
What if proc filesystem is removed from the kernel?
Ability to access some other namespace through the proc filesystem does not look clean. I think it should be cleanly supported through VFS.
You don't have to use
/proc/NNN/root- that's just one convenient way to do it.Other ways are
run_in_namespacemount -t bind //var/namespaces/$NAMEand
clone +
open("/")+ pass to parent using unix socketwhich I think both work already.
Quoted 4 lines
Also cd'ing into a new namespace just allows you to browse through the other namespace. But it does not effectively change the process's namespace. Things like mount in the other namespace will be failed by
check_mount()anyway.
Quoted 6 lines
That's correct.
Quoted 2 lines
I think, we need sys calls like
sys_cdnamespace()which switches to a new namespace.Can you give a reason why
sys_chdir()shouldn't have that behaviour?
Do you mean to say you want to change the namespace when a process changes to a directory which belongs to that namespace?
Well it makes it totally confusing. A user would start seeing different set of mounts suddenly as he changes directories beloning to different namespaces. I am not sure, if changing namespace implicitly is a good idea. Not saying its a bad idea, but seems to change my notion of namespaces completely.
I think a process should have access to one
namespace at any given point in time, and should have the ability to explicitly switch to a different namespace of its choice, provided it has enough access permission to that namespace.
having the ability to access two namespaces simultaneously can allow cross contamination. Which essentially makes namespaces as a concept irrelevent.
RP
Quoted 10 lines
Quoted 3 lines
Effectively the process's
current->namespacehas to be modified, for the process to be effectively work in the new namespace.Or just remove
current->namespace. It's entire purpose seems to be to prevent namespaces from being first class objects. The idea of "current namespace" is adequately represented bycurrent->fs->mnt_root->mnt_namespaceIMHO.-- Jamie
Quoted 9 lines · Ram
Quoted 1 line · Jamie Lokier
Ram wrote:
Well it makes it totally confusing. A user would start seeing different set of mounts suddenly as he changes directories beloning to different namespaces. I am not sure, if changing namespace implicitly is a good idea. Not saying its a bad idea, but seems to change my notion of namespaces completely.
Quoted 5 lines
I think a process should have access to one
namespace at any given point in time, and should have the ability to explicitly switch to a different namespace of its choice, provided it has enough access permission to that namespace.
I agree with Ram. This whole recent flurry of activity seems to be going down a path which will end in tears. I think Miklos' patch for allowing user mounts and Janak's patch were both more or less the direction I'd like to see us moving. Let's hold off on all these freaky shared-namespace and passed-namespace semantics until we get the basics in place and get some experience using them.
-eric
Quoted 6 lines · Eric Van Hensbergen
Quoted 6 lines
Well it makes it totally confusing. A user would start seeing different set of mounts suddenly as he changes directories beloning to different namespaces. I am not sure, if changing namespace implicitly is a good idea. Not saying its a bad idea, but seems to change my notion of namespaces completely.
Quoted 8 lines
Quoted 5 lines
I think a process should have access to one
namespace at any given point in time, and should have the ability to explicitly switch to a different namespace of its choice, provided it has enough access permission to that namespace.I agree with Ram. This whole recent flurry of activity seems to be going down a path which will end in tears.
Please read carefully: I've described what _current_ kernels do.
It's a poorly understood area of the kernel, and I'm attempting to clarify it. This talk of new system calls for entering a namespace makes no sense when you can _already_ do some things that people haven't realised the kernel does.
-- Jamie
Quoted 3 lines · Jamie Lokier
Please read carefully: I've described what _current_ kernels do.
Quoted 6 lines · I guess I misread when you
Quoted 6 lines
You can't do a lot with the new namespace, because of the security restrictions on
mount()on a foreign namespace. That's what I meant about the "small fixes" - get rid of thecurrent->namespacechecks and it'll be usable.
Quoted 6 lines
Quoted 6 lines
I don't see the purpose of
current->namespaceand the associated mount restrictions at all. I asked Al Viro what it's for, but haven't seen a reply :( IMHOcurrent->namespaceshould simply be removed, because the "current namespace" is represented just fine bycurrent->fs->rootmnt->mnt_namespace.
That sounds an awful lot like you want to make changes to the current support in the kernel.
Quoted 5 lines
It's a poorly understood area of the kernel, and I'm attempting to clarify it. This talk of new system calls for entering a namespace makes no sense when you can _already_ do some things that people haven't realised the kernel does.
IMHO part of the reason its so poorly understood is that people aren't using it. That's why I suggest we use some of the proposed patches which open up name space operations to common users. There are some security checks (like the one brought up justifying the CAP_SYS_ADMIN permissions on CLONE_NS) that need to be added, before we start removing others -- and I'm quite concerned that Viro hasn't weighed in on any of these new patches, I wonder if its because this thread seems to have gone off the deep end.
-eric
Quoted 5 lines · Eric Van Hensbergen
Quoted 2 lines · Jamie Lokier
Please read carefully: I've described what _current_ kernels do.
I guess I misread when you wrote:
There are some things which you can't do with current kernels due to the checks against current->namespace. I'm not sure how important those checks are. And there are some things which you _can_ do, such as passing directory file descriptors among processes which are in different namespaces.
-- Jamie
Quoted 5 lines · Jamie Lokier
Quoted 4 lines · Eric Van Hensbergen
Quoted 2 lines · Jamie Lokier
Please read carefully: I've described what _current_ kernels do.
Quoted 8 lines
Quoted 1 line
I guess I misread when you wrote:
There are some things which you can't do with current kernels due to the checks against
current->namespace. I'm not sure how important those checks are. And there are some things which you _can_ do, such as passing directory file descriptors among processes which are in different namespaces.
I'm not sure passing directory file descriptors is the right semantic we want - but at least it provides a point of explicit control (in much the same way as a bind). Are you sure the clone + open("/") + pass-to-parent scenario you allows the parent to traverse the child's private name space through that fd? That seems as bad as accessing pid name space via the /proc file system.
In Plan 9, file descriptors are passed between name spaces, but the only use of such a facility (described in fork(2) [plan9man]) is to pass channels to file servers which can then be mounted in a blank name space. exportfs(4)[plan9man] seems to provide a much nicer semantic for this sort of name space sharing.
Let's focus on baby steps first, and to me that's:
a) get rid of holes that allow users to traverse out of a chroot jail by using the creation of private name spaces (is anyone working on this, did I miss a patch?)
b) make CLONE_NEWNS (and any other name space creation mechanisms such as the proposed unshare system call) available to normal users
c) Get the unshare system call adopted as it seems to be generally useful
d) Get Miklos' unprivileged mount/umount patch adopted in mainline
These 4 things open up lots of opportunities and alternatives, if they prove to be insufficient then we can press forward on name spaces as first class objects, etc.
-eric
[plan9man] Plan 9 manual pages are available at
http://plan9.bell-labs.com/sys/man/index.html
Quoted 4 lines · Eric Van Hensbergen
Let's focus on baby steps first, and to me that's:
a) get rid of holes that allow users to traverse out of a chroot jail by using the creation of private name spaces (is anyone working on this, did I miss a patch?)
I have tested doing
clone(CLONE_NEWNS); chdir(/some_jail_dir); pivot_root(., tmp) umount2(tmp, MNT_DETACH) chroot(.)
which appears to prevent escapes from chroot jails. So unless my tests were insufficient, we don't need additional kernel support. We can just use something like chroot_ns.c from www.sf.net/projects/linux-jail/.
Quoted 4 lines
b) make
CLONE_NEWNS(and any other name space creation mechanisms such as the proposed unshare system call) available to normal users
c) Get the unshare system call adopted as it seems to be generally useful
d) Get Miklos' unprivileged mount/umount patch adopted in mainline
and I'd say
e) Work towards the shared namespaces, which are really one of the main reasons not to use namespaces right now.
I know this work is being done, so this isn't so much a request for the shared namespaces, as just a reminder that this will be one of the major pieces of functionality to consider along with the ones you listed.
thanks,
-serge
Quoted 5 lines · Eric Van Hensbergen
I'm not sure passing directory file descriptors is the right semantic we want - but at least it provides a point of explicit control (in much the same way as a bind). Are you sure the clone +
open("/")+ pass-to-parent scenario you allows the parent to traverse the child's private name space through that fd?
Pretty sure.
Quoted 2 lines
That seems as bad as accessing pid name space via the /proc file system.
Or good, depending on your point of view :)
Don't think of "namespaces". Think "set of mounts". Then what Linux does makes more sense.
Don't forget that if you couldn't do this, you could still use ptrace to traverse the child's namespace by tracing it.
Quoted 7 lines
In Plan 9, file descriptors are passed between name spaces, but the only use of such a facility (described in fork(2) [plan9man]) is to pass channels to file servers which can then be mounted in a blank name space. exportfs(4)[plan9man] seems to provide a much nicer semantic for this sort of name space sharing.
c) Get the unshare system call adopted as it seems to be generally useful
I'm not convinced the functionality is all that useful. It doesn't address the need which arose in this thread, which is roughly equivalent to per-user namespaces (the precise meaning determined by userspace policy). So what applicatins is it useful for? Do we have examples, or is it just a nice idea?
-- Jamie
Quoted 8 lines · Jamie Lokier
Quoted 1 line · Eric Van Hensbergen
c) Get the unshare system call adopted as it seems to be generally useful
I'm not convinced the functionality is all that useful. It doesn't address the need which arose in this thread, which is roughly equivalent to per-user namespaces (the precise meaning determined by userspace policy). So what applicatins is it useful for? Do we have examples, or is it just a nice idea?
[my last reply appears to have disappeared, apologies if two show up]
It is useful for polyinstantiated filesystems. For instance, user u1 opens two sessions, one at clearance L1:C1, one at clearance L3:C1,C2. He starts some software which expects to open tempfiles under /tmp by a particular name. He later (or simultaneously) opens it also under the lower clearance. The software now fails because it can't access the higher clearance file.
This is typically solved by creating /tmp/subdir-CLEARANCE for each clearance which needs it. Now on login, the user gets a new namespace, and /tmp/subidr-CLEARANCE is bind mounted over /tmp. (Traditionally, in other operating systems, instead of bind mounting, lookups under /tmp are just redirected to the appropriate subdir)
This is also used for other dirs, this is just one example. Note that MAC is used to actually enforce the clearances, so this is more to provide a nicer user experience. Note also that I haven't worked on such a system, so I'm just telling you what I'm told :)
Unshare is useful here because we can use it from pam. I haven't yet found how we could use clone() from inside a pam library in a meaningful way to create a new namespace for the resulting login process, so near as I can tell the alternative is to hack each login program (ssh, login, etc) separately.
Unshare should also useful for apps which want to change clearance without needing to clone. There is clearly a desire for this since the ability to transition without exec was already added to SELinux.
thanks,
-serge
Quoted 8 lines
Quoted 6 lines
I'm not sure passing directory file descriptors is the right semantic we want - but at least it provides a point of explicit control (in much the same way as a bind). Are you sure the clone +
open("/")+ pass-to-parent scenario you allows the parent to traverse the child's private name space through that fd?Pretty sure.
Yup. Attached a little program that can be used to try this out. It creates a new namespace in the child, does a bind mount (so the namespaces can be differentiated), then sends the file descriptor of "/" to the parent. The parent does fchdir(fd), then starts a shell.
So the result is that CWD is under the child namespace, while root is under the initial namespace.
I also tried bind mounting from the child's namespace to the parent's, and that works too. But the new mount's mnt_namespace is copied from the old, which makes the mount un-removable. This is most likely not intentional, IOW a bug.
Miklos
=== newns.c ========================================================= #define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <sched.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/un.h>
#include <sys/socket.h>
static int socks[2];
static int send_fd(int sock_fd, int fd)
{
int retval;
struct msghdr msg;
struct cmsghdr *p_cmsg;
struct iovec vec;
char cmsgbuf[CMSG_SPACE(sizeof(fd))];
int *p_fds;
char sendchar = 0;
msg.msg_control = cmsgbuf;
msg.msg_controllen = sizeof(cmsgbuf);
p_cmsg = CMSG_FIRSTHDR(&msg);
p_cmsg->cmsg_level = SOL_SOCKET;
p_cmsg->cmsg_type = SCM_RIGHTS;
p_cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
p_fds = (int *) CMSG_DATA(p_cmsg);
*p_fds = fd;
msg.msg_controllen = p_cmsg->cmsg_len;
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &vec;
msg.msg_iovlen = 1;
msg.msg_flags = 0;
/* "To pass file descriptors or credentials you need to send/read at
* least one byte" (man 7 unix) */
vec.iov_base = &sendchar;
vec.iov_len = sizeof(sendchar);
while ((retval = sendmsg(sock_fd, &msg, 0)) == -1 && errno == EINTR);
if (retval != 1) {
perror("sending file descriptor");
return -1;
}
return 0;
}static int receive_fd(int fd)
{
struct msghdr msg;
struct iovec iov;
char buf[1];
int rv;
int connfd = -1;
char ccmsg[CMSG_SPACE(sizeof(connfd))];
struct cmsghdr *cmsg;
iov.iov_base = buf;
iov.iov_len = 1;
msg.msg_name = 0;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
/* old BSD implementations should use msg_accrights instead of
* msg_control; the interface is different. */
msg.msg_control = ccmsg;
msg.msg_controllen = sizeof(ccmsg);
while(((rv = recvmsg(fd, &msg, 0)) == -1) && errno == EINTR);
if (rv == -1) {
perror("recvmsg");
return -1;
}
if(!rv) {
/* EOF */
return -1;
}
cmsg = CMSG_FIRSTHDR(&msg);
if (!cmsg->cmsg_type == SCM_RIGHTS) {
fprintf(stderr, "got control message of unknown type %d\n",
cmsg->cmsg_type);
return -1;
}
return *(int*)CMSG_DATA(cmsg);
}int childfn(void *p)
{
int fd;
(void) p;
mkdir("/tmp/clonetest", 755);
mkdir("/tmp/clonetest/dir1", 755);
mkdir("/tmp/clonetest/dir1/subdir1", 755);
mkdir("/tmp/clonetest/mnt", 755);
system("mount --bind /tmp/clonetest/dir1 /tmp/clonetest/mnt");
fd = open("/", O_RDONLY | O_DIRECTORY);
send_fd(socks[0], fd);
sleep(1000);
return 1;
}int main()
{
char buf[10000];
pid_t pid;
int res;
int childfd;
res = socketpair(AF_UNIX, SOCK_STREAM, 0, socks);
if (res == -1) {
perror("socketpair");
return 1;
}
pid = clone(childfn, buf+5000, CLONE_NEWNS | SIGCHLD, NULL);
if ((int) pid == -1) {
perror("clone");
exit(1);
}
childfd = receive_fd(socks[1]);
res = fchdir(childfd);
if (res == -1) {
perror("fchdir");
return 1;
}
execl("/bin/bash", "/bin/bash", NULL);
return 0;
}Quoted 4 lines · Miklos Szeredi
I also tried bind mounting from the child's namespace to the parent's, and that works too. But the new mount's
mnt_namespaceis copied from the old, which makes the mount un-removable. This is most likely not intentional, IOW a bug.
I agree about the bug (and it's why I think the current->namespace checks in fs/namespace.c should be killed - the _only_ effect is to make un-removable mounts like the above, and the checks are completely redundant for "normal" namespace operations).
I think the best thing to do for "jails" and such is to think of a private namespace as a collection of bind mounts in a private tree that (normally) cannot be reached from elsewhere, not can it reach elsewhere.
And leave it to adminstration to ensure that a tree isn't visible from another tree if you don't want it to be for security purposes. That basically amounts to making sure processes that shouldn't communicate or ptrace each other can't.
With that view, the kernel's notion of "namespace" is redundant. It doesn't add anything to the security model, and it doesn't add any useful functionality.
It's an abstract idea which does not need to be supported by kernel code, except for the CLONE_NEWNS operation which actually means "copy all mounts found recursively starting from the current root) to a new tree of mounts, and chroot to the new tree".
In other words, is ->mnt_namespace required at all, except to contain namespace->sem (which could be changed)? I don't think it adds anything realistic to security. The way to make secure jails is to isolated their trees so they are unreachable. ->mnt_namespace doesn't make any difference to that.
-- Jamie
Quoted 11 lines
I think the best thing to do for "jails" and such is to think of a private namespace as a collection of bind mounts in a private tree that (normally) cannot be reached from elsewhere, not can it reach elsewhere.
And leave it to adminstration to ensure that a tree isn't visible from another tree if you don't want it to be for security purposes. That basically amounts to making sure processes that shouldn't communicate or ptrace each other can't.
With that view, the kernel's notion of "namespace" is redundant.
I'm not sure.
Quoted 2 lines
It doesn't add anything to the security model, and it doesn't add any useful functionality.
Struct namespace is pretty small, so let's see:
1) count: reference count for the "tree"
if you remove this, how will you know when to "unmount" the tree?
2) root: the root of the tree
needed for the unmount, when the namespace has no more references
3) list: flat list of mounts in the tree
used by /proc/PID/mounts, but probably not strictly needed
4) sem: protects the mount list and the tree from modification
could be removed in favor of a global lock, but that would increase contention
Quoted 5 lines
In other words, is ->mnt_namespace required at all, except to contain
namespace->sem(which could be changed)? I don't think it adds anything realistic to security. The way to make secure jails is to isolated their trees so they are unreachable. ->mnt_namespace doesn't make any difference to that.
Probably true. check_mnt() is there to make sure only trees protected by namespace->sem are modified, and is not a security check. That is why the recursive bind mount from foreign namespace is not allowed, while the simple bind mount is.
Miklos
Quoted 8 lines · Miklos Szeredi
Quoted 7 lines
Quoted 5 lines
I'm not sure passing directory file descriptors is the right semantic we want - but at least it provides a point of explicit control (in much the same way as a bind). Are you sure the clone +
open("/")+ pass-to-parent scenario you allows the parent to traverse the child's private name space through that fd?Pretty sure.
Quoted 9 lines
Yup. Attached a little program that can be used to try this out. It creates a new namespace in the child, does a bind mount (so the namespaces can be differentiated), then sends the file descriptor of "/" to the parent. The parent does fchdir(fd), then starts a shell.
So the result is that CWD is under the child namespace, while root is under the initial namespace.
r u sure, this program works? Sorry if I am saying something dumb here. Correct me. When a file descriptor is sent from one process to other, arn't they referring to different files in each of the processes. fd=5 may be pointing to file 'xyz' in parent process,
where as fd=5 will be pointing to 'abc' in the child process.
This program did not work for me, and I was wondering if adding CLONE_FILES in clone() would help. Because that would make sure
that both
the processes share the same file descriptor. It did not work too.
What am I understanding wrong?
In any case my opinion is if this program works than the hole should be closed instead of exploting it to access different namespace. I know Jamie is going to pounce at me. ;)
RP
Quoted 145 lines
I also tried bind mounting from the child's namespace to the parent's, and that works too. But the new mount's
mnt_namespaceis copied from the old, which makes the mount un-removable. This is most likely not intentional, IOW a bug.Miklos
===
newns.c========================================================= #define_GNU_SOURCE#include <
stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <sched.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/un.h>
#include <sys/socket.h>static int socks[2];
static int
send_fd(int sock_fd, int fd){ int retval; struct msghdr msg; struct cmsghdr *p_cmsg; struct iovec vec; char cmsgbuf[CMSG_SPACE(sizeof(fd))]; int *p_fds; char sendchar = 0; msg.msg_control = cmsgbuf; msg.msg_controllen = sizeof(cmsgbuf); p_cmsg = CMSG_FIRSTHDR(&msg); p_cmsg->cmsg_level = SOL_SOCKET; p_cmsg->cmsg_type = SCM_RIGHTS; p_cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); p_fds = (int *) CMSG_DATA(p_cmsg); *p_fds = fd; msg.msg_controllen = p_cmsg->cmsg_len; msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &vec; msg.msg_iovlen = 1; msg.msg_flags = 0; /* "To pass file descriptors or credentials you need to send/read at * least one byte" (man 7 unix) */ vec.iov_base = &sendchar; vec.iov_len = sizeof(sendchar); while ((retval = sendmsg(sock_fd, &msg, 0)) == -1 && errno == EINTR); if (retval != 1) { perror("sending file descriptor"); return -1; } return 0; }static int
receive_fd(int fd){ struct msghdr msg; struct iovec iov; char buf[1]; int rv; int connfd = -1; char ccmsg[CMSG_SPACE(sizeof(connfd))]; struct cmsghdr *cmsg; iov.iov_base = buf; iov.iov_len = 1; msg.msg_name = 0; msg.msg_namelen = 0; msg.msg_iov = &iov; msg.msg_iovlen = 1; /* old BSD implementations should use msg_accrights instead of * msg_control; the interface is different. */ msg.msg_control = ccmsg; msg.msg_controllen = sizeof(ccmsg); while(((rv = recvmsg(fd, &msg, 0)) == -1) && errno == EINTR); if (rv == -1) { perror("recvmsg"); return -1; } if(!rv) { /* EOF */ return -1; } cmsg = CMSG_FIRSTHDR(&msg); if (!cmsg->cmsg_type == SCM_RIGHTS) { fprintf(stderr, "got control message of unknown type %d\n", cmsg->cmsg_type); return -1; } return *(int*)CMSG_DATA(cmsg); }int
childfn(void *p){ int fd; (void) p; mkdir("/tmp/clonetest", 755); mkdir("/tmp/clonetest/dir1", 755); mkdir("/tmp/clonetest/dir1/subdir1", 755); mkdir("/tmp/clonetest/mnt", 755); system("mount --bind /tmp/clonetest/dir1 /tmp/clonetest/mnt"); fd = open("/", O_RDONLY | O_DIRECTORY); send_fd(socks[0], fd); sleep(1000); return 1; }int
main(){ char buf[10000]; pid_t pid; int res; int childfd; res = socketpair(AF_UNIX, SOCK_STREAM, 0, socks); if (res == -1) { perror("socketpair"); return 1; } pid = clone(childfn, buf+5000, CLONE_NEWNS | SIGCHLD, NULL); if ((int) pid == -1) { perror("clone"); exit(1); } childfd = receive_fd(socks[1]); res = fchdir(childfd); if (res == -1) { perror("fchdir"); return 1; } execl("/bin/bash", "/bin/bash", NULL); return 0; }
Quoted 1 line
r u sure, this program works?
Yes :)
Quoted 5 lines
Sorry if I am saying something dumb here.
Correct me. When a file descriptor is sent from one process to other, arn't they referring to different files in each of the processes. fd=5 may be pointing to file 'xyz' in parent process,
where as fd=5 will be pointing to 'abc' in the child process.
See 'man 7 unix' SCM_RIGHTS.
How do you know the program did not work?
Note: the program starts a new shell, it doesn't exit! Do this in the started shell (do not 'cd' before it):
ls tmp/clonetest/mnt
ls /tmp/clonetest/mnt
If you see different things, then the program worked.
It's not such a magic thing. You can also do something similar for example by:
shell1> mount --bind / /tmp/mnt shell1> cd /tmp/mnt sheel2> umount -l /tmp/mnt
Now shell1 sees two separate "namespaces" in in CWD and /
Miklos
Quoted 25 lines · Ram
Quoted 8 lines · Miklos Szeredi
Quoted 7 lines
Quoted 5 lines
I'm not sure passing directory file descriptors is the right semantic we want - but at least it provides a point of explicit control (in much the same way as a bind). Are you sure the clone +
open("/")+ pass-to-parent scenario you allows the parent to traverse the child's private name space through that fd?Pretty sure.
Quoted 9 lines
Yup. Attached a little program that can be used to try this out. It creates a new namespace in the child, does a bind mount (so the namespaces can be differentiated), then sends the file descriptor of "/" to the parent. The parent does fchdir(fd), then starts a shell.
So the result is that CWD is under the child namespace, while root is under the initial namespace.
r u sure, this program works? Sorry if I am saying something dumb here. Correct me. When a file descriptor is sent from one process to other, arn't they referring to different files in each of the processes. fd=5 may be pointing to file 'xyz' in parent process,
where as fd=5 will be pointing to 'abc' in the child process.
Quoted 6 lines
This program did not work for me, and I was wondering if adding
CLONE_FILESinclone()would help. Because that would make sure
that both
the processes share the same file descriptor. It did not work too.What am I understanding wrong?
Sorry it works. I was misinterpreting the results.
Quoted 4 lines
In any case my opinion is if this program works than the hole should be closed instead of exploting it to access different namespace. I know Jamie is going to pounce at me. ;)
a patch is due to fix the problem :)
RP
Quoted 33 lines · Ram
Quoted 25 lines · Ram
Quoted 8 lines · Miklos Szeredi
Quoted 7 lines
Quoted 5 lines
I'm not sure passing directory file descriptors is the right semantic we want - but at least it provides a point of explicit control (in much the same way as a bind). Are you sure the clone +
open("/")+ pass-to-parent scenario you allows the parent to traverse the child's private name space through that fd?Pretty sure.
Quoted 9 lines
Yup. Attached a little program that can be used to try this out. It creates a new namespace in the child, does a bind mount (so the namespaces can be differentiated), then sends the file descriptor of "/" to the parent. The parent does fchdir(fd), then starts a shell.
So the result is that CWD is under the child namespace, while root is under the initial namespace.
r u sure, this program works? Sorry if I am saying something dumb here. Correct me. When a file descriptor is sent from one process to other, arn't they referring to different files in each of the processes. fd=5 may be pointing to file 'xyz' in parent process,
where as fd=5 will be pointing to 'abc' in the child process.Quoted 6 lines
This program did not work for me, and I was wondering if adding
CLONE_FILESinclone()would help. Because that would make sure
that both
the processes share the same file descriptor. It did not work too.What am I understanding wrong?
Quoted 8 lines
Sorry it works. I was misinterpreting the results.
Quoted 4 lines
In any case my opinion is if this program works than the hole should be closed instead of exploting it to access different namespace. I know Jamie is going to pounce at me. ;)
a patch is due to fix the problem :)
attached a patch that can fix the problem, if everybody agrees that its a problem.
Quoted 2 lines
RP
fs/open.c renamed from home/linux/views/linux-2.6.12-rc4/fs/open.c +2 -0
@@ -552,6 +552,8 @@ dentry = file->f_dentry; mnt = file->f_vfsmnt; inode = dentry->d_inode; +if (mnt->mnt_namespace != current->namespace) + goto out_putf; error = -ENOTDIR ;if (!S_ISDIR (inode->i_mode))
Review
Quoted 10 lines
(quoted diff) +2
-0dentry = file->f_dentry; mnt = file->f_vfsmnt; inode = dentry->d_inode; + if(mnt->mnt_namespace != current->namespace) + goto out_putf; error = -ENOTDIR; if (!S_ISDIR(inode->i_mode))
Does this actually fix the problem? The open is done in the right namespace, and mount() doesn't call open().
I think the right fix is something like this:
fs/namespace.c +1 -1
@@ -160,7 +160,7 @@ clone_mnt(struct vfsmount *old, struct d mnt->mnt_root =dget (root); mnt->mnt_mountpoint = mnt->mnt_root; mnt->mnt_parent = mnt; - mnt->mnt_namespace = old->mnt_namespace; + mnt->mnt_namespace = current->namespace;/* stick the duplicate mount on the same expiry list * as the original if that was on one */
Quoted 6 lines · Miklos Szeredi
Quoted 6 lines
(quoted diff) +2
-0dentry = file->f_dentry; mnt = file->f_vfsmnt; inode = dentry->d_inode; + if(mnt->mnt_namespace != current->namespace) + goto out_putf;
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +0
-0error = -ENOTDIR; if (!S_ISDIR(inode->i_mode))Does this actually fix the problem? The open is done in the right namespace, and
mount()doesn't callopen().
Right but this fix disallows fchdir into a directory belonging to a different namespace. And hence would disallow the ability to cross mount across namespaces.
RP
Quoted 23 lines
I think the right fix is something like this:
Index:
linux/fs/namespace.c
===================================================================fs/namespace.c +1
-1@@ -160,7 +160,7 @@ clone_mnt(struct vfsmount *old, struct d mnt->mnt_root =dget (root); mnt->mnt_mountpoint = mnt->mnt_root; mnt->mnt_parent = mnt; - mnt->mnt_namespace = old->mnt_namespace; + mnt->mnt_namespace = current->namespace;fs/namespace.c +0
-1/* stick the duplicate mount on the same expiry list * as the original if that was on one */ -To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +2
-0dentry = file->f_dentry; mnt = file->f_vfsmnt; inode = dentry->d_inode; + if(mnt->mnt_namespace != current->namespace) + goto out_putf;Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +0
-0error = -ENOTDIR; if (!S_ISDIR(inode->i_mode))Does this actually fix the problem? The open is done in the right namespace, and
mount()doesn't callopen().
Quoted 3 lines
Right but this fix disallows fchdir into a directory belonging to a different namespace. And hence would disallow the ability to cross mount across namespaces.
Ahh, sorry. I thought that check was in open(), but I see now it's in fchdir(). Next time please use '-p' option of diff, to avoid confusing thoughtless readers like me :)
Though your patch does fix the bug, I still think it's wrong, since mounting from a different namespace has legitimate uses, and is not a security problem.
Miklos
Quoted 3 lines
Right but this fix disallows fchdir into a directory belonging to a different namespace. And hence would disallow the ability to cross mount across namespaces.
A helper can still pass file handles for you, you've changed the semantics a little (and I'm not clear if there is a need to) but I don't see it serves any fundamental purpose. Historical experience is that chroot exiting via fchdir is actually useful
Quoted 2 lines
Sorry if I am saying something dumb here.
Correct me. When a file descriptor is sent from one process to other,
This confusion, incidentally, is brought to you by the ambiguous use of the term "file descriptor." In classic Unix, the "file descriptor" is the integer that open() returns. It's an improper use of the term "descriptor," as this value does not describe but identifies. But in the SCM_RIGHTS context, the term "file descriptor" is used to refer to a handle for a file image. While it's true that a file descriptor goes in one end of the pipe and a (generally different) file descriptor comes out the other end, what's being passed is a handle for a file image (aka open instance).
--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems
Quoted 10 lines · Ram
Quoted 1 line
Can you give a reason why
sys_chdir()shouldn't have that behaviour?Do you mean to say you want to change the namespace when a process changes to a directory which belongs to that namespace?
Well it makes it totally confusing. A user would start seeing different set of mounts suddenly as he changes directories beloning to different namespaces. I am not sure, if changing namespace implicitly is a good idea. Not saying its a bad idea, but seems to change my notion of namespaces completely.
That happens _already_. I'm not suggesting it, it's been there in the kernel for ages.
Let me explain how namespaces _really_ work in Linux.
For path lookup, mounts are just mappings from (dentry,vfsmnt) to (dentry,vfsmnt). There's a unique vfsmnt for each (filesystem,namespace) pair, by the way.
During path lookup, each path component moves from one (dentry,vfsmnt) pair to the next. vfsmnt doesn't change from one dentry to the next while following a path component. But then, if there's a mount whose key is the current (dentry,vfsmnt) pair, the current pair is replaced by the value of the mount.
Notice how namespaces aren't involved in path lookup at all.
That's nothing new: it's what Linux does already.
If that seems confusing, it's because _bind mounts_ are confusing.
Namespaces don't really exist. When you create a new namespace with CLONE_NEWNS, all that really happens is a lot of bind mounts, to create a copy of the current directory tree, and then chrooting into that tree (in effect).
Quoted 3 lines
having the ability to access two namespaces simultaneously can allow cross contamination. Which essentially makes namespaces as a concept irrelevent.
Cross contamination is already possible, using file descriptor passing or ptrace().
Also, your suggested new syscall for accessing another namespace would have exactly the same effect, wouldn't it? :)
-- Jamie
Quoted 38 lines · Jamie Lokier
Quoted 10 lines · Ram
Quoted 1 line
Can you give a reason why
sys_chdir()shouldn't have that behaviour?Do you mean to say you want to change the namespace when a process changes to a directory which belongs to that namespace?
Well it makes it totally confusing. A user would start seeing different set of mounts suddenly as he changes directories beloning to different namespaces. I am not sure, if changing namespace implicitly is a good idea. Not saying its a bad idea, but seems to change my notion of namespaces completely.
That happens _already_. I'm not suggesting it, it's been there in the kernel for ages.
Let me explain how namespaces _really_ work in Linux.
For path lookup, mounts are just mappings from (dentry,vfsmnt) to (dentry,vfsmnt). There's a unique vfsmnt for each (filesystem,namespace) pair, by the way.
During path lookup, each path component moves from one (dentry,vfsmnt) pair to the next. vfsmnt doesn't change from one dentry to the next while following a path component. But then, if there's a mount whose key is the current (dentry,vfsmnt) pair, the current pair is replaced by the value of the mount.
Notice how namespaces aren't involved in path lookup at all.
That's nothing new: it's what Linux does already.
If that seems confusing, it's because
_bindmounts_are confusing.Namespaces don't really exist. When you create a new namespace with
CLONE_NEWNS, all that really happens is a lot of bind mounts, to create a copy of the current directory tree, and then chrooting into that tree (in effect).
Quoted 6 lines
Quoted 3 lines
having the ability to access two namespaces simultaneously can allow cross contamination. Which essentially makes namespaces as a concept irrelevent.
Cross contamination is already possible, using file descriptor passing or
ptrace().
I am yet to convince myself that this is possible. Maybe possible and if its possible we should close those holes.
Quoted 3 lines
Also, your suggested new syscall for accessing another namespace would have exactly the same effect, wouldn't it? :)
No it wont. a process can contaminate namespaces if the process has access to both the namespace simultaneously. With the proposed syscall, the process would have access to one namespace at any given point in time. There cannot be a instance where a process will have access to vfsmounts belonging to two different namespaces.
So I dont' think contamination is possible. By contamination I mean 'ability for a process to bind mount from one namespace to other'
RP
Quoted 2 lines
-- Jamie
Quoted 5 lines · Miklos Szeredi
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
How about a new clone option "
CLONE_NOSUID"?IMO, the clone call ist the wrong place to create namespaces. It should be deprecated by a mkdir/chdir-like interface.
Quoted 7 lines
Quoted 1 line
And the mkdir/chdir interface already exists, see "cd
/proc/NNN/root".That's the chdir part.
The mkdir part is
clone()orunshare().How else do you propose to create new namespaces?
This is not a proposal - I'm not saying it's pretty - but a suggestion that you can use today.
Use clone(), and then have the child task open "/" and pass that file descriptor back to the parent process using a unix socket. The child can exit and the parent can use the new namespace how it likes. Short and sweet, and you can create as many namespaces as you like :)
That's mkdir done.
You can't do a lot with the new namespace, because of the security restrictions on mount() on a foreign namespace. That's what I meant about the "small fixes" - get rid of the current->namespace checks and it'll be usable.
I don't see the purpose of current->namespace and the associated mount restrictions at all. I asked Al Viro what it's for, but haven't seen a reply :( IMHO current->namespace should simply be removed, because the "current namespace" is represented just fine by current->fs->rootmnt->mnt_namespace.
-- Jamie
Quoted 9 lines
This is not a proposal - I'm not saying it's pretty - but a suggestion that you can use today.
Use
clone(), and then have the child task open "/" and pass that file descriptor back to the parent process using a unix socket. The child can exit and the parent can use the new namespace how it likes. Short and sweet, and you can create as many namespaces as you like :)That's mkdir done.
Right.
Quoted 10 lines
You can't do a lot with the new namespace, because of the security restrictions on
mount()on a foreign namespace. That's what I meant about the "small fixes" - get rid of thecurrent->namespacechecks and it'll be usable.I don't see the purpose of
current->namespaceand the associated mount restrictions at all. I asked Al Viro what it's for, but haven't seen a reply :( IMHOcurrent->namespaceshould simply be removed, because the "current namespace" is represented just fine bycurrent->fs->rootmnt->mnt_namespace.
I'll look at what it would take to remove current->namespace.
Miklos
Quoted 7 lines · Miklos Szeredi
Quoted 5 lines
I don't see the purpose of
current->namespaceand the associated mount restrictions at all. I asked Al Viro what it's for, but haven't seen a reply :( IMHOcurrent->namespaceshould simply be removed, because the "current namespace" is represented just fine bycurrent->fs->rootmnt->mnt_namespace.I'll look at what it would take to remove
current->namespace.
The security implications don't seem to be important. If you don't want someone to access a namespace, then don't make it accessible.
But knowing Al it might exist for some subtle locking reason. Be sure to study the locking carefully :)
-- Jamie
Quoted 8 lines · Jamie Lokier
Quoted 4 lines · Bodo Eggert
Quoted 1 line
How about a new clone option "
CLONE_NOSUID"?IMO, the clone call ist the wrong place to create namespaces. It should be deprecated by a mkdir/chdir-like interface.
And the mkdir/chdir interface already exists, see "cd
/proc/NNN/root".
If you want persistent namespaces, this will be a PITA (I don't want a keep-the-namespace-open-daemon), and if you don't, it will be racy (user a logs in, while his second/nth login expires).
Keeping a list of named namespaces in kernel can be made cheap and secure.
Signature · 1 line
Friendly fire isn't.
Quoted 5 lines · Bodo Eggert
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
How about a new clone option "
CLONE_NOSUID"?IMO, the clone call ist the wrong place to create namespaces. It should be deprecated by a mkdir/chdir-like interface.
Quoted 7 lines
Quoted 1 line
And the mkdir/chdir interface already exists, see "cd
/proc/NNN/root".If you want persistent namespaces, this will be a PITA (I don't want a keep-the-namespace-open-daemon), and if you don't, it will be racy (user a logs in, while his second/nth login expires).
Keeping a list of named namespaces in kernel can be made cheap and secure.
Still easy.
To keep persistent named namespaces in /var/namespaces, thus:
# Just once please!
mount -t tmpfs none /var/namespaces
# Make a named namespace.
NSNAME='fred'
mkdir /var/namespaces/$NSNAME
run_in_new_namespace mount -t bind / /var/namespaces/$NSNAME
# Make a named namespace for the _original_ namespace. mkdir /var/namespaces/initial
mount -t bind / /var/namespaces/initial
# Access the namespace.
ls /var/namespaces/fred
# Enter the namespace.
chroot /var/namespaces/fred
# Delete a named namespace.
NSNAME='fred'
umount /var/namespaces/$NSNAME
rmdir /var/namespaces/$NSNAME
Some of the above will fail due to security checks in fs/namespace.c, where it tests against current->namespace. Without those checks, which seem to have no purpose _other_ than preventing the above usage, I think the above would all work.
-- Jamie
Quoted 11 lines
Still easy.
To keep persistent named namespaces in
/var/namespaces, thus:# Just once please!
mount -t tmpfs none/var/namespaces# Make a named namespace.
NSNAME='fred'
mkdir/var/namespaces/$NSNAME
run_in_new_namespacemount -t bind //var/namespaces/$NSNAME
That's not going to work, since the mount will only affect the new namespace. You'd need clone(), and then in the original namespace
mount --bind /proc/CHILDPID/root /var/namespace/$NSNAME
and then child process can safely exit.
Miklos
Quoted 7 lines · Miklos Szeredi
Quoted 4 lines
# Make a named namespace.
NSNAME='fred'
mkdir/var/namespaces/$NSNAME
run_in_new_namespacemount -t bind //var/namespaces/$NSNAMEThat's not going to work, since the mount will only affect the new namespace.
Ah, good point. I'm still thinking in terms of shared subtrees, where it might work.
Quoted 5 lines
You'd need
clone(), and then in the original namespacemount --bind /proc/CHILDPID/root /var/namespace/$NSNAMEand then child process can safely exit.
Or pass the file descriptor over a unix domain socket, so that it doesn't need /proc.
-- Jamie
Quoted 11 lines · Jamie Lokier
Quoted 7 lines · Miklos Szeredi
Quoted 4 lines
# Make a named namespace.
NSNAME='fred'
mkdir/var/namespaces/$NSNAME
run_in_new_namespacemount -t bind //var/namespaces/$NSNAMEThat's not going to work, since the mount will only affect the new namespace.
Ah, good point. I'm still thinking in terms of shared subtrees, where it might work.
Oh! Well, I hope it's safe to assume we'll have those "soon"!
-serge