pid_namespace.c (3c0411846118a578de3a979faf2da3ab5fb81179) | pid_namespace.c (64964528b24ea390824f0e5ce9d34b8d39b28cde) |
---|---|
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 * --- 304 unchanged lines hidden (view full) --- 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 | 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 * --- 304 unchanged lines hidden (view full) --- 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 |
321static void *pidns_get(struct task_struct *task) | 321static struct ns_common *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 331 return ns ? &ns->ns : NULL; 332} 333 | 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 331 return ns ? &ns->ns : NULL; 332} 333 |
334static void pidns_put(void *ns) | 334static void pidns_put(struct ns_common *ns) |
335{ 336 put_pid_ns(to_pid_ns(ns)); 337} 338 | 335{ 336 put_pid_ns(to_pid_ns(ns)); 337} 338 |
339static int pidns_install(struct nsproxy *nsproxy, void *ns) | 339static int pidns_install(struct nsproxy *nsproxy, struct ns_common *ns) |
340{ 341 struct pid_namespace *active = task_active_pid_ns(current); 342 struct pid_namespace *ancestor, *new = to_pid_ns(ns); 343 344 if (!ns_capable(new->user_ns, CAP_SYS_ADMIN) || 345 !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) 346 return -EPERM; 347 --- 14 unchanged lines hidden (view full) --- 362 if (ancestor != active) 363 return -EINVAL; 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 | 340{ 341 struct pid_namespace *active = task_active_pid_ns(current); 342 struct pid_namespace *ancestor, *new = to_pid_ns(ns); 343 344 if (!ns_capable(new->user_ns, CAP_SYS_ADMIN) || 345 !ns_capable(current_user_ns(), CAP_SYS_ADMIN)) 346 return -EPERM; 347 --- 14 unchanged lines hidden (view full) --- 362 if (ancestor != active) 363 return -EINVAL; 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{ 372 return ((struct ns_common *)ns)->inum; 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, | 370const struct proc_ns_operations pidns_operations = { 371 .name = "pid", 372 .type = CLONE_NEWPID, 373 .get = pidns_get, 374 .put = pidns_put, 375 .install = pidns_install, |
381 .inum = pidns_inum, | |
382}; 383 384static __init int pid_namespaces_init(void) 385{ 386 pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC); 387 388#ifdef CONFIG_CHECKPOINT_RESTORE 389 register_sysctl_paths(kern_path, pid_ns_ctl_table); 390#endif 391 return 0; 392} 393 394__initcall(pid_namespaces_init); | 376}; 377 378static __init int pid_namespaces_init(void) 379{ 380 pid_ns_cachep = KMEM_CACHE(pid_namespace, SLAB_PANIC); 381 382#ifdef CONFIG_CHECKPOINT_RESTORE 383 register_sysctl_paths(kern_path, pid_ns_ctl_table); 384#endif 385 return 0; 386} 387 388__initcall(pid_namespaces_init); |