diff options
| author | Chen Linxuan <me@black-desk.cn> | 2026-11-06 15:12:23 +0800 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-11-10 22:13:15 +0100 |
| commit | a9deb044d54315498f3fbde1e14cd53eb7658722 (patch) | |
| tree | 531167ffa2dbfd5a1540ae33e5c3ba5fa91edfc1 /include/uapi | |
| parent | d0f84855938e3e170a1b271180a407e4c730c571 (diff) | |
| download | linux-next-a9deb044d54315498f3fbde1e14cd53eb7658722.tar.gz linux-next-a9deb044d54315498f3fbde1e14cd53eb7658722.zip | |
pidfd: Add task path ioctls
Add PIDFD_GET_EXE, PIDFD_GET_CWD, and PIDFD_GET_ROOT so callers holding
a pidfd can obtain close-on-exec O_PATH file descriptors for the
target's executable, working directory, and root without requiring
procfs.
Use the task acquisition helper shared with the namespace ioctls to
check PID namespace visibility and ptrace access. Hold exec_update_lock
across the access check and path acquisition to prevent a concurrent
execve() from changing the target's credentials between them.
Add task_path_open() to perform weak revalidation before opening the
selected path. This gives the filesystem the opportunity to reject a
path handed out directly by a task, as it can when following a procfs
magic link. Pass flags zero because no pathname lookup is performed,
propagate negative errors, and return ESTALE for a zero result.
Release exec_update_lock before calling task_path_open() so filesystem
revalidation runs outside the target's exec critical section.
Suggested-by: Christian Brauner <brauner@kernel.org>
Link: https://lore.kernel.org/all/20261105-gefolge-rosten-neueinstellung-6223a18aae90@brauner/
Signed-off-by: Chen Linxuan <me@black-desk.cn>
Link: https://patch.msgid.link/20261106-pidfd-get-paths-v5-3-3147ce6571cb@black-desk.cn
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include/uapi')
| -rw-r--r-- | include/uapi/linux/pidfd.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/uapi/linux/pidfd.h b/include/uapi/linux/pidfd.h index 0919246a1611..95ce1819f423 100644 --- a/include/uapi/linux/pidfd.h +++ b/include/uapi/linux/pidfd.h @@ -121,4 +121,11 @@ struct pidfd_info { #define PIDFD_GET_UTS_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 10) #define PIDFD_GET_INFO _IOWR(PIDFS_IOCTL_MAGIC, 11, struct pidfd_info) +/* Return an O_PATH file descriptor for the target task's executable. */ +#define PIDFD_GET_EXE _IO(PIDFS_IOCTL_MAGIC, 12) +/* Return an O_PATH file descriptor for the target task's working directory. */ +#define PIDFD_GET_CWD _IO(PIDFS_IOCTL_MAGIC, 13) +/* Return an O_PATH file descriptor for the target task's root directory. */ +#define PIDFD_GET_ROOT _IO(PIDFS_IOCTL_MAGIC, 14) + #endif /* _UAPI_LINUX_PIDFD_H */ |
