pidfd: Add task path ioctls
Get series with b4
b4 am [email protected] change-id 20260819-pidfd-get-paths-59640d8cd1eeVersions newest first
- v5 Latest3 patches 0 repliesNew
- v43 patches 2 repliesSuperseded
- v34 patches 0 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 3 patches | 11 replies | Superseded | |
| v1 RFC | 3 patches | 0 replies | Superseded |
Changes in v5 from the cover letter
- Add task_path_open() as suggested by Christian Brauner, replacing the direct dentry_open() call from v4. Revalidate with flags zero outside exec_update_lock and return filesystem errors without lookup retries.
- Link to v4:
https://lore.kernel.org/all/[email protected]/
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | fs: Introduce task path helpersfs/ fs/ include/ +3 more | +75 | 0 replies | |
| 2/3 | pidfd: Use scoped cleanup for task accessfs/ | +74 | 0 replies | |
| 3/3 | pidfd: Add task path ioctlsfs/ fs/ fs/ +1 more | +75 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.
Cover letter [PATCH v5 0/3] pidfd: Add task path ioctls
Obtaining a target task's executable, working directory or root currently requires following /proc/<pid>/{exe,cwd,root}. Add PIDFD_GET_EXE, PIDFD_GET_CWD and PIDFD_GET_ROOT so callers holding a pidfd can obtain these paths without requiring procfs to be mounted or visible.
Each ioctl takes a zero argument and returns an O_PATH file descriptor with FD_CLOEXEC set. Targets must be visible in the caller's active pid namespace. Reuse the procfs path getters and hold exec_update_lock across PTRACE_MODE_READ_FSCREDS authorization and path acquisition.
Following Christian Brauner's review, use a dedicated task_path_open() helper after releasing exec_update_lock. It calls ->d_weak_revalidate() with flags zero when the filesystem provides it, propagates a negative error, maps a zero result to ESTALE, and otherwise opens the path with O_PATH. This gives filesystems such as failfs the opportunity to refuse an O_PATH descriptor without starting a pathname lookup.
The first patch factors out the task path getters. The second prepares scoped task access for the pidfd ioctls. The third adds the three ioctls and task_path_open().
This series depends on the separately submitted pid-namespace visibility restriction:
https://lore.kernel.org/all/[email protected]/
Tested with virtme-ng.
Sashiko AI review reported the missing weak revalidation in v4. This entire patch series was generated with LLM assistance. I defined the requirements, guided the implementation, reviewed the changes, and made the design decisions.
---
Changes in v5:
- Add task_path_open() as suggested by Christian Brauner, replacing the direct dentry_open() call from v4. Revalidate with flags zero outside exec_update_lock and return filesystem errors without lookup retries.
- Link to v4:
https://lore.kernel.org/all/[email protected]/
To: Alexander Viro <[email protected]>
To: Christian Brauner <[email protected]>
To: Jan Kara <[email protected]>
To: Andrew Morton <[email protected]>
To: David Hildenbrand <[email protected]>
To: Lorenzo Stoakes <[email protected]>
To: "Liam R. Howlett" <[email protected]>
To: Vlastimil Babka <[email protected]>
To: Mike Rapoport <[email protected]>
To: Suren Baghdasaryan <[email protected]>
To: Michal Hocko <[email protected]>
To: Ingo Molnar <[email protected]>
To: Peter Zijlstra <[email protected]>
To: Juri Lelli <[email protected]>
To: Vincent Guittot <[email protected]>
To: Dietmar Eggemann <[email protected]>
To: Steven Rostedt <[email protected]>
To: Ben Segall <[email protected]>
To: Mel Gorman <[email protected]>
To: Valentin Schneider <[email protected]>
To: K Prateek Nayak <[email protected]>
To: Kees Cook <[email protected]>
To: John Johansen <[email protected]>
To: Georgia Garcia <[email protected]>
To: Paul Moore <[email protected]>
To: James Morris <[email protected]>
To: "Serge E. Hallyn" <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Chen Linxuan (3):
fs: Introduce task path helpers
pidfd: Use scoped cleanup for task access
pidfd: Add task path ioctls
fs/fs_struct.c | 44 +++++++++++++ fs/internal.h | 1 + fs/open.c | 30 +++++++++ fs/pidfs.c | 157 ++++++++++++++++++++++++++++++++------------- fs/proc/base.c | 34 +--------- include/linux/fs_struct.h | 3 + include/linux/mm.h | 1 + include/uapi/linux/pidfd.h | 7 ++ kernel/fork.c | 22 +++++++ security/apparmor/task.c | 12 +--- 10 files changed, 224 insertions(+), 87 deletions(-)
---
base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
change-id: 20260819-pidfd-get-paths-59640d8cd1ee
prerequisite-change-id: 20261027-pidfd-task-access-b797ecb260a4:v1
prerequisite-patch-id: 021f6b0840ced7fe967a849b99c366257160c005
Best regards,
Signature · 1 line
Chen Linxuan <[email protected]>