]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pidfs: never refuse ppid == 0 in PIDFD_GET_INFO
authorMike Yuan <me@yhndnzj.com>
Wed, 4 Jun 2025 15:03:42 +0000 (15:03 +0000)
committerChristian Brauner <brauner@kernel.org>
Wed, 4 Jun 2025 20:48:32 +0000 (22:48 +0200)
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] https://github.com/systemd/systemd/issues/37715

Fixes: cdda1f26e74b ("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>
fs/pidfs.c

index c1f0a067be40ce4eaab7ca1e739ad34519c4b45d..69919be1c9d8918b60670c937cee5255dd6a57f8 100644 (file)
@@ -366,7 +366,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)
        kinfo.pid = task_pid_vnr(task);
        kinfo.mask |= PIDFD_INFO_PID;
 
-       if (kinfo.pid == 0 || kinfo.tgid == 0 || (kinfo.ppid == 0 && kinfo.pid != 1))
+       if (kinfo.pid == 0 || kinfo.tgid == 0)
                return -ESRCH;
 
 copy_out: