From 0aae409212db2668945afec2da783e60c80e1b21 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Thu, 2 Aug 2018 20:07:14 -0400 Subject: [PATCH] proc.5: Correct description of NStgid The left-most pid namespace in a given procfs' `NStgid` does not change based on the pid namespace of the reading process. Rather, each procfs has an associated outer-most namespace, which gets set when the procfs is mounted: ``` static struct dentry *proc_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { struct pid_namespace *ns; if (flags & MS_KERNMOUNT) { ns = data; data = NULL; } else { ns = task_active_pid_ns(current); } return mount_ns(fs_type, flags, data, ns, ns->user_ns, proc_fill_super); } ``` i.e. either the root namespace for kernel mounts or the namespace of the mounting process. This ns then gets saved in the fs' super block and is the basis for most operations. It is this ns that the left-most value of `NStgid` is relative to, not the reading process. Reported-by: Robert O'Callahan Signed-off-by: Keno Fischer Signed-off-by: Michael Kerrisk --- man5/proc.5 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man5/proc.5 b/man5/proc.5 index c01aed2b1..34cb957dd 100644 --- a/man5/proc.5 +++ b/man5/proc.5 @@ -2356,7 +2356,8 @@ Thread group ID (i.e., PID) in each of the PID namespaces of which .I [pid] is a member. The leftmost entry shows the value with respect to the PID namespace -of the reading process, +of the process that mounted this procfs (or the root namespace +if mounted by the kernel), followed by the value in successively nested inner namespaces. .\" commit e4bc33245124db69b74a6d853ac76c2976f472d5 (Since Linux 4.1.)