mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 3.8 08/13] mnt: Only change user settable mount flags in remount
Date: Mon, 25 Aug 2014 09:54:54 -0700	[thread overview]
Message-ID: <1408985699-31838-9-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1408985699-31838-1-git-send-email-kamal@canonical.com>

3.8.13.28 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: "Eric W. Biederman" <ebiederm@xmission.com>

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.

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/namespace.c        | 2 +-
 include/linux/mount.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 5dd7709..ddbd5bc 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1782,7 +1782,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 73005f9..16fc05d 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
-- 
1.9.1


  parent reply	other threads:[~2014-08-25 16:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-25 16:54 [3.8.y.z extended stable] Linux 3.8.13.28 stable review Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 01/13] x86_32, entry: Do syscall exit work on badsys (CVE-2014-4508) Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 02/13] x86_32, entry: Store badsys error code in %eax Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 03/13] shmem: fix faulting into a hole while it's punched Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 04/13] shmem: fix faulting into a hole, not taking i_mutex Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 05/13] shmem: fix splicing from a hole while it's punched Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 06/13] target: Explicitly clear ramdisk_mcp backend pages Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 07/13] sctp: Fix sk_ack_backlog wrap-around problem Kamal Mostafa
2014-08-25 16:54 ` Kamal Mostafa [this message]
2014-08-25 16:54 ` [PATCH 3.8 09/13] mnt: Move the test for MNT_LOCK_READONLY from change_mount_flags into do_remount Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 10/13] mnt: Correct permission checks in do_remount Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 11/13] mnt: Change the default remount atime from relatime to the existing value Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 12/13] ptrace,x86: force IRET path after a ptrace_stop() Kamal Mostafa
2014-08-25 16:54 ` [PATCH 3.8 13/13] net/l2tp: don't fall back on UDP [get|set]sockopt Kamal Mostafa
2014-08-25 17:00 ` [3.8.y.z extended stable] Linux 3.8.13.28 stable review Greg KH
2014-08-25 19:14   ` Kamal Mostafa
2014-08-25 19:37     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1408985699-31838-9-git-send-email-kamal@canonical.com \
    --to=kamal@canonical.com \
    --cc=ebiederm@xmission.com \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®