lkml.org 
[lkml]   [2008]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch 11/11] unprivileged mounts: copy mount ownership on namespace cloning
From: Miklos Szeredi <mszeredi@suse.cz>

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

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
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 *);
--


\
 
 \ /
  Last update: 2008-03-17 21:09    [W:0.080 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site