Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Lutomirski and committed by
David S. Miller
c2b1df2e d661684c

+24 -18
+5 -1
include/linux/nsproxy.h
··· 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. ··· 31 27 struct uts_namespace *uts_ns; 32 28 struct ipc_namespace *ipc_ns; 33 29 struct mnt_namespace *mnt_ns; 34 - struct pid_namespace *pid_ns; 30 + struct pid_namespace *pid_ns_for_children; 35 31 struct net *net_ns; 36 32 }; 37 33 extern struct nsproxy init_nsproxy;
+3 -2
kernel/fork.c
··· 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); ··· 1352 1351 1353 1352 if (pid != &init_struct_pid) { 1354 1353 retval = -ENOMEM; 1355 - pid = alloc_pid(p->nsproxy->pid_ns); 1354 + pid = alloc_pid(p->nsproxy->pid_ns_for_children); 1356 1355 if (!pid) 1357 1356 goto bad_fork_cleanup_io; 1358 1357 }
+14 -13
kernel/nsproxy.c
··· 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 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 ··· 101 100 return new_nsp; 102 101 103 102 out_net: 104 - if (new_nsp->pid_ns) 105 - put_pid_ns(new_nsp->pid_ns); 103 + if (new_nsp->pid_ns_for_children) 104 + put_pid_ns(new_nsp->pid_ns_for_children); 106 105 out_pid: 107 106 if (new_nsp->ipc_ns) 108 107 put_ipc_ns(new_nsp->ipc_ns); ··· 175 174 put_uts_ns(ns->uts_ns); 176 175 if (ns->ipc_ns) 177 176 put_ipc_ns(ns->ipc_ns); 178 - if (ns->pid_ns) 179 - put_pid_ns(ns->pid_ns); 177 + if (ns->pid_ns_for_children) 178 + put_pid_ns(ns->pid_ns_for_children); 180 179 put_net(ns->net_ns); 181 180 kmem_cache_free(nsproxy_cachep, ns); 182 181 }
+2 -2
kernel/pid_namespace.c
··· 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