[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180913094256.gpwrlu4gnjn6zyhn@mikami>
Date: Thu, 13 Sep 2018 19:42:56 +1000
From: Aleksa Sarai <asarai@...e.de>
To: Andy Lutomirski <luto@...capital.net>
Cc: Tycho Andersen <tycho@...ho.ws>, Kees Cook <keescook@...omium.org>,
Jann Horn <jannh@...gle.com>,
Linux API <linux-api@...r.kernel.org>,
Linux Containers <containers@...ts.linux-foundation.org>,
Akihiro Suda <suda.akihiro@....ntt.co.jp>,
Oleg Nesterov <oleg@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
"Eric W . Biederman" <ebiederm@...ssion.com>,
Christian Brauner <christian.brauner@...ntu.com>
Subject: Re: [PATCH v6 4/5] seccomp: add support for passing fds via
USER_NOTIF
On 2018-09-12, Andy Lutomirski <luto@...capital.net> wrote:
> > The idea here is that the userspace handler should be able to pass an fd
> > back to the trapped task, for example so it can be returned from socket().
> >
> > I've proposed one API here, but I'm open to other options. In particular,
> > this only lets you return an fd from a syscall, which may not be enough in
> > all cases. For example, if an fd is written to an output parameter instead
> > of returned, the current API can't handle this. Another case is that
> > netlink takes as input fds sometimes (IFLA_NET_NS_FD, e.g.). If netlink
> > ever decides to install an fd and output it, we wouldn't be able to handle
> > this either.
>
> An alternative could be to have an API (an ioctl on the listener,
> perhaps) that just copies an fd into the tracee. There would be the
> obvious set of options: do we replace an existing fd or allocate a new
> one, and is it CLOEXEC. Then the tracer could add an fd and then
> return it just like it's a regular number.
>
> I feel like this would be more flexible and conceptually simpler, but
> maybe a little slower for the common cases. What do you think?
When we first discussed this I sent a (probably somewhat broken) patch
for "dup4" which would let you inject a file descriptor into a different
process -- I still think that having a method for injecting a file
descriptor without needing ptrace (and SCM_RIGHTS) shenanigans would be
generally useful. (With "dup4" you have a more obvious API for flags and
whether you allocate a new fd or use a specific one.)
--
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH
<https://www.cyphar.com/>
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists