linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andrei Vagin <avagin@gmail.com>,
	Alexey Izbyshev <izbyshev@ispras.ru>,
	Florian Weimer <fweimer@redhat.com>,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Kees Cook <keescook@chromium.org>
Subject: Re: Potentially undesirable interactions between vfork() and time namespaces
Date: Fri, 9 Sep 2022 09:51:58 +0200	[thread overview]
Message-ID: <20220909075158.ed4linrpwwabxabl@wittgenstein> (raw)
In-Reply-To: <87v8pxa51n.fsf@email.froward.int.ebiederm.org>

On Thu, Sep 08, 2022 at 05:13:08PM -0500, Eric W. Biederman wrote:
> Christian Brauner <brauner@kernel.org> writes:
> 
> > On Wed, Sep 07, 2022 at 10:15:51AM -0700, Andrei Vagin wrote:
> >> On Wed, Sep 07, 2022 at 08:33:20AM +0300, Alexey Izbyshev wrote:
> >> > > 
> >> > > That is something to be double checked.
> >> > > 
> >> > > I can't see where it would make sense to unshare a time namespace and
> >> > > then call exec, instead of calling exit.  So I suspect we can just
> >> > > change this behavior and no one will notice.
> >> > > 
> >> > One can imagine a helper binary that calls unshare, forks some children in
> >> > new namespaces, and then calls exec to hand off actual work to another
> >> > binary (which might not expect being in the new time namespace). I'm purely
> >> > theorizing here, however. Keeping a special case for vfork() based only on
> >> > FUD is likely a net negative, so it'd be nice to hear actual time namespace
> >> > users speak up, and switch to the solution you suggested if they don't care.
> >> 
> >> I can speak for one tool that uses time namespaces for the right
> >> reasons. It is CRIU.  When a process is restored, the monotonic and
> >> boottime clocks have to be adjusted to match old values. It is for what
> >> the timens was designed for. These changes doesn't affect CRIU.
> >> 
> >> Honestly, I haven't heard about other users of timens yet. I don't take
> >> into account tools like unshare.
> >
> > LXC/LXD does
> >
> > unshare(CLONE_NEWTIME)
> > // write offsets to /proc/self/timens_offsets
> > timens_fd = open("/proc/self/ns/time_for_children", O_RDONLY | O_CLOEXEC)
> > setns(timens_fd, CLONE_NEWTIME)
> > exec(payload)
> >
> > so I agree don't change the uapi, please.
> >
> > But as you can see what we do is basically emulating changing time
> > namespace during exec via the setns() prior to the exec call.
> 
> If I understand the description of lxc/lxd correctly the proposed change
> will not effect lxc/lxd, as the time namespace is already installed
> before exec.  If anything what is proposed would potentially allow
> lxc/lxd to be simplified in the future by removing the setns.
> 
> Are you then requesting the behavior of the time namespace not change
> when the proposed change will not effect lxc/lxd?

Don't change /proc/self/ns/time_for_children to a different name.
As stated above the proposed exec behavior we currently clearly emulate
in userspace. So that part is fine.


  reply	other threads:[~2022-09-09  7:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30 19:49 Alexey Izbyshev
2022-08-31  1:18 ` Andrei Vagin
2022-09-01  3:45   ` Andrei Vagin
2022-09-01  4:21     ` Florian Weimer
2022-09-01 15:49     ` Alexey Izbyshev
2022-09-01 18:11     ` Eric W. Biederman
2022-09-02 16:14       ` Andrei Vagin
2022-09-02 16:39         ` Alexey Izbyshev
2022-09-02 17:20           ` Andrei Vagin
2022-09-02 17:01       ` Alexey Izbyshev
2022-09-02 17:28         ` Andrei Vagin
2022-09-06 22:16         ` Eric W. Biederman
2022-09-07  5:33           ` Alexey Izbyshev
2022-09-07 17:15             ` Andrei Vagin
2022-09-08  8:10               ` Christian Brauner
2022-09-08 22:13                 ` Eric W. Biederman
2022-09-09  7:51                   ` Christian Brauner [this message]
2022-09-11 15:12                     ` Kees Cook
2022-09-11 22:51                       ` Andrei Vagin

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=20220909075158.ed4linrpwwabxabl@wittgenstein \
    --to=brauner@kernel.org \
    --cc=0x7f454c46@gmail.com \
    --cc=avagin@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=fweimer@redhat.com \
    --cc=izbyshev@ispras.ru \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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