Skip to content

Commit 8b6cb4d

Browse files
committed
pidfs: never refuse ppid == 0 in PIDFD_GET_INFO
JIRA: https://issues.redhat.com/browse/RHEL-107520 Conflicts: A context diff due to missing upstream commit 7477d7d ("pidfs: allow to retrieve exit information"). 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 3f88b70 commit 8b6cb4d

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
@@ -267,7 +267,7 @@ static long pidfd_info(struct task_struct *task, unsigned int cmd, unsigned long
267267
kinfo.pid = task_pid_vnr(task);
268268
kinfo.mask |= PIDFD_INFO_PID;
269269

270-
if (kinfo.pid == 0 || kinfo.tgid == 0 || (kinfo.ppid == 0 && kinfo.pid != 1))
270+
if (kinfo.pid == 0 || kinfo.tgid == 0)
271271
return -ESRCH;
272272

273273
/*

0 commit comments

Comments
 (0)