Skip to contentSkip to conversation

vfs: Report a mount r/o if the superblock is

PATCH In review Shea Levy 2 participants 5 messages Mar 14, 2013 – Apr 5, 2013 VFS

lore
Share & tools
lore

Shea Levy

author
#0 lore raw

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.

author
#1 lore raw

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
index 5fe34c3..cf8963c 100644
@@ -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
author
#2 lore raw

PATCH 2/2 vfs: statfs: A fs is r/o if the superblock is

In reply to Shea Levy

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, 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
index c219e733..c614087 100644
@@ -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
author
#3 lore raw
In reply to Shea Levy

Any feedback on this?

Quoted 11 lines · Shea Levy

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.

reviewer
#4 lore raw
In reply to Shea Levy
Quoted 8 lines · Shea Levy

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.

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