All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pidfd: show pids for nested pid namespaces in fdinfo
@ 2019-10-08 13:36 Christian Kellner
  2019-10-08 13:52 ` Christian Brauner
  2019-10-09 16:05 ` [PATCH v2 1/2] " Christian Kellner
  0 siblings, 2 replies; 36+ messages in thread
From: Christian Kellner @ 2019-10-08 13:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: Christian Kellner, Christian Brauner, Andrew Morton,
	Peter Zijlstra (Intel),
	Ingo Molnar, Michal Hocko, Elena Reshetova, Thomas Gleixner,
	Roman Gushchin, Andrea Arcangeli, Joel Fernandes (Google),
	Al Viro, Dmitry V. Levin

From: Christian Kellner <christian@kellner.me>

The fdinfo file for a process file descriptor already contains the
pid of the process in the callers namespaces. Additionally, if pid
namespaces are configured, show the process ids of the process in
all nested namespaces in the same format as in the procfs status
file, i.e. "NSPid:\t%d\%d...". This allows the easy identification
of the processes in nested namespaces.

Signed-off-by: Christian Kellner <christian@kellner.me>
---
 kernel/fork.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/kernel/fork.c b/kernel/fork.c
index 5a0fd518e04e..801793789f33 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1685,8 +1685,18 @@ static void pidfd_show_fdinfo(struct seq_file *m, struct file *f)
 {
 	struct pid_namespace *ns = proc_pid_ns(file_inode(m->file));
 	struct pid *pid = f->private_data;
+#ifdef CONFIG_PID_NS
+	int i;
+#endif
 
 	seq_put_decimal_ull(m, "Pid:\t", pid_nr_ns(pid, ns));
+#ifdef CONFIG_PID_NS
+	seq_puts(m, "\nNSpid:");
+	for (i = ns->level; i <= pid->level; i++) {
+		ns = pid_nr_ns(pid, pid->numbers[i].ns);
+		seq_put_decimal_ull(m, "\t", ns);
+	}
+#endif
 	seq_putc(m, '\n');
 }
 #endif
-- 
2.21.0


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

end of thread, other threads:[~2019-11-13 12:20 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-08 13:36 [PATCH] pidfd: show pids for nested pid namespaces in fdinfo Christian Kellner
2019-10-08 13:52 ` Christian Brauner
2019-10-08 14:00   ` Michal Hocko
2019-10-09 16:05 ` [PATCH v2 1/2] " Christian Kellner
2019-10-09 16:05   ` [PATCH v2 2/2] pidfd: add tests for NSpid info " Christian Kellner
2019-10-11 15:09     ` Jann Horn
2019-10-11 15:09       ` Jann Horn
2019-10-11 17:08       ` Christian Brauner
2019-10-11 17:08         ` Christian Brauner
2019-10-09 17:29   ` [PATCH v2 1/2] pidfd: show pids for nested pid namespaces " Christian Brauner
2019-10-11 12:23   ` [PATCH v3 " Christian Kellner
2019-10-11 12:23     ` [PATCH v3 2/2] pidfd: add tests for NSpid info " Christian Kellner
2019-10-11 13:18       ` Christian Brauner
2019-10-11 13:18         ` Christian Brauner
2019-10-11 13:17     ` [PATCH v3 1/2] pidfd: show pids for nested pid namespaces " Christian Brauner
2019-10-11 14:55     ` Jann Horn
2019-10-11 15:17       ` Christian Brauner
2019-10-11 15:30         ` Jann Horn
2019-10-11 16:58           ` Christian Brauner
2019-10-11 18:20             ` Jann Horn
2019-10-12 10:19               ` [PATCH] pidfd: add NSpid entries to fdinfo Christian Brauner
2019-10-12 10:21                 ` Christian Brauner
2019-10-14  9:43                   ` Christian Kellner
2019-10-14 10:31                     ` Christian Brauner
2019-10-14 15:10                       ` Jann Horn
2019-10-14 15:20                         ` Christian Kellner
2019-10-14 15:09                 ` Jann Horn
2019-10-14 17:06                   ` Christian Brauner
2019-10-14 16:20     ` [PATCH v4 1/2] " Christian Kellner
2019-10-14 16:20       ` [PATCH v4 2/2] pidfd: add tests for NSpid info in fdinfo Christian Kellner
2019-10-15 10:07         ` Christian Brauner
2019-11-13 11:52           ` Naresh Kamboju
2019-11-13 11:52             ` Naresh Kamboju
2019-11-13 12:20             ` Christian Brauner
2019-11-13 12:20               ` Christian Brauner
2019-10-15  9:40       ` [PATCH v4 1/2] pidfd: add NSpid entries to fdinfo Christian Brauner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.