[Vserver] [PATCH 05/10] vfs: propagate vfsmount into chown_common()

From: Sam Vilain <sam.vilain_at_catalyst.net.nz>
Date: Mon 27 Feb 2006 - 05:25:31 GMT
Message-Id: <20060227052531.21148.66657.stgit@wilber.wgtn.cat-it.co.nz>

From: Herbert Pƶtzl <herbert@13thfloor.at>

Previously, chown_common just deals in dentry structures, which are
not connected to the mount whence they came.

As the permissions for the dentry may now vary depending on which VFS
point the dentry came from, the vfsmount struct is propagated into
chown_common() to allow for vfsmount based checks there.

An accompanying MNT_IS_RDONLY() check inside chown_common rejects
changes to the dentry.

Acked-by: Sam Vilain <sam.vilain@catalyst.net.nz>

---
 fs/open.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/fs/open.c b/fs/open.c
index 70e0230..8632721 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -686,7 +686,8 @@ asmlinkage long sys_chmod(const char __u
 	return sys_fchmodat(AT_FDCWD, filename, mode);
 }
 
-static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
+static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
+	uid_t user, gid_t group)
 {
 	struct inode * inode;
 	int error;
@@ -698,7 +699,7 @@ static int chown_common(struct dentry * 
 		goto out;
 	}
 	error = -EROFS;
-	if (IS_RDONLY(inode))
+	if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
 		goto out;
 	error = -EPERM;
 	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
@@ -728,7 +729,7 @@ asmlinkage long sys_chown(const char __u
 
 	error = user_path_walk(filename, &nd);
 	if (!error) {
-		error = chown_common(nd.dentry, user, group);
+		error = chown_common(nd.dentry, nd.mnt, user, group);
 		path_release(&nd);
 	}
 	return error;
@@ -761,7 +762,7 @@ asmlinkage long sys_lchown(const char __
 
 	error = user_path_walk_link(filename, &nd);
 	if (!error) {
-		error = chown_common(nd.dentry, user, group);
+		error = chown_common(nd.dentry, nd.mnt, user, group);
 		path_release(&nd);
 	}
 	return error;
@@ -775,7 +776,7 @@ asmlinkage long sys_fchown(unsigned int 
 
 	file = fget(fd);
 	if (file) {
-		error = chown_common(file->f_dentry, user, group);
+		error = chown_common(file->f_dentry, file->f_vfsmnt, user, group);
 		fput(file);
 	}
 	return error;
_______________________________________________
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver
Received on Mon Feb 27 06:10:09 2006
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Mon 27 Feb 2006 - 06:10:11 GMT by hypermail 2.1.8