]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
vfs: Add a mount flag to lock read only bind mounts
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 22 Mar 2013 10:10:15 +0000 (03:10 -0700)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 27 Mar 2013 14:50:04 +0000 (07:50 -0700)
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.

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

index a3035223d4218c13ac6db83f8d5444e454346c2f..8505b5ece5de98bc41a9a00efcb0a11035607508 100644 (file)
@@ -1713,6 +1713,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
index d7029f4a191a093ef9294104c75756b6d3b7faee..73005f9957ead2b95adb4107329434afbbf482a7 100644 (file)
@@ -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 */