Commit bd088dae authored by Seth Forshee's avatar Seth Forshee Committed by Luis Henriques

UBUNTU: SAUCE: (namespace) fs: Don't remove suid for CAP_FSETID for userns root

BugLink: http://bugs.launchpad.net/bugs/1634964

Expand the check in should_remove_suid() to keep privileges for
CAP_FSETID in s_user_ns rather than init_user_ns.

--EWB Changed from ns_capable(sb->s_user_ns, ) to capable_wrt_inode_uidgid
Signed-off-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Acked-by: default avatarTim Gardner <tim.gardner@canonical.com>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent e47ad83f
...@@ -1677,7 +1677,8 @@ EXPORT_SYMBOL(touch_atime); ...@@ -1677,7 +1677,8 @@ EXPORT_SYMBOL(touch_atime);
*/ */
int should_remove_suid(struct dentry *dentry) int should_remove_suid(struct dentry *dentry)
{ {
umode_t mode = d_inode(dentry)->i_mode; struct inode *inode = d_inode(dentry);
umode_t mode = inode->i_mode;
int kill = 0; int kill = 0;
/* suid always must be killed */ /* suid always must be killed */
...@@ -1691,7 +1692,8 @@ int should_remove_suid(struct dentry *dentry) ...@@ -1691,7 +1692,8 @@ int should_remove_suid(struct dentry *dentry)
if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
kill |= ATTR_KILL_SGID; kill |= ATTR_KILL_SGID;
if (unlikely(kill && !capable(CAP_FSETID) && S_ISREG(mode))) if (unlikely(kill && !capable_wrt_inode_uidgid(inode, CAP_FSETID) &&
S_ISREG(mode)))
return kill; return kill;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment