[PATCH 22/27] r-o-bind-mounts-nfs-check-mnt-instead-of-superblock-directly

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <akpm@...>
Cc: <linux-kernel@...>, <miklos@...>, <hch@...>, Dave Hansen <haveblue@...>
Date: Thursday, November 1, 2007 - 7:08 pm

If we depend on the inodes for writeability, we will not catch the r/o mounts
when implemented.

This patches uses __mnt_want_write().  It does not guarantee that the mount
will stay writeable after the check.  But, this is OK for one of the checks
because it is just for a printk().

The other two are probably unnecessary and duplicate existing checks in the
VFS.  This won't make them better checks than before, but it will make them
detect r/o mounts.

Acked-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 linux-2.6.git-dave/fs/nfs/dir.c  |    3 ++-
 linux-2.6.git-dave/fs/nfsd/vfs.c |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff -puN fs/nfs/dir.c~r-o-bind-mounts-nfs-check-mnt-instead-of-superblock-directly fs/nfs/dir.c
--- linux-2.6.git/fs/nfs/dir.c~r-o-bind-mounts-nfs-check-mnt-instead-of-superblock-directly	2007-11-01 14:46:19.000000000 -0700
+++ linux-2.6.git-dave/fs/nfs/dir.c	2007-11-01 14:46:19.000000000 -0700
@@ -949,7 +949,8 @@ static int is_atomic_open(struct inode *
 	if (nd->flags & LOOKUP_DIRECTORY)
 		return 0;
 	/* Are we trying to write to a read only partition? */
-	if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
+	if (__mnt_is_readonly(nd->mnt) &&
+	    (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
 		return 0;
 	return 1;
 }
diff -puN fs/nfsd/vfs.c~r-o-bind-mounts-nfs-check-mnt-instead-of-superblock-directly fs/nfsd/vfs.c
--- linux-2.6.git/fs/nfsd/vfs.c~r-o-bind-mounts-nfs-check-mnt-instead-of-superblock-directly	2007-11-01 14:46:19.000000000 -0700
+++ linux-2.6.git-dave/fs/nfsd/vfs.c	2007-11-01 14:46:19.000000000 -0700
@@ -1862,7 +1862,7 @@ nfsd_permission(struct svc_rqst *rqstp, 
 		inode->i_mode,
 		IS_IMMUTABLE(inode)?	" immut" : "",
 		IS_APPEND(inode)?	" append" : "",
-		IS_RDONLY(inode)?	" ro" : "");
+		__mnt_is_readonly(exp->ex_mnt)?	" ro" : "");
 	dprintk("      owner %d/%d user %d/%d\n",
 		inode->i_uid, inode->i_gid, current->fsuid, current->fsgid);
 #endif
@@ -1873,7 +1873,7 @@ nfsd_permission(struct svc_rqst *rqstp, 
 	 */
 	if (!(acc & MAY_LOCAL_ACCESS))
 		if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
-			if (exp_rdonly(rqstp, exp) || IS_RDONLY(inode))
+			if (exp_rdonly(rqstp, exp) || __mnt_is_readonly(exp->ex_mnt))
 				return nfserr_rofs;
 			if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
 				return nfserr_perm;
_
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/27] Read-only bind mounts (-mm resend), Dave Hansen, (Thu Nov 1, 7:08 pm)
[PATCH 22/27] r-o-bind-mounts-nfs-check-mnt-instead-of-super..., Dave Hansen, (Thu Nov 1, 7:08 pm)
[PATCH 06/27] r-o-bind-mounts-stub-functions, Dave Hansen, (Thu Nov 1, 7:08 pm)
[PATCH 05/27] rename open_namei() to open_pathname(), Dave Hansen, (Thu Nov 1, 7:08 pm)
Re: [PATCH 05/27] rename open_namei() to open_pathname(), Christoph Hellwig, (Mon Nov 26, 10:33 am)
[PATCH 04/27] kill filp_open(), Dave Hansen, (Thu Nov 1, 7:08 pm)
Re: [PATCH 04/27] kill filp_open(), Andrew Morton, (Wed Jan 16, 4:52 am)
Re: [PATCH 04/27] kill filp_open(), Dave Hansen, (Wed Jan 16, 1:04 pm)
Re: [PATCH 04/27] kill filp_open(), Bryn M. Reeves, (Wed Jan 16, 1:12 pm)
Re: [PATCH 04/27] kill filp_open(), Christoph Hellwig, (Wed Jan 16, 1:10 pm)
Re: [PATCH 04/27] kill filp_open(), Dave Hansen, (Wed Jan 16, 1:41 pm)
Re: [PATCH 04/27] kill filp_open(), Christoph Hellwig, (Wed Jan 16, 1:47 pm)
[PATCH 03/27] kill do_filp_open(), Dave Hansen, (Thu Nov 1, 7:08 pm)
[PATCH 02/27] make open_namei() return a filp, Dave Hansen, (Thu Nov 1, 7:08 pm)