Skip to content

Commit b55eb6e

Browse files
YHNdnzjbrauner
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/[email protected] Cc: Christian Brauner <[email protected]> Cc: Luca Boccassi <[email protected]> Cc: [email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 5abc743 commit b55eb6e

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
@@ -366,7 +366,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)
366366
kinfo.pid = task_pid_vnr(task);
367367
kinfo.mask |= PIDFD_INFO_PID;
368368

369-
if (kinfo.pid == 0 || kinfo.tgid == 0 || (kinfo.ppid == 0 && kinfo.pid != 1))
369+
if (kinfo.pid == 0 || kinfo.tgid == 0)
370370
return -ESRCH;
371371

372372
copy_out:

0 commit comments

Comments
 (0)