From: Jeff Layton <jlayton@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Jim Lieb <jlieb@panasas.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
LSM List <linux-security-module@vger.kernel.org>,
"Serge E. Hallyn" <serge@canonical.com>,
Kees Cook <keescook@chromium.org>,
Linux FS Devel <linux-fsdevel@vger.kernel.org>,
"Theodore Ts'o" <tytso@mit.edu>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
bfields@redhat.com
Subject: Re: Thoughts on credential switching
Date: Wed, 26 Mar 2014 19:48:47 -0700 [thread overview]
Message-ID: <20140326194847.0e994d0b@ipyr.poochiereds.net> (raw)
In-Reply-To: <CALCETrVyNXYaMWOyWj4gKLWVdzPrSkvv7WTBi2Aa8mYs4NKH9g@mail.gmail.com>
On Wed, 26 Mar 2014 17:23:24 -0700
Andy Lutomirski <luto@amacapital.net> wrote:
> Hi various people who care about user-space NFS servers and/or
> security-relevant APIs.
>
> I propose the following set of new syscalls:
>
> int credfd_create(unsigned int flags): returns a new credfd that
> corresponds to current's creds.
>
> int credfd_activate(int fd, unsigned int flags): Change current's
> creds to match the creds stored in fd. To be clear, this changes both
> the "subjective" and "objective" (aka real_cred and cred) because
> there aren't any real semantics for what happens when userspace code
> runs with real_cred != cred.
>
> Rules:
>
> - credfd_activate fails (-EINVAL) if fd is not a credfd.
> - credfd_activate fails (-EPERM) if the fd's userns doesn't match
> current's userns. credfd_activate is not intended to be a substitute
> for setns.
> - credfd_activate will fail (-EPERM) if LSM does not allow the
> switch. This probably needs to be a new selinux action --
> dyntransition is too restrictive.
>
>
> Optional:
> - credfd_create always sets cloexec, because the alternative is
> silly.
> - credfd_activate fails (-EINVAL) if dumpable. This is because we
> don't want a privileged daemon to be ptraced while impersonating
> someone else.
> - optional: both credfd_create and credfd_activate fail if
> !ns_capable(CAP_SYS_ADMIN) or perhaps !capable(CAP_SETUID).
>
> The first question: does this solve Ganesha's problem?
>
> The second question: is this safe? I can see two major concerns. The
> bigger concern is that having these syscalls available will allow
> users to exploit things that were previously secure. For example,
> maybe some configuration assumes that a task running as uid==1 can't
> switch to uid==2, even with uid 2's consent. Similar issues happen
> with capabilities. If CAP_SYS_ADMIN is not required, then this is no
> longer really true.
>
> Alternatively, something running as uid == 0 with heavy capability
> restrictions in a mount namespace (but not a uid namespace) could pass
> a credfd out of the namespace. This could break things like Docker
> pretty badly. CAP_SYS_ADMIN guards against this to some extent. But
> I think that Docker is already totally screwed if a Docker root task
> can receive an O_DIRECTORY or O_PATH fd out of the container, so it's
> not entirely clear that the situation is any worse, even without
> requiring CAP_SYS_ADMIN.
>
> The second concern is that it may be difficult to use this correctly.
> There's a reason that real_cred and cred exist, but it's not really
> well set up for being used.
>
> As a simple way to stay safe, Ganesha could only use credfds that have
> real_uid == 0.
>
> --Andy
I still don't quite grok why having this special credfd_create call
buys you anything over simply doing what Al had originally suggested --
switch creds using all of the different syscalls and then simply caching
that in a "normal" fd:
fd = open("/dev/null", O_PATH...);
...it seems to me that the credfd_activate call will still need to do
the same permission checking that all of the individual set*id() calls
require (and all of the other stuff like changing selinux contexts,
etc).
IOW, this fd is just a "handle" for passing around a struct cred, but I
don't see why having access to that handle would allow you to do
something you couldn't already do anyway.
Am I missing something obvious here?
--
Jeff Layton <jlayton@redhat.com>
next prev parent reply other threads:[~2014-03-27 2:49 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-27 0:23 Thoughts on credential switching Andy Lutomirski
2014-03-27 0:42 ` Serge Hallyn
2014-03-27 1:01 ` Andy Lutomirski
2014-03-27 15:41 ` Florian Weimer
2014-03-27 16:21 ` Andy Lutomirski
2014-03-27 2:48 ` Jeff Layton [this message]
2014-03-27 3:05 ` Andy Lutomirski
2014-03-27 3:25 ` Jeff Layton
2014-03-27 14:08 ` Jeff Layton
2014-03-29 6:43 ` Alex Elsayed
2014-03-30 13:03 ` Theodore Ts'o
2014-03-30 18:56 ` Andy Lutomirski
2014-03-31 11:51 ` Jeff Layton
2014-03-31 18:06 ` Trond Myklebust
2014-03-31 18:12 ` Jeff Layton
2014-03-31 19:26 ` Andy Lutomirski
2014-03-31 20:14 ` Trond Myklebust
2014-03-31 21:25 ` Andy Lutomirski
2014-03-27 12:46 ` Florian Weimer
2014-03-27 13:02 ` Jeff Layton
2014-03-27 13:06 ` Florian Weimer
2014-03-27 13:33 ` Boaz Harrosh
2014-04-22 11:37 ` Florian Weimer
2014-04-22 12:14 ` Boaz Harrosh
2014-04-22 16:35 ` Jim Lieb
2014-03-27 14:01 ` Jeff Layton
2014-03-27 18:26 ` Jeremy Allison
2014-03-27 18:46 ` Andy Lutomirski
2014-03-27 18:56 ` Jeremy Allison
2014-03-27 19:02 ` Andy Lutomirski
2014-03-27 19:30 ` Jim Lieb
2014-03-27 19:45 ` Andy Lutomirski
2014-03-27 20:47 ` Jim Lieb
2014-03-27 21:19 ` Andy Lutomirski
2014-03-31 10:44 ` One Thousand Gnomes
2014-03-31 16:49 ` Andy Lutomirski
2014-04-01 20:22 ` One Thousand Gnomes
2014-03-31 19:05 ` Jeremy Allison
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=20140326194847.0e994d0b@ipyr.poochiereds.net \
--to=jlayton@redhat.com \
--cc=bfields@redhat.com \
--cc=ebiederm@xmission.com \
--cc=jlieb@panasas.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=serge@canonical.com \
--cc=tytso@mit.edu \
/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;
as well as URLs for NNTP newsgroup(s).