2013-03-14 16:10:16

by Shea Levy

[permalink] [raw]
Subject: [PATCH 0/2] 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.

Signed-off-by: Shea Levy <[email protected]>


2013-03-14 16:10:18

by Shea Levy

[permalink] [raw]
Subject: [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.

Signed-off-by: Shea Levy <[email protected]>
---
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

2013-03-14 16:11:22

by Shea Levy

[permalink] [raw]
Subject: [PATCH 2/2] vfs: statfs: A fs 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, 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.

Signed-off-by: Shea Levy <[email protected]>
---
fs/statfs.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/statfs.c b/fs/statfs.c
index c219e733..c614087 100644
--- a/fs/statfs.c
+++ b/fs/statfs.c
@@ -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;
}

--
1.8.1.3

2013-03-22 01:24:53

by Shea Levy

[permalink] [raw]
Subject: Re: [PATCH 0/2] vfs: Report a mount r/o if the superblock is

Any feedback on this?

On Mar 14, 2013, at 12:09 PM, Shea Levy <[email protected]> wrote:

> 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.
>
> Signed-off-by: Shea Levy <[email protected]>
>

2013-04-05 14:06:53

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 0/2] vfs: Report a mount r/o if the superblock is

On Thu 14-03-13 12:09:18, Shea Levy wrote:
> 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
--
Jan Kara <[email protected]>
SUSE Labs, CR