]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
Revert 95ebabde382c ("capabilities: Don't allow writing ambiguous v3 file capabilities")
authorEric W. Biederman <ebiederm@xmission.com>
Fri, 12 Mar 2021 21:07:09 +0000 (15:07 -0600)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Apr 2021 16:31:57 +0000 (18:31 +0200)
BugLink: https://bugs.launchpad.net/bugs/1920246
commit 3b0c2d3eaa83da259d7726192cf55a137769012f upstream.

It turns out that there are in fact userspace implementations that
care and this recent change caused a regression.

https://github.com/containers/buildah/issues/3071

As the motivation for the original change was future development,
and the impact is existing real world code just revert this change
and allow the ambiguity in v3 file caps.

Cc: stable@vger.kernel.org
Fixes: 95ebabde382c ("capabilities: Don't allow writing ambiguous v3 file capabilities")
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
security/commoncap.c

index 62507784a17032b05dfa3a1e3316ef5574307880..8440463a35389f7242959153d1b0e31b00fed954 100644 (file)
@@ -500,8 +500,7 @@ int cap_convert_nscap(struct dentry *dentry, const void **ivalue, size_t size)
        __u32 magic, nsmagic;
        struct inode *inode = d_backing_inode(dentry);
        struct user_namespace *task_ns = current_user_ns(),
-               *fs_ns = inode->i_sb->s_user_ns,
-               *ancestor;
+               *fs_ns = inode->i_sb->s_user_ns;
        kuid_t rootid;
        size_t newsize;
 
@@ -524,15 +523,6 @@ int cap_convert_nscap(struct dentry *dentry, const void **ivalue, size_t size)
        if (nsrootid == -1)
                return -EINVAL;
 
-       /*
-        * Do not allow allow adding a v3 filesystem capability xattr
-        * if the rootid field is ambiguous.
-        */
-       for (ancestor = task_ns->parent; ancestor; ancestor = ancestor->parent) {
-               if (from_kuid(ancestor, rootid) == 0)
-                       return -EINVAL;
-       }
-
        newsize = sizeof(struct vfs_ns_cap_data);
        nscap = kmalloc(newsize, GFP_ATOMIC);
        if (!nscap)