pid_namespace.c (435d5f4bb2ccba3b791d9ef61d2590e30b8e806e) pid_namespace.c (3c0411846118a578de3a979faf2da3ab5fb81179)
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 *

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

308 read_unlock(&tasklist_lock);
309
310 do_exit(0);
311
312 /* Not reached */
313 return 0;
314}
315
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 *

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

308 read_unlock(&tasklist_lock);
309
310 do_exit(0);
311
312 /* Not reached */
313 return 0;
314}
315
316static inline struct pid_namespace *to_pid_ns(struct ns_common *ns)
317{
318 return container_of(ns, struct pid_namespace, ns);
319}
320
316static void *pidns_get(struct task_struct *task)
317{
318 struct pid_namespace *ns;
319
320 rcu_read_lock();
321 ns = task_active_pid_ns(task);
322 if (ns)
323 get_pid_ns(ns);
324 rcu_read_unlock();
325
321static void *pidns_get(struct task_struct *task)
322{
323 struct pid_namespace *ns;
324
325 rcu_read_lock();
326 ns = task_active_pid_ns(task);
327 if (ns)
328 get_pid_ns(ns);
329 rcu_read_unlock();
330
326 return ns;
331 return ns ? &ns->ns : NULL;
327}
328
329static void pidns_put(void *ns)
330{
332}
333
334static void pidns_put(void *ns)
335{
331 put_pid_ns(ns);
336 put_pid_ns(to_pid_ns(ns));
332}
333
334static int pidns_install(struct nsproxy *nsproxy, void *ns)
335{
336 struct pid_namespace *active = task_active_pid_ns(current);
337}
338
339static int pidns_install(struct nsproxy *nsproxy, void *ns)
340{
341 struct pid_namespace *active = task_active_pid_ns(current);
337 struct pid_namespace *ancestor, *new = ns;
342 struct pid_namespace *ancestor, *new = to_pid_ns(ns);
338
339 if (!ns_capable(new->user_ns, CAP_SYS_ADMIN) ||
340 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
341 return -EPERM;
342
343 /*
344 * Only allow entering the current active pid namespace
345 * or a child of the current active pid namespace.

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

359
360 put_pid_ns(nsproxy->pid_ns_for_children);
361 nsproxy->pid_ns_for_children = get_pid_ns(new);
362 return 0;
363}
364
365static unsigned int pidns_inum(void *ns)
366{
343
344 if (!ns_capable(new->user_ns, CAP_SYS_ADMIN) ||
345 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
346 return -EPERM;
347
348 /*
349 * Only allow entering the current active pid namespace
350 * or a child of the current active pid namespace.

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

364
365 put_pid_ns(nsproxy->pid_ns_for_children);
366 nsproxy->pid_ns_for_children = get_pid_ns(new);
367 return 0;
368}
369
370static unsigned int pidns_inum(void *ns)
371{
367 struct pid_namespace *pid_ns = ns;
368 return pid_ns->ns.inum;
372 return ((struct ns_common *)ns)->inum;
369}
370
371const struct proc_ns_operations pidns_operations = {
372 .name = "pid",
373 .type = CLONE_NEWPID,
374 .get = pidns_get,
375 .put = pidns_put,
376 .install = pidns_install,

--- 14 unchanged lines hidden ---
373}
374
375const struct proc_ns_operations pidns_operations = {
376 .name = "pid",
377 .type = CLONE_NEWPID,
378 .get = pidns_get,
379 .put = pidns_put,
380 .install = pidns_install,

--- 14 unchanged lines hidden ---