Re: [GIT PULL] pidfd patches for v5.2-rc1
From: Christian Brauner
Date: Tue May 07 2019 - 08:50:03 EST
On Mon, May 06, 2019 at 02:36:59PM +0200, Christian Brauner wrote:
> Hi Linus,
>
> This is the promised pull request for the CLONE_PIDFD flag to the clone()
> syscall in its agreed upon form:
>
> The following changes since commit 15ade5d2e7775667cf191cf2f94327a4889f8b9d:
>
> Linux 5.1-rc4 (2019-04-07 14:09:59 -1000)
>
> are available in the Git repository at:
>
> git@xxxxxxxxxxxxxxxxxxx:pub/scm/linux/kernel/git/brauner/linux tags/pidfd-v5.2-rc1
>
> for you to fetch changes up to 0786de75cbc560f779378c862b8bac16bee74d10:
I just realized that this still includes the old hash for the tag where
Jann's email is not fixed up. The fixed tag didn't get pushed to
kernel.org correctly. Probably just my incompetence. I fixed it. So this
should read:
for you to fetch changes up to 43c6afee48d4d866d5eb984d3a5dbbc7d9b4e7bf:
Sorry about that!
Christian
>
> samples: show race-free pidfd metadata access (2019-05-06 13:26:37 +0200)
>
> /* Testing */
> The patches have been sitting in linux-next for quite a while.
> The recent change date on two of the commits is caused by a necessary
> update to Jann's mail address for the co-developed and signed-off-by lines.
> No semantic changes were done!
>
> /* Conflicts with other trees */
> Please note, that the pidfd branch has two minor conflicts. The first with
> akpm-current/current. The conflict and fix for it can be found under [1].
> The second with the kbuild tree. The conflict and fix for it can be found
> under [2].
> I'm happy to provide a fixed up tree but was told you usually prefer to do
> it yourself when reasonably small.
>
> /* Summary */
> This patchset makes it possible to retrieve pidfds at process creation time
> by introducing the new flag CLONE_PIDFD to the clone() system call. Linus
> originally suggested to implement this as a new flag to clone() instead of
> making it a separate system call.
>
> After a thorough review from Oleg CLONE_PIDFD returns pidfds in the
> parent_tidptr argument. This means we can give back the associated pid and
> the pidfd at the same time. Access to process metadata information thus
> becomes rather trivial.
>
> As has been agreed, CLONE_PIDFD creates file descriptors based on anonymous
> inodes similar to the new mount api. They are made unconditional by this
> patchset as they are now needed by core kernel code (vfs, pidfd) even more
> than they already were before (timerfd, signalfd, io_uring, epoll etc.).
> The core patchset is rather small. The bulky looking changelist is caused
> by David's very simple changes to Kconfig to make anon inodes unconditional.
>
> A pidfd comes with additional information in fdinfo if the kernel supports
> procfs. The fdinfo file contains the pid of the process in the callers pid
> namespace in the same format as the procfs status file, i.e. "Pid:\t%d".
>
> To remove worries about missing metadata access this patchset comes with a
> sample/test program that illustrates how a combination of CLONE_PIDFD and
> pidfd_send_signal() can be used to gain race-free access to process
> metadata through /proc/<pid>.
>
> Further work based on this patchset has been done by Joel. His work makes
> pidfds pollable. It finished too late for this merge window. I would
> prefer to have it sitting in linux-next for a while and send it for
> inclusion during the 5.3 merge window.
>
> Please consider pulling these changes from the signed pidfd-v5.2-rc1 tag.
>
> Thanks!
> Christian
>
> [1]: https://lore.kernel.org/lkml/20190423184657.3d16ba97@xxxxxxxxxxxxxxxx/
> [2]: https://lore.kernel.org/lkml/20190502183125.3b53300e@xxxxxxxxxxxxxxxx/
>
> ----------------------------------------------------------------
> pidfd patches for v5.2-rc1
>
> ----------------------------------------------------------------
> Christian Brauner (3):
> clone: add CLONE_PIDFD
> signal: support CLONE_PIDFD with pidfd_send_signal
> samples: show race-free pidfd metadata access
>
> David Howells (1):
> Make anon_inodes unconditional
>
> arch/arm/kvm/Kconfig | 1 -
> arch/arm64/kvm/Kconfig | 1 -
> arch/mips/kvm/Kconfig | 1 -
> arch/powerpc/kvm/Kconfig | 1 -
> arch/s390/kvm/Kconfig | 1 -
> arch/x86/Kconfig | 1 -
> arch/x86/kvm/Kconfig | 1 -
> drivers/base/Kconfig | 1 -
> drivers/char/tpm/Kconfig | 1 -
> drivers/dma-buf/Kconfig | 1 -
> drivers/gpio/Kconfig | 1 -
> drivers/iio/Kconfig | 1 -
> drivers/infiniband/Kconfig | 1 -
> drivers/vfio/Kconfig | 1 -
> fs/Makefile | 2 +-
> fs/notify/fanotify/Kconfig | 1 -
> fs/notify/inotify/Kconfig | 1 -
> include/linux/pid.h | 2 +
> include/uapi/linux/sched.h | 1 +
> init/Kconfig | 10 ----
> kernel/fork.c | 108 +++++++++++++++++++++++++++++++++++++--
> kernel/signal.c | 12 +++--
> kernel/sys_ni.c | 3 --
> samples/Makefile | 2 +-
> samples/pidfd/Makefile | 6 +++
> samples/pidfd/pidfd-metadata.c | 112 +++++++++++++++++++++++++++++++++++++++++
> 26 files changed, 236 insertions(+), 38 deletions(-)
> create mode 100644 samples/pidfd/Makefile
> create mode 100644 samples/pidfd/pidfd-metadata.c