From: Eric W. Biederman Date: Mon, 28 Jul 2014 23:26:53 +0000 (-0700) Subject: mnt: Only change user settable mount flags in remount X-Git-Tag: TizenStudio_2.0_p2.3.1~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=469b5ce05987a89b72b199dc213a8303b01c24e7;p=sdk%2Femulator%2Femulator-kernel.git mnt: Only change user settable mount flags in remount Kenton Varda discovered that by remounting a read-only bind mount read-only in a user namespace the MNT_LOCK_READONLY bit would be cleared, allowing an unprivileged user to the remount a read-only mount read-write. Correct this by replacing the mask of mount flags to preserve with a mask of mount flags that may be changed, and preserve all others. This ensures that any future bugs with this mask and remount will fail in an easy to detect way where new mount flags simply won't change. Change-Id: Iae497b91c8dc83961937a6b1e6db9139d24d13ae Cc: stable@vger.kernel.org Acked-by: Serge E. Hallyn Signed-off-by: "Eric W. Biederman" --- diff --git a/fs/namespace.c b/fs/namespace.c index 0b958c396391..78f2c179c4d6 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1854,7 +1854,7 @@ static int do_remount(struct path *path, int flags, int mnt_flags, err = do_remount_sb(sb, flags, data, 0); if (!err) { br_write_lock(&vfsmount_lock); - mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK; + mnt_flags |= mnt->mnt.mnt_flags & ~MNT_USER_SETTABLE_MASK; mnt->mnt.mnt_flags = mnt_flags; br_write_unlock(&vfsmount_lock); } diff --git a/include/linux/mount.h b/include/linux/mount.h index 38cd98f112a0..d9bf038cdff3 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -42,8 +42,9 @@ struct mnt_namespace; * flag, consider how it interacts with shared mounts. */ #define MNT_SHARED_MASK (MNT_UNBINDABLE) -#define MNT_PROPAGATION_MASK (MNT_SHARED | MNT_UNBINDABLE) - +#define MNT_USER_SETTABLE_MASK (MNT_NOSUID | MNT_NODEV | MNT_NOEXEC \ + | MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME \ + | MNT_READONLY) #define MNT_INTERNAL 0x4000