pid_namespace.c (94bd217e2d683719ab21a4ac117d8a1b91cbedc9) pid_namespace.c (b8f566b04d3cddd192cfd2418ae6d54ac6353792)
1/*
2 * Pid namespaces
3 *
4 * Authors:
5 * (C) 2007 Pavel Emelyanov <xemul@openvz.org>, OpenVZ, SWsoft Inc.
6 * (C) 2007 Sukadev Bhattiprolu <sukadev@us.ibm.com>, IBM
7 * Many thanks to Oleg Nesterov for comments and help
8 *

--- 177 unchanged lines hidden (view full) ---

186 clear_thread_flag(TIF_SIGPENDING);
187 rc = sys_wait4(-1, NULL, __WALL, NULL);
188 } while (rc != -ECHILD);
189
190 acct_exit_ns(pid_ns);
191 return;
192}
193
1/*
2 * Pid namespaces
3 *
4 * Authors:
5 * (C) 2007 Pavel Emelyanov <xemul@openvz.org>, OpenVZ, SWsoft Inc.
6 * (C) 2007 Sukadev Bhattiprolu <sukadev@us.ibm.com>, IBM
7 * Many thanks to Oleg Nesterov for comments and help
8 *

--- 177 unchanged lines hidden (view full) ---

186 clear_thread_flag(TIF_SIGPENDING);
187 rc = sys_wait4(-1, NULL, __WALL, NULL);
188 } while (rc != -ECHILD);
189
190 acct_exit_ns(pid_ns);
191 return;
192}
193
194static int pid_ns_ctl_handler(struct ctl_table *table, int write,
195 void __user *buffer, size_t *lenp, loff_t *ppos)
196{
197 struct ctl_table tmp = *table;
198
199 if (write && !capable(CAP_SYS_ADMIN))
200 return -EPERM;
201
202 /*
203 * Writing directly to ns' last_pid field is OK, since this field
204 * is volatile in a living namespace anyway and a code writing to
205 * it should synchronize its usage with external means.
206 */
207
208 tmp.data = &current->nsproxy->pid_ns->last_pid;
209 return proc_dointvec(&tmp, write, buffer, lenp, ppos);
210}
211
212static struct ctl_table pid_ns_ctl_table[] = {
213 {
214 .procname = "ns_last_pid",
215 .maxlen = sizeof(int),
216 .mode = 0666, /* permissions are checked in the handler */
217 .proc_handler = pid_ns_ctl_handler,
218 },
219 { }
220};
221
222static struct ctl_path kern_path[] = { { .procname = "kernel", }, { } };
223
194static __init int pid_namespaces_init(void)
195{
196 pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC);
224static __init int pid_namespaces_init(void)
225{
226 pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC);
227 register_sysctl_paths(kern_path, pid_ns_ctl_table);
197 return 0;
198}
199
200__initcall(pid_namespaces_init);
228 return 0;
229}
230
231__initcall(pid_namespaces_init);