Skip to content

Commit 41a81b0

Browse files
committed
pidfs: never refuse ppid == 0 in PIDFD_GET_INFO
JIRA: https://issues.redhat.com/browse/RHEL-113598 commit b55eb6e Author: Mike Yuan <me@yhndnzj.com> Date: Wed, 4 Jun 2025 15:03:42 +0000 pidfs: never refuse ppid == 0 in PIDFD_GET_INFO In systemd we spotted an issue after switching to ioctl(PIDFD_GET_INFO) for obtaining pid number the pidfd refers to, that for processes with a parent from outer pidns PIDFD_GET_INFO unexpectedly yields -ESRCH [1]. It turned out that there's an arbitrary check blocking this, which is not really sensible given getppid() happily returns 0 for such processes. Just drop the spurious check and userspace ought to handle ppid == 0 properly everywhere. [1] systemd/systemd#37715 Fixes: cdda1f2 ("pidfd: add ioctl to retrieve pid info") Signed-off-by: Mike Yuan <me@yhndnzj.com> Link: https://lore.kernel.org/20250604150238.42664-1-me@yhndnzj.com Cc: Christian Brauner <brauner@kernel.org> Cc: Luca Boccassi <luca.boccassi@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Waiman Long <longman@redhat.com>
1 parent 7da4add commit 41a81b0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/pidfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)
335335
kinfo.pid = task_pid_vnr(task);
336336
kinfo.mask |= PIDFD_INFO_PID;
337337

338-
if (kinfo.pid == 0 || kinfo.tgid == 0 || (kinfo.ppid == 0 && kinfo.pid != 1))
338+
if (kinfo.pid == 0 || kinfo.tgid == 0)
339339
return -ESRCH;
340340

341341
copy_out:

0 commit comments

Comments
 (0)