]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mnt: Only change user settable mount flags in remount
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 28 Jul 2014 23:26:53 +0000 (16:26 -0700)
committerEric W. Biederman <ebiederm@xmission.com>
Fri, 1 Aug 2014 00:11:54 +0000 (17:11 -0700)
Kenton Varda <kenton@sandstorm.io> 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.

Cc: stable@vger.kernel.org
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
fs/namespace.c
include/linux/mount.h

index 7187d01329c3581856d9936f686c7ca8b4c9c743..cb40449ea0dfe8983d45162ef724c45898d2424a 100644 (file)
@@ -1937,7 +1937,7 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
                err = do_remount_sb(sb, flags, data, 0);
        if (!err) {
                lock_mount_hash();
-               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;
                touch_mnt_namespace(mnt->mnt_ns);
                unlock_mount_hash();
index 839bac2709048da4d3f2d5099da1db618adcc729..b637a89e1faeb271af0ab5e850e47fdf9d8f487c 100644 (file)
@@ -42,7 +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_FLAGS (MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | \
                            MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED)