aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2014-07-28 16:26:53 -0700
committerZiyan <jaraidaniel@gmail.com>2016-10-29 01:34:18 +0200
commit045b35811978bda95db69acd658956d935ce70dd (patch)
treef61bd4e0848e94e6032393b700d4073899485392
parent6b43c1e526d9ec1bc7ab1692a5620568d8e5e0d4 (diff)
downloadkernel_samsung_tuna-045b35811978bda95db69acd658956d935ce70dd.tar.gz
kernel_samsung_tuna-045b35811978bda95db69acd658956d935ce70dd.tar.bz2
kernel_samsung_tuna-045b35811978bda95db69acd658956d935ce70dd.zip
mnt: Only change user settable mount flags in remount
commit a6138db815df5ee542d848318e5dae681590fccd upstream. 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. Change-Id: I8ab8bda03a14b9b43e78f1dc6c818bbec048e986 Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Francis Moreau <francis.moro@gmail.com> Signed-off-by: Zefan Li <lizefan@huawei.com>
-rw-r--r--fs/namespace.c2
-rw-r--r--include/linux/mount.h4
2 files changed, 4 insertions, 2 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 8815c8be80d..be146adc2c2 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1883,7 +1883,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 |= path->mnt->mnt_flags & MNT_PROPAGATION_MASK;
+ mnt_flags |= path->mnt->mnt_flags & ~MNT_USER_SETTABLE_MASK;
path->mnt->mnt_flags = mnt_flags;
br_write_unlock(&vfsmount_lock);
}
diff --git a/include/linux/mount.h b/include/linux/mount.h
index fe90f576f6d..cffe39e8e1b 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -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 0x4000