Commit c2b1df2eb42978073ec27c99cc199d20ae48b849

Authored by Andy Lutomirski
Committed by David S. Miller
1 parent d661684cf6

Rename nsproxy.pid_ns to nsproxy.pid_ns_for_children

nsproxy.pid_ns is *not* the task's pid namespace.  The name should clarify
that.

This makes it more obvious that setns on a pid namespace is weird --
it won't change the pid namespace shown in procfs.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 4 changed files with 24 additions and 18 deletions Side-by-side Diff

include/linux/nsproxy.h
... ... @@ -14,6 +14,10 @@
14 14 * A structure to contain pointers to all per-process
15 15 * namespaces - fs (mount), uts, network, sysvipc, etc.
16 16 *
  17 + * The pid namespace is an exception -- it's accessed using
  18 + * task_active_pid_ns. The pid namespace here is the
  19 + * namespace that children will use.
  20 + *
17 21 * 'count' is the number of tasks holding a reference.
18 22 * The count for each namespace, then, will be the number
19 23 * of nsproxies pointing to it, not the number of tasks.
... ... @@ -27,7 +31,7 @@
27 31 struct uts_namespace *uts_ns;
28 32 struct ipc_namespace *ipc_ns;
29 33 struct mnt_namespace *mnt_ns;
30   - struct pid_namespace *pid_ns;
  34 + struct pid_namespace *pid_ns_for_children;
31 35 struct net *net_ns;
32 36 };
33 37 extern struct nsproxy init_nsproxy;
... ... @@ -1177,7 +1177,8 @@
1177 1177 * don't allow the creation of threads.
1178 1178 */
1179 1179 if ((clone_flags & (CLONE_VM|CLONE_NEWPID)) &&
1180   - (task_active_pid_ns(current) != current->nsproxy->pid_ns))
  1180 + (task_active_pid_ns(current) !=
  1181 + current->nsproxy->pid_ns_for_children))
1181 1182 return ERR_PTR(-EINVAL);
1182 1183  
1183 1184 retval = security_task_create(clone_flags);
... ... @@ -1351,7 +1352,7 @@
1351 1352  
1352 1353 if (pid != &init_struct_pid) {
1353 1354 retval = -ENOMEM;
1354   - pid = alloc_pid(p->nsproxy->pid_ns);
  1355 + pid = alloc_pid(p->nsproxy->pid_ns_for_children);
1355 1356 if (!pid)
1356 1357 goto bad_fork_cleanup_io;
1357 1358 }
... ... @@ -29,15 +29,15 @@
29 29 static struct kmem_cache *nsproxy_cachep;
30 30  
31 31 struct nsproxy init_nsproxy = {
32   - .count = ATOMIC_INIT(1),
33   - .uts_ns = &init_uts_ns,
  32 + .count = ATOMIC_INIT(1),
  33 + .uts_ns = &init_uts_ns,
34 34 #if defined(CONFIG_POSIX_MQUEUE) || defined(CONFIG_SYSVIPC)
35   - .ipc_ns = &init_ipc_ns,
  35 + .ipc_ns = &init_ipc_ns,
36 36 #endif
37   - .mnt_ns = NULL,
38   - .pid_ns = &init_pid_ns,
  37 + .mnt_ns = NULL,
  38 + .pid_ns_for_children = &init_pid_ns,
39 39 #ifdef CONFIG_NET
40   - .net_ns = &init_net,
  40 + .net_ns = &init_net,
41 41 #endif
42 42 };
43 43  
... ... @@ -85,9 +85,10 @@
85 85 goto out_ipc;
86 86 }
87 87  
88   - new_nsp->pid_ns = copy_pid_ns(flags, user_ns, tsk->nsproxy->pid_ns);
89   - if (IS_ERR(new_nsp->pid_ns)) {
90   - err = PTR_ERR(new_nsp->pid_ns);
  88 + new_nsp->pid_ns_for_children =
  89 + copy_pid_ns(flags, user_ns, tsk->nsproxy->pid_ns_for_children);
  90 + if (IS_ERR(new_nsp->pid_ns_for_children)) {
  91 + err = PTR_ERR(new_nsp->pid_ns_for_children);
91 92 goto out_pid;
92 93 }
93 94  
... ... @@ -100,8 +101,8 @@
100 101 return new_nsp;
101 102  
102 103 out_net:
103   - if (new_nsp->pid_ns)
104   - put_pid_ns(new_nsp->pid_ns);
  104 + if (new_nsp->pid_ns_for_children)
  105 + put_pid_ns(new_nsp->pid_ns_for_children);
105 106 out_pid:
106 107 if (new_nsp->ipc_ns)
107 108 put_ipc_ns(new_nsp->ipc_ns);
... ... @@ -174,8 +175,8 @@
174 175 put_uts_ns(ns->uts_ns);
175 176 if (ns->ipc_ns)
176 177 put_ipc_ns(ns->ipc_ns);
177   - if (ns->pid_ns)
178   - put_pid_ns(ns->pid_ns);
  178 + if (ns->pid_ns_for_children)
  179 + put_pid_ns(ns->pid_ns_for_children);
179 180 put_net(ns->net_ns);
180 181 kmem_cache_free(nsproxy_cachep, ns);
181 182 }
kernel/pid_namespace.c
... ... @@ -349,8 +349,8 @@
349 349 if (ancestor != active)
350 350 return -EINVAL;
351 351  
352   - put_pid_ns(nsproxy->pid_ns);
353   - nsproxy->pid_ns = get_pid_ns(new);
  352 + put_pid_ns(nsproxy->pid_ns_for_children);
  353 + nsproxy->pid_ns_for_children = get_pid_ns(new);
354 354 return 0;
355 355 }
356 356