[GIT PULL v1] core process updates for v5.4

From: Christian Brauner
Date: Tue Sep 10 2019 - 12:01:33 EST

Hi Linus,

This is a resend of the pull request for v5.4 with the clone3 extension for
choosing a specific pid at process creation time _dropped_: After an
in-person discussion between multiple parties at LPC/KSummit use-cases were
presented that require restoring nested pid namespaces. This means clone3
would need to create a process with specific pids in multiple pid
namespaces not just a single one. For this reason, it seems wise to delay
this feature one more cycle to get the semantics for this right. Sorry for
the churn! The rest is _unchanged_.

This pull request includes the current process group and pidfd extensions
for the waitid() syscall and various tests.
All changes are centered around process management not just the pidfd api.
For this reason the tag name is core-process-v5.4. If you have objections
and would rather see this split in separate PRs, please tell me.

The following changes since commit 5f9e832c137075045d15cd6899ab0505cfb2ca4b:

Linus 5.3-rc1 (2019-07-21 14:05:38 -0700)

are available in the Git repository at:

git@xxxxxxxxxxxxxxxxxxx:pub/scm/linux/kernel/git/brauner/linux tags/core-process-v5.4

for you to fetch changes up to 821cc7b0b205c0df64cce59aacc330af251fa8f7:

waitid: Add support for waiting for the current process group (2019-09-10 17:05:46 +0200)

/* Summary */
This tag contains two features and various tests.

First, it adds support for waiting on process through pidfds by adding the
P_PIDFD type to the waitid() syscall. This completes the basic
functionality of the pidfd api (cf. [1]).
In the meantime we also have a new adition to the userspace projects that
make use of the pidfd api. The qt project was nice enough to send a mail
pointing out that they have a pr up to switch to the pidfd api (cf. [2]).

Second, this tag contains an extension to the waitid() syscall to make it
possible to wait on the current process group in a race free manner (even
though the actual problem is very unlikely) by specifing 0 together with
the P_PGID type. This extension traces back to a discussion on the glibc
development mailing list.

There are also a range of tests for the features above. Additionally, the
test-suite which detected the pidfd-polling race we fixed in [3] is
included in this tag.

/* Testing */
All patches are based on v5.3-rc1 and have been sitting in linux-next since
then or at least before v5.3-rc3. None of them have caused failures or
warnings and they are passing the tests accompanying them.

/* Conflicts */
At the time of creating this PR no merge conflicts were observed in

Please consider pulling these changes from the signed core-process-v5.4 tag.


/* References */
[1]: https://lwn.net/Articles/794707/
[2]: https://codereview.qt-project.org/c/qt/qtbase/+/108456
[3]: commit b191d6491be6 ("pidfd: fix a poll race when setting exit_state")


Christian Brauner (2):
pidfd: add P_PIDFD to waitid()
pidfd: add pidfd_wait tests

Eric W. Biederman (1):
waitid: Add support for waiting for the current process group

Suren Baghdasaryan (2):
tests: move common definitions and functions into pidfd.h
tests: add pidfd poll tests

include/linux/pid.h | 4 +
include/uapi/linux/wait.h | 1 +
kernel/exit.c | 38 +++-
kernel/fork.c | 8 +
kernel/signal.c | 7 +-
tools/testing/selftests/pidfd/.gitignore | 2 +
tools/testing/selftests/pidfd/Makefile | 2 +-
tools/testing/selftests/pidfd/pidfd.h | 30 +++
tools/testing/selftests/pidfd/pidfd_open_test.c | 5 -
tools/testing/selftests/pidfd/pidfd_poll_test.c | 117 ++++++++++
tools/testing/selftests/pidfd/pidfd_test.c | 14 --
tools/testing/selftests/pidfd/pidfd_wait.c | 271 ++++++++++++++++++++++++
12 files changed, 473 insertions(+), 26 deletions(-)
create mode 100644 tools/testing/selftests/pidfd/pidfd_poll_test.c
create mode 100644 tools/testing/selftests/pidfd/pidfd_wait.c