[PATCH 1/2] vfs: mountinfo: A mnt is r/o if the superblock is

From: Shea Levy
Date: Thu Mar 14 2013 - 12:10:24 EST


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.

Signed-off-by: Shea Levy <shea@xxxxxxxxxxxx>
---
fs/proc_namespace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index 5fe34c3..cf8963c 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -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") */
--
1.8.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/