All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@primarydata.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Layton Jeff <jlayton@redhat.com>, "Theodore Ts'o" <tytso@mit.edu>,
	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>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Dr Fields James Bruce <bfields@redhat.com>
Subject: Re: Thoughts on credential switching
Date: Mon, 31 Mar 2014 16:14:33 -0400	[thread overview]
Message-ID: <3E5CB7F4-0CB6-4D50-85DC-D19FC47FCBD8@primarydata.com> (raw)
In-Reply-To: <CALCETrX5ta875ij08_SNmzrN+KLRNuYiM2psNyFn8JdLOd=8DQ@mail.gmail.com>


On Mar 31, 2014, at 15:26, Andy Lutomirski <luto@amacapital.net> wrote:

> On Mon, Mar 31, 2014 at 11:06 AM, Trond Myklebust
> <trond.myklebust@primarydata.com> wrote:
>> 
>> On Mar 31, 2014, at 7:51, Jeff Layton <jlayton@redhat.com> wrote:
>> 
>>> On Sun, 30 Mar 2014 09:03:29 -0400
>>> "Theodore Ts'o" <tytso@mit.edu> wrote:
>>> 
>>>> On Thu, Mar 27, 2014 at 07:08:02AM -0700, Jeff Layton wrote:
>>>>> I had some time to think about this last night...
>>>>> 
>>>>> While using a fd to pass around credentials is convenient, the danger
>>>>> is that it's pretty opaque. You have a fd that you know has creds
>>>>> attached to it, but it's hard to be certain what is going to change.
>>>> 
>>>> I don't think that's a particularly tough problem.  In general, the fd
>>>> isn't something that you would want to pass around, and so the process
>>>> which generated it will know exactly what it contained.
>>>> 
>>> 
>>> I think there's a bit more of a use-case for passing around such an fd
>>> via socket...
>>> 
>>> Part of the problem is that the traditional uid/gid switching glibc
>>> wrappers are per-process. If we're proposing doing something like:
>>> 
>>> seteuid()
>>> setegid()
>>> setgroups()
>>> fd = open()
>>> (...and then revert the creds using same syscalls)
>>> 
>>> ...during the time that you're doing all of that, you can't really
>>> allow any thread in the process to be doing something that requires
>>> _other_ creds until you've completed the above.
>> 
>> Umm... open() isn't the only operation that you want to be able to do with an assumed user identity. You want mknod(), mkdir(), link(), unlink(), ... Pretty much any interaction with the underlying filesystem needs to use the right identity.
>> 
>>> So, I could envision a program like ganesha firing up a separate
>>> process to handle the credential switching and fd creation and then
>>> handing those back to the main process via a unix domain socket.
>> 
>> How about using the keyrings interface to atomically cache and retrieve these user identities? We already have support for different types of keys that store/retrieve different types of structured information. How is this so different?
> 
> This sounds considerably more complicated than just using fds.  What's
> the advantage?

The advantage is that it’s considerably _less_ complicated because it uses interfaces that were designed to carry security related information, and to share them across threads.

> I guess using keys for local fs credentials fits in with using keys to
> access things like AFS, but I'm still not sure I see why this helps
> here.

All you want to do is atomically store and retrieve a user identity (in practice a credential) and share it between members of a thread. As I said, that kind of storage/retrieval of structured data is what keyrings do. As far as I know, there are already LSM interfaces in place (see security_key_alloc/permission/free), and the generic keyring/keyctl interface exists with appropriate process sharing/inheritance rules via the kernel keyring interface.

So basically, the recipe is:

- You set up a kernel key type that takes a reference to the current process credential on instantiation (no upcalls, etc needed). Ganesha can then use standard libkeyutils methods to create the key and store it in its user, process or thread keyring.
- You add a new keyctl (KEYCTL_APPLY?) that enables any thread/process that has access to the key, via the keyring in which it is stored, to apply the stored process credential to itself (and perhaps cache it’s old credential in a new key?).


_________________________________
Trond Myklebust
Linux NFS client maintainer, PrimaryData
trond.myklebust@primarydata.com


  reply	other threads:[~2014-03-31 20:14 UTC|newest]

Thread overview: 42+ 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
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:06               ` Trond Myklebust
2014-03-31 18:12               ` Jeff Layton
2014-03-31 18:12                 ` Jeff Layton
2014-03-31 19:26               ` Andy Lutomirski
2014-03-31 20:14                 ` Trond Myklebust [this message]
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-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 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=3E5CB7F4-0CB6-4D50-85DC-D19FC47FCBD8@primarydata.com \
    --to=trond.myklebust@primarydata.com \
    --cc=bfields@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=jlayton@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.