mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Brauner <christian.brauner@ubuntu.com>
To: Adrian Reber <areber@redhat.com>
Cc: Eric Biederman <ebiederm@xmission.com>,
	Pavel Emelyanov <ovzxemul@gmail.com>,
	Jann Horn <jannh@google.com>, Oleg Nesterov <oleg@redhat.com>,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org, Andrei Vagin <avagin@gmail.com>,
	Mike Rapoport <rppt@linux.ibm.com>,
	Radostin Stoyanov <rstoyanov1@gmail.com>
Subject: Re: [PATCH v9 1/2] fork: extend clone3() to support setting a PID
Date: Thu, 14 Nov 2019 09:02:09 +0100	[thread overview]
Message-ID: <20191114080208.m5cl4hv5w7k2za4e@wittgenstein> (raw)
In-Reply-To: <20191114075759.3cdil2rh3dz4ozvs@wittgenstein>

On Thu, Nov 14, 2019 at 08:57:59AM +0100, Christian Brauner wrote:
> On Thu, Nov 14, 2019 at 08:07:08AM +0100, Adrian Reber wrote:
> > The main motivation to add set_tid to clone3() is CRIU.
> > 
> > To restore a process with the same PID/TID CRIU currently uses
> > /proc/sys/kernel/ns_last_pid. It writes the desired (PID - 1) to
> > ns_last_pid and then (quickly) does a clone(). This works most of the
> > time, but it is racy. It is also slow as it requires multiple syscalls.
> > 
> > Extending clone3() to support *set_tid makes it possible restore a
> > process using CRIU without accessing /proc/sys/kernel/ns_last_pid and
> > race free (as long as the desired PID/TID is available).
> > 
> > This clone3() extension places the same restrictions (CAP_SYS_ADMIN)
> > on clone3() with *set_tid as they are currently in place for ns_last_pid.
> > 
> > The original version of this change was using a single value for
> > set_tid. At the 2019 LPC, after presenting set_tid, it was, however,
> > decided to change set_tid to an array to enable setting the PID of a
> > process in multiple PID namespaces at the same time. If a process is
> > created in a PID namespace it is possible to influence the PID inside
> > and outside of the PID namespace. Details also in the corresponding
> > selftest.
> > 
> > To create a process with the following PIDs:
> > 
> >       PID NS level         Requested PID
> >         0 (host)              31496
> >         1                        42
> >         2                         1
> > 
> > For that example the two newly introduced parameters to struct
> > clone_args (set_tid and set_tid_size) would need to be:
> > 
> >   set_tid[0] = 1;
> >   set_tid[1] = 42;
> >   set_tid[2] = 31496;
> >   set_tid_size = 3;
> > 
> > If only the PIDs of the two innermost nested PID namespaces should be
> > defined it would look like this:
> > 
> >   set_tid[0] = 1;
> >   set_tid[1] = 42;
> >   set_tid_size = 2;
> > 
> > The PID of the newly created process would then be the next available
> > free PID in the PID namespace level 0 (host) and 42 in the PID namespace
> > at level 1 and the PID of the process in the innermost PID namespace
> > would be 1.
> > 
> > The set_tid array is used to specify the PID of a process starting
> > from the innermost nested PID namespaces up to set_tid_size PID namespaces.
> > 
> > set_tid_size cannot be larger then the current PID namespace level.
> > 
> > Signed-off-by: Adrian Reber <areber@redhat.com>
> 
> I have no quarrels with the core patch anymore.
> Note, once Oleg has said he's fine with this patch too I will likely
> reword the kernel-doc and the comment in alloc_pid() and the commit
> message a little before applying; but really just minor things that are
> not worth resending for.
> 
> Thanks!
> Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>

And thanks for the --base=<commit> information you've added to this
version. :)

	Christian

  reply	other threads:[~2019-11-14  8:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-14  7:07 Adrian Reber
2019-11-14  7:07 ` [PATCH v9 2/2] selftests: add tests for clone3() with *set_tid Adrian Reber
2019-11-14  8:38   ` Christian Brauner
2019-11-14  7:58 ` [PATCH v9 1/2] fork: extend clone3() to support setting a PID Christian Brauner
2019-11-14  8:02   ` Christian Brauner [this message]
2019-11-14  8:14 ` Christian Brauner
2019-11-14  8:22   ` Adrian Reber
2019-11-14  8:32     ` Christian Brauner

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=20191114080208.m5cl4hv5w7k2za4e@wittgenstein \
    --to=christian.brauner@ubuntu.com \
    --cc=0x7f454c46@gmail.com \
    --cc=areber@redhat.com \
    --cc=avagin@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=oleg@redhat.com \
    --cc=ovzxemul@gmail.com \
    --cc=rppt@linux.ibm.com \
    --cc=rstoyanov1@gmail.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®