summaryrefslogtreecommitdiffstats
path: root/security/safesetid
diff options
context:
space:
mode:
authorJann Horn <jannh@google.com>2019-04-10 09:55:58 -0700
committerMicah Morton <mortonm@chromium.org>2019-07-15 08:07:19 -0700
commit71a98971b932174e121bc19056475c601598132f (patch)
treefb3a1ee4a8b7cdec81b2f0671524a25af4b5b016 /security/safesetid
parent78ae7df96d647627ceae0b65eea9e4f83a0a4b66 (diff)
downloadlinux-stable-71a98971b932174e121bc19056475c601598132f.tar.gz
linux-stable-71a98971b932174e121bc19056475c601598132f.tar.bz2
linux-stable-71a98971b932174e121bc19056475c601598132f.zip
LSM: SafeSetID: fix userns handling in securityfs
Looking at current_cred() in write handlers is bad form, stop doing that. Also, let's just require that the write is coming from the initial user namespace. Especially SAFESETID_WHITELIST_FLUSH requires privilege over all namespaces, and SAFESETID_WHITELIST_ADD should probably require it as well. Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Micah Morton <mortonm@chromium.org>
Diffstat (limited to 'security/safesetid')
-rw-r--r--security/safesetid/securityfs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/security/safesetid/securityfs.c b/security/safesetid/securityfs.c
index 90784a8d950a..77d301f0ff7a 100644
--- a/security/safesetid/securityfs.c
+++ b/security/safesetid/securityfs.c
@@ -59,8 +59,8 @@ static int parse_policy_line(
if (ret)
return ret;
- *parent = make_kuid(current_user_ns(), parsed_parent);
- *child = make_kuid(current_user_ns(), parsed_child);
+ *parent = make_kuid(file->f_cred->user_ns, parsed_parent);
+ *child = make_kuid(file->f_cred->user_ns, parsed_child);
if (!uid_valid(*parent) || !uid_valid(*child))
return -EINVAL;
@@ -92,7 +92,7 @@ static ssize_t safesetid_file_write(struct file *file,
kuid_t child;
int ret;
- if (!ns_capable(current_user_ns(), CAP_MAC_ADMIN))
+ if (!file_ns_capable(file, &init_user_ns, CAP_MAC_ADMIN))
return -EPERM;
if (*ppos != 0)