vfs: Report a mount r/o if the superblock is
cover vfs: Report a mount r/o if the superblock is
By calling mount(2) with MS_REMOUNT | MS_BIND on a non-bind readonly mountpoint, it is possible to have a readonly mount without MNT_READONLY in its mnt_flags. Currently, /proc/<pid>/mountinfo and statfs will report such a mount as r/w, even though for all intents and purposes it is still readonly.
This patchset fixes show_mountinfo and statfs to report such mounts as readonly.
PATCH 1/2 vfs: mountinfo: A mnt is r/o if the superblock is
By calling mount(2) with MS_REMOUNT | MS_BIND on a non-bind readonly mountpoint, it is possible to have a readonly mount without MNT_READONLY in its mnt_flags. Currently, /proc/<pid>/mountinfo will report such a mount as r/w in the 4th column, even though for all intents and purposes it is still readonly.
This patch makes show_mountinfo use __mnt_is_readonly to check if a mount is readonly, which checks both for MNT_READONLY in mnt_flags and for MS_RDONLY in mnt_sb->s_flags.
--- fs/proc_namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc_namespace.c +1 -1
@@ -143,7 +143,7 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt)if (err) goto out; -seq_puts (m, mnt->mnt_flags &MNT_READONLY ?" ro" :" rw" ); +seq_puts (m,__mnt_is_readonly (mnt) ?" ro" :" rw" );show_mnt_opts (m, mnt);/* Tagged fields ("foo:X" or "bar") */
Signature · 1 line
1.8.1.3
PATCH 2/2 vfs: statfs: A fs is r/o if the superblock is
In reply to Shea LevyBy calling mount(2) with MS_REMOUNT | MS_BIND on a non-bind readonly mountpoint, it is possible to have a readonly mount without MNT_READONLY in its mnt_flags. Currently, statfs will not set the ST_RDONLY flag in f_flags for such a mount, even though for all intents and purposes it is still readonly.
This patch makes vfs_statfs set ST_RDONLY in f_flags if mnt_sb->s_flags contains MS_RDONLY.
--- fs/statfs.c | 2 ++ 1 file changed, 2 insertions(+)
fs/statfs.c +2 -0
@@ -37,6 +37,8 @@ static int flags_by_sb(int s_flags) flags |=ST_SYNCHRONOUS ;if (s_flags &MS_MANDLOCK ) flags |=ST_MANDLOCK ; +if (s_flags &MS_RDONLY ) + flags |=ST_RDONLY ;return flags; }
Signature · 1 line
1.8.1.3
Any feedback on this?
Quoted 11 lines · Shea Levy
By calling mount(2) with
MS_REMOUNT|MS_BINDon a non-bind readonly mountpoint, it is possible to have a readonly mount withoutMNT_READONLYin itsmnt_flags. Currently, /proc/<pid>/mountinfo and statfs will report such a mount as r/w, even though for all intents and purposes it is still readonly.This patchset fixes
show_mountinfoand statfs to report such mounts as readonly.Signed-off-by Shea Levy <[email protected]>
Jan Kara
reviewerQuoted 8 lines · Shea Levy
By calling mount(2) with
MS_REMOUNT|MS_BINDon a non-bind readonly mountpoint, it is possible to have a readonly mount withoutMNT_READONLYin itsmnt_flags. Currently, /proc/<pid>/mountinfo and statfs will report such a mount as r/w, even though for all intents and purposes it is still readonly.This patchset fixes
show_mountinfoand statfs to report such mounts as readonly.
Andrew, I think the two patches in this thread deserve to be picked up...
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR