Lines Matching full:ns
61 static struct ucounts *inc_pid_namespaces(struct user_namespace *ns) in inc_pid_namespaces() argument
63 return inc_ucount(ns, current_euid(), UCOUNT_PID_NAMESPACES); in inc_pid_namespaces()
74 struct pid_namespace *ns; in create_pid_namespace() local
91 ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL); in create_pid_namespace()
92 if (ns == NULL) in create_pid_namespace()
95 idr_init(&ns->idr); in create_pid_namespace()
97 ns->pid_cachep = create_pid_cachep(level); in create_pid_namespace()
98 if (ns->pid_cachep == NULL) in create_pid_namespace()
101 err = ns_alloc_inum(&ns->ns); in create_pid_namespace()
104 ns->ns.ops = &pidns_operations; in create_pid_namespace()
106 kref_init(&ns->kref); in create_pid_namespace()
107 ns->level = level; in create_pid_namespace()
108 ns->parent = get_pid_ns(parent_pid_ns); in create_pid_namespace()
109 ns->user_ns = get_user_ns(user_ns); in create_pid_namespace()
110 ns->ucounts = ucounts; in create_pid_namespace()
111 ns->pid_allocated = PIDNS_ADDING; in create_pid_namespace()
113 return ns; in create_pid_namespace()
116 idr_destroy(&ns->idr); in create_pid_namespace()
117 kmem_cache_free(pid_ns_cachep, ns); in create_pid_namespace()
126 struct pid_namespace *ns = container_of(p, struct pid_namespace, rcu); in delayed_free_pidns() local
128 dec_pid_namespaces(ns->ucounts); in delayed_free_pidns()
129 put_user_ns(ns->user_ns); in delayed_free_pidns()
131 kmem_cache_free(pid_ns_cachep, ns); in delayed_free_pidns()
134 static void destroy_pid_namespace(struct pid_namespace *ns) in destroy_pid_namespace() argument
136 ns_free_inum(&ns->ns); in destroy_pid_namespace()
138 idr_destroy(&ns->idr); in destroy_pid_namespace()
139 call_rcu(&ns->rcu, delayed_free_pidns); in destroy_pid_namespace()
154 struct pid_namespace *ns; in free_pid_ns() local
156 ns = container_of(kref, struct pid_namespace, kref); in free_pid_ns()
157 destroy_pid_namespace(ns); in free_pid_ns()
160 void put_pid_ns(struct pid_namespace *ns) in put_pid_ns() argument
164 while (ns != &init_pid_ns) { in put_pid_ns()
165 parent = ns->parent; in put_pid_ns()
166 if (!kref_put(&ns->kref, free_pid_ns)) in put_pid_ns()
168 ns = parent; in put_pid_ns()
277 * Writing directly to ns' last_pid field is OK, since this field in pid_ns_ctl_handler()
336 static inline struct pid_namespace *to_pid_ns(struct ns_common *ns) in to_pid_ns() argument
338 return container_of(ns, struct pid_namespace, ns); in to_pid_ns()
343 struct pid_namespace *ns; in pidns_get() local
346 ns = task_active_pid_ns(task); in pidns_get()
347 if (ns) in pidns_get()
348 get_pid_ns(ns); in pidns_get()
351 return ns ? &ns->ns : NULL; in pidns_get()
356 struct pid_namespace *ns = NULL; in pidns_for_children_get() local
360 ns = task->nsproxy->pid_ns_for_children; in pidns_for_children_get()
361 get_pid_ns(ns); in pidns_for_children_get()
365 if (ns) { in pidns_for_children_get()
367 if (!ns->child_reaper) { in pidns_for_children_get()
368 put_pid_ns(ns); in pidns_for_children_get()
369 ns = NULL; in pidns_for_children_get()
374 return ns ? &ns->ns : NULL; in pidns_for_children_get()
377 static void pidns_put(struct ns_common *ns) in pidns_put() argument
379 put_pid_ns(to_pid_ns(ns)); in pidns_put()
382 static int pidns_install(struct nsset *nsset, struct ns_common *ns) in pidns_install() argument
386 struct pid_namespace *ancestor, *new = to_pid_ns(ns); in pidns_install()
414 static struct ns_common *pidns_get_parent(struct ns_common *ns) in pidns_get_parent() argument
420 pid_ns = p = to_pid_ns(ns)->parent; in pidns_get_parent()
429 return &get_pid_ns(pid_ns)->ns; in pidns_get_parent()
432 static struct user_namespace *pidns_owner(struct ns_common *ns) in pidns_owner() argument
434 return to_pid_ns(ns)->user_ns; in pidns_owner()