public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pidfs: return -EREMOTE when PIDFD_GET_INFO is called on another ns
@ 2026-01-27 22:51 luca.boccassi
  2026-02-06  2:51 ` kernel test robot
  2026-02-12 17:01 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: luca.boccassi @ 2026-01-27 22:51 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: christian

From: Luca Boccassi <luca.boccassi@gmail.com>

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: 7477d7dce48a ("pidfs: allow to retrieve exit information")

Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
---
More context: https://sourceware.org/pipermail/libc-alpha/2026-January/174506.html

 fs/pidfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/pidfs.c b/fs/pidfs.c
index 1e20e36e0ed5..d18c51513f6c 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -329,7 +329,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)
 	 * namespace hierarchy.
 	 */
 	if (!pid_in_current_pidns(pid))
-		return -ESRCH;
+		return -EREMOTE;
 
 	attr = READ_ONCE(pid->attr);
 	if (mask & PIDFD_INFO_EXIT) {
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-14 12:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 22:51 [PATCH] pidfs: return -EREMOTE when PIDFD_GET_INFO is called on another ns luca.boccassi
2026-02-06  2:51 ` kernel test robot
2026-02-06 12:24   ` Christian Brauner
2026-02-12 17:01 ` Mark Brown
2026-02-14 12:27   ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox