public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Andrei Vagin <avagin@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Christian Brauner <brauner@kernel.org>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	libc-alpha@sourceware.org, Alexey Izbyshev <izbyshev@ispras.ru>,
	Carlos O'Donell <carlos@redhat.com>
Subject: Re: [PATCH v4 0/3] Linux: Fix posix_spawn when user with time namespaces
Date: Wed, 8 Jun 2022 00:21:23 -0700	[thread overview]
Message-ID: <YqBN8y6/j1ztdVyV@gmail.com> (raw)
In-Reply-To: <87sfori3dy.fsf@oldenburg.str.redhat.com>

On Mon, May 30, 2022 at 02:58:01PM +0200, Florian Weimer wrote:
> * Andrei Vagin:
> 
> [CLONE_NEWTIME and vfork]
> 
> >> Breaking vfork is really a bit of a hassle for us, and the workaround
> >> code is quite non-trivial and will have to implemented across many
> >> projects (not just glibc).  An unshare request that takes effect on
> >> execve only would really help.
> >
> > Is the problem that vfork fails if a process has half-entered a time
> > namespace?
> 
> Exactly.  Anything that implements a general-purpose process launching
> facility on top of vfork now needs to implement fork fallback (after
> vfork failure), so that launching processes still works if the original
> process has called unshare(CLONE_NEWTIME).  
> 
> In glibc, this affects posix_spawn, but other libcs are also impacted,
> and so is any custom posix_spawn-like interface that uses vfork
> internally.  Without fork fallback, they turn unusable if anything in
> the process has previously called unshare(CLONE_NEWTIME).  The fallback
> implementation tends to be complicated if it's necessary to report
> execve and other errors to the caller.  There is a choice between the
> O_CLOEXEC pipe hack (which has become more complex to implement due to
> close_range support), or a shared mapping has to be created using
> MAP_SHARED, and the subprocess writes error information to that (which
> adds more potentially costly MM updates).  MAP_SHARED is probably easier
> to implement than the pipe approach (no interference possible from file
> actions), but for glibc, Adhemerval wrote something based on the pipe
> approach.
> 
> But the key point is that any general-purpose wrapper around vfork now
> has to implement fork fallback.
> 
> Regarding the patch you sketched, we'd probably have to introduce a new
> flag (not CLONE_NEWTIME) for this because the difference in behavior is
> quite visible.

I agree that if we want to switch timens on exec, we need to introduce a
new clone flag. But I would like to avoid doing that. I think we can
live with the current clone flag if we allow switching timens only when
exec is executed by a vfork-ed process. In this case, the chance to
affect existing users is very low, isn't it?


Without the new change, vfork fails if the currect process has unshared
timens. With the change, vfork creates a new process, and the following
exec executes a binary in the target timens.

Thanks,
Andrei

  reply	other threads:[~2022-06-08  7:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10 19:11 Adhemerval Zanella
2022-05-10 19:11 ` [PATCH v4 1/3] linux: Add CLONE_NEWTIME from Linux 5.6 to bits/sched.h Adhemerval Zanella
2022-05-23 13:45   ` Adhemerval Zanella
2022-05-10 19:11 ` [PATCH v4 2/3] support: Add support_enter_time_namespace Adhemerval Zanella
2022-05-10 19:11 ` [PATCH v4 3/3] linux: Add fallback for clone failure on posix_spawn (BZ #29115) Adhemerval Zanella
2022-05-10 19:18 ` [PATCH v4 0/3] Linux: Fix posix_spawn when user with time namespaces Florian Weimer
2022-05-11  9:21   ` Christian Brauner
2022-05-11 16:01     ` Alexey Izbyshev
2022-05-25 12:24     ` Florian Weimer
2022-05-27 15:53       ` Andrei Vagin
2022-05-28  0:03         ` Andrei Vagin
2022-05-29 14:33           ` Christian Brauner
2022-05-30 12:58         ` Florian Weimer
2022-06-08  7:21           ` Andrei Vagin [this message]
2022-06-08  8:35             ` Florian Weimer

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=YqBN8y6/j1ztdVyV@gmail.com \
    --to=avagin@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=brauner@kernel.org \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=izbyshev@ispras.ru \
    --cc=libc-alpha@sourceware.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).