Skip to content

Commit

Permalink
Revert 95ebabd ("capabilities: Don't allow writing ambiguous v3 file …
Browse files Browse the repository at this point in the history
…capabilities")

BugLink: https://bugs.launchpad.net/bugs/1920246

commit 3b0c2d3 upstream.

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

containers/buildah#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: [email protected]
Fixes: 95ebabd ("capabilities: Don't allow writing ambiguous v3 file capabilities")
Signed-off-by: Eric W. Biederman <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Kamal Mostafa <[email protected]>
Signed-off-by: Kelsey Skunberg <[email protected]>
  • Loading branch information
ebiederm authored and ksacilotto committed Apr 14, 2021
1 parent 7c04788 commit 0e273ef
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions security/commoncap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down

0 comments on commit 0e273ef

Please sign in to comment.