]> www.infradead.org Git - users/jedix/linux-maple.git/commit
pidfd: add ioctl to retrieve pid info
authorLuca Boccassi <luca.boccassi@gmail.com>
Thu, 10 Oct 2024 15:52:32 +0000 (16:52 +0100)
committerChristian Brauner <brauner@kernel.org>
Thu, 24 Oct 2024 11:54:51 +0000 (13:54 +0200)
commitcdda1f26e74bac732eca537a69f19f6a37b641be
tree07fcfc8122c1a1ef147f40f70d58fa68232f5200
parent8e929cb546ee42c9a61d24fae60605e9e3192354
pidfd: add ioctl to retrieve pid info

A common pattern when using pid fds is having to get information
about the process, which currently requires /proc being mounted,
resolving the fd to a pid, and then do manual string parsing of
/proc/N/status and friends. This needs to be reimplemented over
and over in all userspace projects (e.g.: I have reimplemented
resolving in systemd, dbus, dbus-daemon, polkit so far), and
requires additional care in checking that the fd is still valid
after having parsed the data, to avoid races.

Having a programmatic API that can be used directly removes all
these requirements, including having /proc mounted.

As discussed at LPC24, add an ioctl with an extensible struct
so that more parameters can be added later if needed. Start with
returning pid/tgid/ppid and creds unconditionally, and cgroupid
optionally.

Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Link: https://lore.kernel.org/r/20241010155401.2268522-1-luca.boccassi@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/pidfs.c
include/uapi/linux/pidfd.h
tools/testing/selftests/pidfd/pidfd_open_test.c