aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/pidfd
diff options
context:
space:
mode:
authorChristian Brauner <christian.brauner@ubuntu.com>2019-10-17 12:18:28 +0200
committerChristian Brauner <christian.brauner@ubuntu.com>2019-10-17 15:36:50 +0200
commit3d6d8da48d0b214d65ea0227d47228abc75d7c88 (patch)
tree389de3a6c77902dccbf7957ced2c550cac64ac69 /tools/testing/selftests/pidfd
parentpidfd: add tests for NSpid info in fdinfo (diff)
downloadlinux-dev-3d6d8da48d0b214d65ea0227d47228abc75d7c88.tar.xz
linux-dev-3d6d8da48d0b214d65ea0227d47228abc75d7c88.zip
pidfd: check pid has attached task in fdinfo
Currently, when a task is dead we still print the pid it used to use in the fdinfo files of its pidfds. This doesn't make much sense since the pid may have already been reused. So verify that the task is still alive by introducing the pid_has_task() helper which will be used by other callers in follow-up patches. If the task is not alive anymore, we will print -1. This allows us to differentiate between a task not being present in a given pid namespace - in which case we already print 0 - and a task having been reaped. Note that this uses PIDTYPE_PID for the check. Technically, we could've checked PIDTYPE_TGID since pidfds currently only refer to thread-group leaders but if they won't anymore in the future then this check becomes problematic without it being immediately obvious to non-experts imho. If a thread is created via clone(CLONE_THREAD) than struct pid has a single non-empty list pid->tasks[PIDTYPE_PID] and this pid can't be used as a PIDTYPE_TGID meaning pid->tasks[PIDTYPE_TGID] will return NULL even though the thread-group leader might still be very much alive. So checking PIDTYPE_PID is fine and is easier to maintain should we ever allow pidfds to refer to threads. Cc: Jann Horn <jannh@google.com> Cc: Christian Kellner <christian@kellner.me> Cc: linux-api@vger.kernel.org Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com> Reviewed-by: Oleg Nesterov <oleg@redhat.com> Link: https://lore.kernel.org/r/20191017101832.5985-1-christian.brauner@ubuntu.com
Diffstat (limited to 'tools/testing/selftests/pidfd')
0 files changed, 0 insertions, 0 deletions