RFC pidfd: improve uapi when task isn't found
Get series with b4
b4 am [email protected] change-id 20250403-work-pidfd-fixes-54c5b13ee0eeVersions newest first
- v1 RFC Latest4 patches 4 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | selftests/pidfd: adapt to recent changestools/ | +6 | 0 replies | |
| 2/4 | pidfd: remove unneeded NULL check from pidfd_prepare()kernel/ | +1 | 0 replies | |
| 3/4 | pidfd: improve uapi when task isn't foundkernel/ | +28 | 14 replies | |
| 4/4 | selftest/pidfd: add test for thread-group leader pidfd open for threadtools/ | +1 | 0 replies |
Reviews trailers per patch
1 of 4 patches has a Reviewed-by or Acked-by.
| Patch | Oleg Nesterov |
|---|---|
| 1/4 | |
| 2/4 | |
| 3/4 | R-b A-b |
| 4/4 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH RFC 0/4] pidfd: improve uapi when task isn't found
Oleg,
We currently report EINVAL whenever a struct pid has no tasked attached anymore thereby conflating two concepts:
(1) The task has already been reaped.
(2) The caller requested a pidfd for a thread-group leader but the pid actually references a struct pid that isn't used as a thread-group leader.
This is causing issues for non-threaded workloads as in [1] where they expect ESRCH to be reported, not EINVAL. I think that's a very resonable assumption.
This patch tries to allow userspace to distinguish between (1) and (2). This is racy of course but that shouldn't matter.
Christian
---
Christian Brauner (4):
selftests/pidfd: adapt to recent changes
pidfd: remove unneeded NULL check from pidfd_prepare()
pidfd: improve uapi when task isn't found
selftest/pidfd: add test for thread-group leader pidfd open for thread
kernel/fork.c | 31 ++++++++++++++++++++++--- tools/testing/selftests/pidfd/pidfd_info_test.c | 13 ++++++----- 2 files changed, 35 insertions(+), 9 deletions(-)
---
base-commit: a2cc6ff5ec8f91bc463fd3b0c26b61166a07eb11
change-id: 20250403-work-pidfd-fixes-54c5b13ee0ee