Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9656665ybi; Wed, 24 Jul 2019 07:48:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQ7LFYRg+gFdzl40Mndarx8xh2xRfYKHKma9d1JQgx78RAt9NNk1BwnXaXBW1/tJIhPx1n X-Received: by 2002:a17:902:e287:: with SMTP id cf7mr85373114plb.32.1563979699001; Wed, 24 Jul 2019 07:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563979698; cv=none; d=google.com; s=arc-20160816; b=cyhZDMfK9o7AXCkVDdVJR9WwI0VYWO/8Nz1Ytn9jWvcognA/yGnkJWZjil7q9kMK9j UaCWtPAR9CudDgRY5FAyowFqMdaMmHOZndoznYvJoxg68HqzHDA+zDK5jQhWe9XkV9nL SIVQDQBX1QVDJwsX/ERFMVdyWmB/oNmWZv5aRXnyxJInQUkxogDMosa/ojtFP0YZP/JS tG+jd3ENsm5PgBGRhG8MysgoztzlEF3rzcxKY87JRBLevKC3czW0LJuCmRSzGI6kQ7cb nF4kqWMdCaZSsuotM6P6NK5x0KF9yndDWEtZ23kc8yxCXzkpprz4MzIr/WfAAO6S3rTr fZYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+x1xAgVfBQpMxOF18mx/2Uy7ftJyt8nFpuTntfkBjEg=; b=fNbg1RchvBWl8jBMwX1R7fzkV1j8JZ90NvzhogEdEVAcFVnF+Uss+3Z8u1wVqZlEYi xkprn8+BwsyfuTpYOG+O2hz0XYWNmN3ZImesLpxEABBngqn5ZsADNVN8RePJahfxyeEG ef2QQDTN8UvC+RM4790XZaAa5RW/cTZHE7qPkZLWTqlNytuK43wmO1YimQx6mV8uDvjP 2i+kxPz8BmBFotYocaU2yWhAlr4wFSe95dMBVLO6pgyroqDJXldTrgkYjEnAOWsAMrw2 uFmboAsbKBWPlm4meSVPuLpPTEMR9SgEeXMOZLPoJnLrRR4Qn2xA4HfbE3ZUewAIVMBc Gnrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=RESSSGPA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e21si17236668pfl.68.2019.07.24.07.48.03; Wed, 24 Jul 2019 07:48:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=RESSSGPA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387479AbfGXOrZ (ORCPT + 99 others); Wed, 24 Jul 2019 10:47:25 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40110 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726709AbfGXOrY (ORCPT ); Wed, 24 Jul 2019 10:47:24 -0400 Received: by mail-pg1-f193.google.com with SMTP id w10so21358389pgj.7 for ; Wed, 24 Jul 2019 07:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+x1xAgVfBQpMxOF18mx/2Uy7ftJyt8nFpuTntfkBjEg=; b=RESSSGPA0O+5JYyX91vaVnA6lsxVmp5RnMRaIXurS29e1+tNscsKmgS7lkixjyGmJk WsE81K7wiVC/+cBvIw6n+WE8+odmEvgd2JEX4qbTR49bt7D4k+EMACJ7F5mTFxRN8KCC lGIMAmNVS4XTWcGlxlEEPV0QRFtO17qh1moYf1iap6wJldUA9ZUut4t6QUWL/mlLYDVq 5kltEKua2cU+bHZPplIAIp/HvcmO/bGgMKkobzb3Ldfdyk3/p3xirHjckEFgKrtOZ4xq UTwVECWAwAYu3+B0EllOPICWFksBbCitdIv0nmcHUia3I9uaduuGeXCJw6UqUlAq822c vvQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+x1xAgVfBQpMxOF18mx/2Uy7ftJyt8nFpuTntfkBjEg=; b=UdEo0zfQiQhPhKSRek+TAowKAvBAsdr9SmnIs6wn0sp5CpZritjT2upPwl7K+RW9Pm fdpKUyk8dIulGWnOAAxgokiluMSPaS+VTGV49gV0vTdMzJIDrEtBYg4TthB8p0hwFmwH 6Rz84LiWYMOvJYQYv6ZWWoKTvNlsHBgyBkyZChmVPoThB+9x8zY7keGFNFGj/y1CbUiU RLgj+EPeHaXmgKz6Z/b4Zzd5ZMCjzXf55A75PxUOExsW/TdTk/boK62jrDx9K6L0E6QX lMPW35cC/Z5Gg8S6/uICdNGq7zPm/3AgUaWKEorOhbvqs4Xd0vhnBMu7sLUx5aXoHbu4 4ZSw== X-Gm-Message-State: APjAAAVLlhrCpi66iisJLkaTRgvEeUUI5KnDYI0YMfdexphsbpbhiKtX MWvtFJNF/U465Bunm8Q8UuK2X96gzR8= X-Received: by 2002:a17:90a:5806:: with SMTP id h6mr85582626pji.126.1563979643748; Wed, 24 Jul 2019 07:47:23 -0700 (PDT) Received: from localhost.localdomain ([172.58.27.54]) by smtp.gmail.com with ESMTPSA id g6sm41125644pgh.64.2019.07.24.07.47.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 07:47:22 -0700 (PDT) From: Christian Brauner To: linux-kernel@vger.kernel.org, oleg@redhat.com Cc: arnd@arndb.de, ebiederm@xmission.com, keescook@chromium.org, joel@joelfernandes.org, tglx@linutronix.de, tj@kernel.org, dhowells@redhat.com, jannh@google.com, luto@kernel.org, akpm@linux-foundation.org, cyphar@cyphar.com, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, kernel-team@android.com, Christian Brauner Subject: [PATCH 0/5] pidfd: waiting on processes through pidfds Date: Wed, 24 Jul 2019 16:46:46 +0200 Message-Id: <20190724144651.28272-1-christian@brauner.io> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey everyone, This adds the ability to wait on processes using pidfds. This is one of the few missing pieces to make it possible to manage processes using only pidfds. pidfd_wait() does explicitly not allow scoping of the process referred to by the pidfd, i.e. generic wait requests such as P_PGID and P_ALL and other trickery such as passing in negative values and so on is not supported. The series also adds support for CLONE_WAIT_PID which prevents the process referred to by the pidfd to appear in generic wait requests similar to what is the default in FreeBSD. This feature has been requested multiple times when I gave talks about this work (for extensions see [1]). The syscall patch is rather small overall. The largest portion of this series are the tests and the cleanup to remove struct waitid_info from exit.c. Thanks! Christian [1]: In the future, we might add something like CLONE_WAIT_STATUS_FOREIGN (or some better name). Such pidfds will allow anyone to retrieve the exit status of a non-parent process by calling pidfd_wait() on it without reaping it. This has also been requested quite often and fits nicely into the api. But that's for a later patchset. Christian Brauner (5): exit: kill struct waitid_info pidfd: add pidfd_wait() arch: wire-up pidfd_wait() pidfd: add CLONE_WAIT_PID pidfd: add pidfd_wait tests arch/alpha/kernel/syscalls/syscall.tbl | 1 + arch/arm/tools/syscall.tbl | 1 + arch/arm64/include/asm/unistd.h | 2 +- arch/arm64/include/asm/unistd32.h | 4 +- arch/ia64/kernel/syscalls/syscall.tbl | 1 + arch/m68k/kernel/syscalls/syscall.tbl | 1 + arch/microblaze/kernel/syscalls/syscall.tbl | 1 + arch/mips/kernel/syscalls/syscall_n32.tbl | 1 + arch/mips/kernel/syscalls/syscall_n64.tbl | 1 + arch/mips/kernel/syscalls/syscall_o32.tbl | 1 + arch/parisc/kernel/syscalls/syscall.tbl | 1 + arch/powerpc/kernel/syscalls/syscall.tbl | 1 + arch/s390/kernel/syscalls/syscall.tbl | 1 + arch/sh/kernel/syscalls/syscall.tbl | 1 + arch/sparc/kernel/syscalls/syscall.tbl | 1 + arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/xtensa/kernel/syscalls/syscall.tbl | 1 + include/linux/pid.h | 5 + include/linux/sched.h | 1 + include/linux/syscalls.h | 4 + include/uapi/asm-generic/unistd.h | 4 +- include/uapi/linux/sched.h | 1 + kernel/exit.c | 191 ++++++---- kernel/fork.c | 19 +- kernel/signal.c | 7 +- tools/testing/selftests/pidfd/pidfd.h | 25 ++ tools/testing/selftests/pidfd/pidfd_test.c | 14 - tools/testing/selftests/pidfd/pidfd_wait.c | 398 ++++++++++++++++++++ 29 files changed, 606 insertions(+), 85 deletions(-) create mode 100644 tools/testing/selftests/pidfd/pidfd_wait.c -- 2.22.0