From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Subject: Re: [musl] Calling setxid() in a vfork()-child
Date: Tue, 13 Oct 2020 04:47:37 +0200 [thread overview]
Message-ID: <20201013024737.GB7816@voyager> (raw)
In-Reply-To: <fcfe55b416f8225de3875699bc126250@ispras.ru>
On Mon, Oct 12, 2020 at 11:30:58PM +0300, Alexey Izbyshev wrote:
> Unfortunately, while posix_spawn() + a helper executable would be fine in
> many cases (more so for applications than libraries), addition of a helper
> to an existing library exposing a process creation API that can't be
> implemented in terms of posix_spawn() may be not straightforward. If the
> helper is just an executable file, we'll need to locate it, which may be
> simply impossible when our library is called if, say, switching mount
> namespaces is involved (which may be out of control of our library).
> Solutions may exist (locate and open() at startup or memfd_create(), and
> then execveat()?), but vfork() (+ preventing execution of signal handlers in
> the child) seems so much simpler, and doesn't add the overhead of an extra
> execve() too.
>
> Alexey
>
If dropping privileges is all you want, then posix_spawn() has a flag
for that. And if you are foregoing portability anyway by doing anything
between vfork() and execve(), might as well use clone() and do it
properly.
Yes, locating a helper binary is a bit of a problem. I've been recently
struggling with that myself. While you can make the binary part of the
main application (or library, in your case), using posix_spawn() means
the binary must have a path name, so using tempfile() is out of the
question (unless you use the proc file name, which is, again,
non-portable).
Ciao,
Markus
next prev parent reply other threads:[~2020-10-13 2:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-12 9:27 Alexey Izbyshev
2020-10-12 14:55 ` Rich Felker
2020-10-12 20:30 ` Alexey Izbyshev
2020-10-13 2:47 ` Markus Wichmann [this message]
2020-10-13 9:52 ` Laurent Bercot
2020-10-13 15:48 ` Alexey Izbyshev
2020-10-13 15:24 ` Alexey Izbyshev
2020-10-13 16:07 ` Rich Felker
2020-10-13 16:52 ` Alexey Izbyshev
2020-10-13 17:05 ` Rich Felker
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=20201013024737.GB7816@voyager \
--to=nullplan@gmx.net \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).