From: Micah Morton <mortonm@chromium.org>
To: jmorris@namei.org, keescook@chromium.org, casey@schaufler-ca.com,
linux-security-module@vger.kernel.org
Cc: Jann Horn <jannh@google.com>, Micah Morton <mortonm@chromium.org>
Subject: [PATCH 06/10] LSM: SafeSetID: fix userns handling in securityfs
Date: Wed, 10 Apr 2019 09:55:58 -0700 [thread overview]
Message-ID: <20190410165558.211483-1-mortonm@chromium.org> (raw)
From: Jann Horn <jannh@google.com>
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>
---
security/safesetid/securityfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/security/safesetid/securityfs.c b/security/safesetid/securityfs.c
index 87e42b7f3e33..76c1e8a6ab93 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)
--
2.21.0.392.gf8f6787159e-goog
next reply other threads:[~2019-04-10 16:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-10 16:55 Micah Morton [this message]
2019-04-10 17:16 ` [PATCH 06/10] LSM: SafeSetID: fix userns handling in securityfs Kees Cook
2019-05-07 15:01 ` Micah Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190410165558.211483-1-mortonm@chromium.org \
--to=mortonm@chromium.org \
--cc=casey@schaufler-ca.com \
--cc=jannh@google.com \
--cc=jmorris@namei.org \
--cc=keescook@chromium.org \
--cc=linux-security-module@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox