All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Jim Lieb <jlieb@panasas.com>,
	tytso@mit.edu, viro@zeniv.linux.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	bfields@redhat.com, jlayton@redhat.com
Subject: Re: [PATCH 1/3] switch_creds:  Syscall to switch creds for file server ops
Date: Wed, 16 Oct 2013 18:18:16 -0700	[thread overview]
Message-ID: <87ppr4lmp3.fsf@xmission.com> (raw)
In-Reply-To: <20131016224248.GQ13318@ZenIV.linux.org.uk> (Al Viro's message of "Wed, 16 Oct 2013 23:42:48 +0100")

Al Viro <viro@ZenIV.linux.org.uk> writes:

> On Wed, Oct 16, 2013 at 03:01:57PM -0700, Jim Lieb wrote:
>> File servers must do some operations with the credentials of
>> their client.  This syscall switches the key credentials similar
>> to nfsd_setuser() in fs/nfsd/auth.c  with the capability of retaining a
>> handle to the credentials by way of an fd for an open anonymous file.
>> This makes switching for subsequent operations for that client more efficient.
>
> 	Yet Another Untyped Multiplexor.  Inna bun.  Onna stick.
> CMOT Dibbler special...
>
> 	Switching creds to those of opener of given file descriptor
> is fine, but in any realistic situation you'll get all the real win
> from that - you should cache those fds (which you seem to do), and
> then setuid/etc. is done once per cache miss.  Making the magical
> "set them all at once" mess (complete with non-trivial structure,
> 32/64bit compat, etc.) pointless.  Moreover, you don't need any magic
> files at all - just set the creds and open /dev/null and there's your fd.
> With proper creds associated with it.  While we are at it, just _start_
> with opening /dev/null.  With your initial creds.  Voila - revert is
> simply switch to that fd's creds.
>
> 	IOW, you really need only one syscall:

That doesn't look bad but it does need capable(CAP_SETUID) &&
capable(CAP_SETGID) or possibly something a little more refined.

I don't think we want file descriptor passing to all of a sudden become
a grant of privilege, beyond what the passed fd can do.

> SYSCALL_DEFINE1(switch_cred, int, fd)
> {
> 	struct fd f = fdget(fd);
> 	if (!f.file)
> 		return -EBADF;
> 	put_cred(override_creds(f.file->f_cred);
> 	fdput(f);
> 	return 0;
> }
>
> and that's all there is to it.

Eric

  reply	other threads:[~2013-10-17  1:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16 22:01 [RFC PATCH 0/3] System call to switch user credentials Jim Lieb
2013-10-16 22:01 ` [PATCH 1/3] switch_creds: Syscall to switch creds for file server ops Jim Lieb
2013-10-16 22:42   ` Al Viro
2013-10-17  1:18     ` Eric W. Biederman [this message]
2013-10-17  1:20       ` Al Viro
2013-10-17  3:35         ` Jim Lieb
2013-10-17  3:35           ` Jim Lieb
2013-10-17  3:52         ` Eric W. Biederman
2013-10-24  1:14           ` Andy Lutomirski
2013-10-24  5:59             ` Eric W. Biederman
2013-10-24 19:04               ` Jim Lieb
2013-10-24 19:04                 ` Jim Lieb
2013-10-24 19:28               ` Andy Lutomirski
2013-10-24 20:24                 ` Jim Lieb
2013-10-24 20:24                   ` Jim Lieb
2013-10-31 19:09                   ` Andy Lutomirski
2013-10-31 19:09                     ` Andy Lutomirski
2013-10-31 19:43                     ` Jim Lieb
2013-10-31 19:48                       ` Andy Lutomirski
2013-10-31 20:39                         ` Jim Lieb
2013-11-01 13:24                           ` Tetsuo Handa
2013-11-01 15:49                             ` Jim Lieb
2013-11-01 16:07                               ` Tetsuo Handa
2013-11-01 17:16                                 ` Jim Lieb
2013-10-16 22:01 ` [PATCH 2/3] switch_creds: Add x86 syscall number Jim Lieb
2013-10-16 22:01 ` [PATCH 3/3] switch_creds: Assign x86_64 syscall number for switch_creds Jim Lieb

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=87ppr4lmp3.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=bfields@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=jlieb@panasas.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=viro@zeniv.linux.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 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.