Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1281934
| From | Seth Forshee <seth.forshee@canonical.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 15/19] capabilities: Allow privileged user in s_user_ns to set file caps |
| Date | 2015-12-02 16:50 +0100 |
| Message-ID | <qBhPl-FC-49@gated-at.bofh.it> (permalink) |
| References | <qBhPj-FC-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
A privileged user in a super block's s_user_ns is privileged
towards that file system and thus should be allowed to set file
capabilities. The file capabilities will not be trusted outside
of s_user_ns, so an unprivileged user cannot use this to gain
privileges in a user namespace where they are not already
privileged.
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
---
security/commoncap.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/security/commoncap.c b/security/commoncap.c
index 2119421613f6..d6c80c19c449 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -653,15 +653,17 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
int cap_inode_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
+ struct user_namespace *user_ns = dentry->d_sb->s_user_ns;
+
if (!strcmp(name, XATTR_NAME_CAPS)) {
- if (!capable(CAP_SETFCAP))
+ if (!ns_capable(user_ns, CAP_SETFCAP))
return -EPERM;
return 0;
}
if (!strncmp(name, XATTR_SECURITY_PREFIX,
sizeof(XATTR_SECURITY_PREFIX) - 1) &&
- !capable(CAP_SYS_ADMIN))
+ !ns_capable(user_ns, CAP_SYS_ADMIN))
return -EPERM;
return 0;
}
@@ -679,15 +681,17 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name,
*/
int cap_inode_removexattr(struct dentry *dentry, const char *name)
{
+ struct user_namespace *user_ns = dentry->d_sb->s_user_ns;
+
if (!strcmp(name, XATTR_NAME_CAPS)) {
- if (!capable(CAP_SETFCAP))
+ if (!ns_capable(user_ns, CAP_SETFCAP))
return -EPERM;
return 0;
}
if (!strncmp(name, XATTR_SECURITY_PREFIX,
sizeof(XATTR_SECURITY_PREFIX) - 1) &&
- !capable(CAP_SYS_ADMIN))
+ !ns_capable(user_ns, CAP_SYS_ADMIN))
return -EPERM;
return 0;
}
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH 15/19] capabilities: Allow privileged user in s_user_ns to set file caps Seth Forshee <seth.forshee@canonical.com> - 2015-12-02 16:50 +0100
Re: [PATCH 15/19] capabilities: Allow privileged user in s_user_ns to set file caps "Serge E. Hallyn" <serge@hallyn.com> - 2015-12-04 20:50 +0100
Re: [PATCH 15/19] capabilities: Allow privileged user in s_user_ns to set file caps Seth Forshee <seth.forshee@canonical.com> - 2015-12-04 21:40 +0100
Re: [PATCH 15/19] capabilities: Allow privileged user in s_user_ns to set file caps "Serge E. Hallyn" <serge.hallyn@ubuntu.com> - 2015-12-04 23:10 +0100
csiph-web