diff mbox

[3.5.y.z,extended,stable] Patch "vfs: Add a mount flag to lock read only bind mounts" has been added to staging queue

Message ID 1364986223-8693-1-git-send-email-luis.henriques@canonical.com
State New
Headers show

Commit Message

Luis Henriques April 3, 2013, 10:50 a.m. UTC
This is a note to let you know that I have just added a patch titled

    vfs: Add a mount flag to lock read only bind mounts

to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
which can be found at:

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.5.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Luis

------

From 777a11be9c4b612497dfc1252b1b836e5663a656 Mon Sep 17 00:00:00 2001
From: "Eric W. Biederman" <ebiederm@xmission.com>
Date: Fri, 22 Mar 2013 03:10:15 -0700
Subject: [PATCH] vfs: Add a mount flag to lock read only bind mounts

commit 90563b198e4c6674c63672fae1923da467215f45 upstream.

When a read-only bind mount is copied from mount namespace in a higher
privileged user namespace to a mount namespace in a lesser privileged
user namespace, it should not be possible to remove the the read-only
restriction.

Add a MNT_LOCK_READONLY mount flag to indicate that a mount must
remain read-only.

Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 fs/namespace.c        | 3 +++
 include/linux/mount.h | 2 ++
 2 files changed, 5 insertions(+)

--
1.8.1.2

Comments

Eric W. Biederman April 3, 2013, 11:03 p.m. UTC | #1
Luis Henriques <luis.henriques@canonical.com> writes:

> This is a note to let you know that I have just added a patch titled
>
>     vfs: Add a mount flag to lock read only bind mounts
>
> to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
> which can be found at:
>
>  http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue
>
> If you, or anyone else, feels it should not be added to this tree, please 
> reply to this email.
>
> For more information about the 3.5.y.z tree, see
> https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

This is harmless but the commit that makes this necessary is the commit
that allows unprivileged changes to the user namespace in 3.8 Aka:


    commit 0c55cfc4166d9a0f38de779bd4d75a90afbe7734
    Author: Eric W. Biederman <ebiederm@xmission.com>
    Date:   Thu Jul 26 21:42:03 2012 -0700
     
        vfs: Allow unprivileged manipulation of the mount namespace.

So I believe this is a useless backport.

Eric
Luis Henriques April 4, 2013, 8:56 a.m. UTC | #2
On Wed, Apr 03, 2013 at 04:03:27PM -0700, Eric W. Biederman wrote:
> Luis Henriques <luis.henriques@canonical.com> writes:
> 
> > This is a note to let you know that I have just added a patch titled
> >
> >     vfs: Add a mount flag to lock read only bind mounts
> >
> > to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree 
> > which can be found at:
> >
> >  http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue
> >
> > If you, or anyone else, feels it should not be added to this tree, please 
> > reply to this email.
> >
> > For more information about the 3.5.y.z tree, see
> > https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
> 
> This is harmless but the commit that makes this necessary is the commit
> that allows unprivileged changes to the user namespace in 3.8 Aka:
> 
> 
>     commit 0c55cfc4166d9a0f38de779bd4d75a90afbe7734
>     Author: Eric W. Biederman <ebiederm@xmission.com>
>     Date:   Thu Jul 26 21:42:03 2012 -0700
>      
>         vfs: Allow unprivileged manipulation of the mount namespace.
> 
> So I believe this is a useless backport.

Hmm, right.  This patch is indeed pointless.  I'll drop it.

Thanks a lot for your feedback.

Cheers,
--
Luis
diff mbox

Patch

diff --git a/fs/namespace.c b/fs/namespace.c
index 1e4a5fe..c8cd18c 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1641,6 +1641,9 @@  static int change_mount_flags(struct vfsmount *mnt, int ms_flags)
 	if (readonly_request == __mnt_is_readonly(mnt))
 		return 0;

+	if (mnt->mnt_flags & MNT_LOCK_READONLY)
+		return -EPERM;
+
 	if (readonly_request)
 		error = mnt_make_readonly(real_mount(mnt));
 	else
diff --git a/include/linux/mount.h b/include/linux/mount.h
index d7029f4..73005f9 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -47,6 +47,8 @@  struct mnt_namespace;

 #define MNT_INTERNAL	0x4000

+#define MNT_LOCK_READONLY	0x400000
+
 struct vfsmount {
 	struct dentry *mnt_root;	/* root of the mounted tree */
 	struct super_block *mnt_sb;	/* pointer to superblock */