Skip to content

Commit 695e9df

Browse files
committed
mnt: Account for MS_RDONLY in fs_fully_visible
In rare cases it is possible for s_flags & MS_RDONLY to be set but MNT_READONLY to be clear. This starting combination can cause fs_fully_visible to fail to ensure that the new mount is readonly. Therefore force MNT_LOCK_READONLY in the new mount if MS_RDONLY is set on the source filesystem of the mount. In general both MS_RDONLY and MNT_READONLY are set at the same for mounts so I don't expect any programs to care. Nor do I expect MS_RDONLY to be set on proc or sysfs in the initial user namespace, which further decreases the likelyhood of problems. Which means this change should only affect system configurations by paranoid sysadmins who should welcome the additional protection as it keeps people from wriggling out of their policies. Cc: stable@vger.kernel.org Fixes: 8c6cf9c ("mnt: Modify fs_fully_visible to deal with locked ro nodev and atime") Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
1 parent d71ed6c commit 695e9df

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎fs/namespace.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,6 +3247,10 @@ static bool fs_fully_visible(struct file_system_type *type, int *new_mnt_flags)
32473247
if (mnt->mnt.mnt_sb->s_iflags & SB_I_NOEXEC)
32483248
mnt_flags &= ~(MNT_LOCK_NOSUID | MNT_LOCK_NOEXEC);
32493249

3250+
/* Don't miss readonly hidden in the superblock flags */
3251+
if (mnt->mnt.mnt_sb->s_flags & MS_RDONLY)
3252+
mnt_flags |= MNT_LOCK_READONLY;
3253+
32503254
/* Verify the mount flags are equal to or more permissive
32513255
* than the proposed new mount.
32523256
*/

0 commit comments

Comments
 (0)