The patch titled r/o bind mounts: check mnt instead of superblock directly has been added to the -mm tree. Its filename is r-o-bind-mounts-check-mnt-instead-of-superblock-directly.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: r/o bind mounts: check mnt instead of superblock directly From: Dave Hansen <haveblue@xxxxxxxxxx> 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: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Signed-off-by: Christoph Hellwig <hch@xxxxxxxxxxxxx> Signed-off-by: Dave Hansen <haveblue@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/nfs/dir.c | 3 ++- fs/nfsd/vfs.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff -puN fs/nfs/dir.c~r-o-bind-mounts-check-mnt-instead-of-superblock-directly fs/nfs/dir.c --- a/fs/nfs/dir.c~r-o-bind-mounts-check-mnt-instead-of-superblock-directly +++ a/fs/nfs/dir.c @@ -967,7 +967,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-check-mnt-instead-of-superblock-directly fs/nfsd/vfs.c --- a/fs/nfsd/vfs.c~r-o-bind-mounts-check-mnt-instead-of-superblock-directly +++ a/fs/nfsd/vfs.c @@ -1874,7 +1874,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 @@ -1885,7 +1885,8 @@ 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; _ Patches currently in -mm which might be from haveblue@xxxxxxxxxx are enable-hotplug-memory-remove-for-ppc64.patch reiserfs-eliminate-private-use-of-struct-file-in-xattr.patch hppfs-pass-vfsmount-to-dentry_open.patch check-for-null-vfsmount-in-dentry_open.patch fix-up-new-filp-allocators.patch do-namei_flags-calculation-inside-open_namei.patch merge-open_namei-and-do_filp_open.patch r-o-bind-mounts-stub-functions.patch r-o-bind-mounts-create-helper-to-drop-file-write-access.patch r-o-bind-mounts-drop-write-during-emergency-remount.patch r-o-bind-mounts-elevate-write-count-for-vfs_rmdir.patch r-o-bind-mounts-elevate-write-count-for-callers-of-vfs_mkdir.patch r-o-bind-mounts-elevate-mnt_writers-for-unlink-callers.patch r-o-bind-mounts-elevate-write-count-for-xattr_permission-callers.patch r-o-bind-mounts-elevate-write-count-for-ncp_ioctl.patch r-o-bind-mounts-write-counts-for-time-functions.patch r-o-bind-mounts-elevate-write-count-for-do_utimes.patch r-o-bind-mounts-write-count-for-file_update_time.patch r-o-bind-mounts-write-counts-for-link-symlink.patch r-o-bind-mounts-elevate-write-count-for-ioctls.patch r-o-bind-mounts-elevate-write-count-for-opens.patch r-o-bind-mounts-get-write-access-for-vfs_rename-callers.patch r-o-bind-mounts-elevate-write-count-for-chmod-chown-callers.patch r-o-bind-mounts-write-counts-for-truncate.patch r-o-bind-mounts-elevate-count-for-xfs-timestamp-updates.patch r-o-bind-mounts-make-access-use-new-r-o-helper.patch r-o-bind-mounts-check-mnt-instead-of-superblock-directly.patch r-o-bind-mounts-get-callers-of-vfs_mknod-create.patch r-o-bind-mounts-track-numbers-of-writers-to-mounts.patch r-o-bind-mounts-honor-mount-writer-counts-at-remount.patch r-o-bind-mounts-debugging-for-missed-calls.patch reiser4.patch page-owner-tracking-leak-detector.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html