From: Rich Felker <dalias@libc.org>
To: Alexey Izbyshev <izbyshev@ispras.ru>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Calling setxid() in a vfork()-child
Date: Tue, 13 Oct 2020 12:07:45 -0400 [thread overview]
Message-ID: <20201013160744.GQ17637@brightrain.aerifal.cx> (raw)
In-Reply-To: <208f256649f23621ada37409eb02ff86@ispras.ru>
On Tue, Oct 13, 2020 at 06:24:45PM +0300, Alexey Izbyshev wrote:
> On 2020-10-13 05:47, Markus Wichmann wrote:
> >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.
> >
> What do you mean by "do it properly"? Unless you mean doing
> syscalls, it seems that I'd have the same issues with clone() (with
> CLONE_VFORK, since I'm trying to avoid copying of page tables) as I
> do with vfork(). Namely, I'd still have to care about signals, and I
> wouldn't be able to safely call setxid() (and, frankly, anything
> else from a C library if we want a solution that's, while being
> Linux-specific, still portable across C libraries).
Indeed, it's not safe to call libc functions from a CLONE_VM context.
We might want to make some sort of contract about a subset that are
safe to call, but right now there really isn't such a set. AS-safe
functions might be close, and indeed after the __synccall change
set*id should in theory work from a clone() context too.
Really, unless you're trying to support NOMMU, "do it properly" means
just forgetting about CLONE_VM if posix_spawn doesn't meet your needs
and using plain fork+...+exec.
Rich
next prev parent reply other threads:[~2020-10-13 16:08 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
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 [this message]
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=20201013160744.GQ17637@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=izbyshev@ispras.ru \
--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).