[patch 11/11] unprivileged mounts: copy mount ownership on namespace cloning

From: Miklos Szeredi
Date: Mon Mar 17 2008 - 16:05:28 EST


From: Miklos Szeredi <mszeredi@xxxxxxx>

Mount ownership wasn't copied on CLONE_NEWNS. Noticed by Al Viro.

Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxx>
---
fs/namespace.c | 7 ++++++-
fs/pnode.h | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)

Index: linux/fs/namespace.c
===================================================================
--- linux.orig/fs/namespace.c 2008-03-17 20:55:53.000000000 +0100
+++ linux/fs/namespace.c 2008-03-17 20:55:53.000000000 +0100
@@ -585,6 +585,11 @@ static struct vfsmount *clone_mnt(struct
struct super_block *sb = old->mnt_sb;
struct vfsmount *mnt;

+ if ((flag & CL_COPYUSER) && (old->mnt_flags & MNT_USER)) {
+ owner = old->mnt_uid;
+ flag |= CL_SETUSER;
+ }
+
if (flag & CL_SETUSER) {
int err = reserve_user_mount();
if (err)
@@ -2141,7 +2146,7 @@ static struct mnt_namespace *dup_mnt_ns(
down_write(&namespace_sem);
/* First pass: copy the tree topology */
new_ns->root = copy_tree(mnt_ns->root, mnt_ns->root->mnt_root,
- CL_COPY_ALL | CL_EXPIRE, 0);
+ CL_COPY_ALL | CL_EXPIRE | CL_COPYUSER, 0);
if (IS_ERR(new_ns->root)) {
up_write(&namespace_sem);
kfree(new_ns);
Index: linux/fs/pnode.h
===================================================================
--- linux.orig/fs/pnode.h 2008-03-17 20:55:52.000000000 +0100
+++ linux/fs/pnode.h 2008-03-17 20:55:53.000000000 +0100
@@ -24,6 +24,7 @@
#define CL_PRIVATE 0x20
#define CL_SETUSER 0x40
#define CL_NOSUID 0x80
+#define CL_COPYUSER 0x100

void set_mnt_shared(struct vfsmount *);
void clear_mnt_shared(struct vfsmount *);

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