Skip to content

Commit ab89060

Browse files
blucabrauner
authored andcommitted
pidfs: return -EREMOTE when PIDFD_GET_INFO is called on another ns
Currently it is not possible to distinguish between the case where a process has already exited and the case where a process is in a different namespace, as both return -ESRCH. glibc's pidfd_getpid() procfs-based implementation returns -EREMOTE in the latter, so that distinguishing the two is possible, as the fdinfo in procfs will list '0' as the PID in that case: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/pidfd_getpid.c;h=860829cf07da2267484299ccb02861822c0d07b4;hb=HEAD#l121 Change the error code so that the kernel also returns -EREMOTE in that case. Fixes: 7477d7d ("pidfs: allow to retrieve exit information") Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com> Link: https://patch.msgid.link/20260127225209.2293342-1-luca.boccassi@gmail.com Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent b3c78bc commit ab89060

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/pidfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)
329329
* namespace hierarchy.
330330
*/
331331
if (!pid_in_current_pidns(pid))
332-
return -ESRCH;
332+
return -EREMOTE;
333333

334334
attr = READ_ONCE(pid->attr);
335335
if (mask & PIDFD_INFO_EXIT) {

0 commit comments

Comments
 (0)