public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [seccomp] Request for a "enable on execve" mode for Seccomp filters
@ 2020-10-28 11:18 Camille Mougey
  2020-10-28 12:42 ` Jann Horn
  2020-10-28 22:47 ` Kees Cook
  0 siblings, 2 replies; 15+ messages in thread
From: Camille Mougey @ 2020-10-28 11:18 UTC (permalink / raw)
  To: lkml
  Cc: Kees Cook, Jann Horn, Tycho Andersen, Rich Felker, Sargun Dhillon,
	Christian Brauner, Michael Kerrisk (man-pages), Denis Efremov

Hello,

(This is my first message to the kernel list, I hope I'm doing it right)

From my understanding, there is no way to delay the activation of
seccomp filters, for instance "until an _execve_ call".
But this might be useful, especially for tools who sandbox other,
non-cooperative, executables, such as "systemd" or "FireJail".

It seems to be a caveat of seccomp specific to the system call
_execve_. For now, some tools such as "systemd" explicitly mention
this exception, and do not support it (from the man page):
> Note that strict system call filters may impact execution and error handling code paths of the service invocation. Specifically, access to the execve system call is required for the execution of the service binary — if it is blocked service invocation will necessarily fail

"FireJail" takes a different approach[1], with a kind of workaround:
the project uses an external library to be loaded through LD_PRELOAD
mechanism, in order to install filters during the loader stage.
This approach, a bit hacky, also has several caveats:
* _openat_, _mmap_, etc. must be allowed in order to reach the
LD_PRELOAD mechanism, and for the crafted library to work ;
* it doesn't work for static binaries.

I only see hackish ways to restrict the use of _execve_ in a
non-cooperative executable. These methods seem globally bypassables
and not satisfactory from a security point of view.

IMHO, a way to prepare filter and enable them only on the next
_execve_ would have some benefit:
* have a way to restrict _execve_ in a non-cooperative executable;
* install filters atomically, ie. before the _execve_ system call
return. That would limit racy situations, and have the very firsts
instructions of potentially untrusted binaries already subject to
seccomp filters. It would also ensure there is only one thread running
at the filter enabling time.

From what I understand, there is a relative use case[2] where the
"enable on exec" mode would also be a solution.

Thanks for your attention,
C. Mougey

[1]: https://github.com/netblue30/firejail/issues/3685
[2]: https://lore.kernel.org/linux-man/202010250759.F9745E0B6@keescook/

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-10-29 13:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-28 11:18 [seccomp] Request for a "enable on execve" mode for Seccomp filters Camille Mougey
2020-10-28 12:42 ` Jann Horn
2020-10-28 16:49   ` Rich Felker
2020-10-28 17:34     ` Jann Horn
2020-10-28 17:52       ` Rich Felker
2020-10-28 18:25         ` Jann Horn
2020-10-28 18:35           ` Rich Felker
2020-10-28 18:39             ` Jann Horn
2020-10-28 18:50               ` Rich Felker
2020-10-28 22:03     ` Kees Cook
2020-10-28 22:00   ` Kees Cook
2020-10-28 22:47 ` Kees Cook
2020-10-28 23:59   ` Andy Lutomirski
2020-10-29  7:58   ` Sargun Dhillon
2020-10-29 13:56     ` Rich Felker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox