Lines Matching refs:ns
64 struct pid_namespace *ns = container_of(work, struct pid_namespace, proc_work); in proc_cleanup_work() local
65 pid_ns_release_proc(ns); in proc_cleanup_work()
68 static struct ucounts *inc_pid_namespaces(struct user_namespace *ns) in inc_pid_namespaces() argument
70 return inc_ucount(ns, current_euid(), UCOUNT_PID_NAMESPACES); in inc_pid_namespaces()
81 struct pid_namespace *ns; in create_pid_namespace() local
98 ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL); in create_pid_namespace()
99 if (ns == NULL) in create_pid_namespace()
102 idr_init(&ns->idr); in create_pid_namespace()
104 ns->pid_cachep = create_pid_cachep(level); in create_pid_namespace()
105 if (ns->pid_cachep == NULL) in create_pid_namespace()
108 err = ns_alloc_inum(&ns->ns); in create_pid_namespace()
111 ns->ns.ops = &pidns_operations; in create_pid_namespace()
113 kref_init(&ns->kref); in create_pid_namespace()
114 ns->level = level; in create_pid_namespace()
115 ns->parent = get_pid_ns(parent_pid_ns); in create_pid_namespace()
116 ns->user_ns = get_user_ns(user_ns); in create_pid_namespace()
117 ns->ucounts = ucounts; in create_pid_namespace()
118 ns->pid_allocated = PIDNS_ADDING; in create_pid_namespace()
119 INIT_WORK(&ns->proc_work, proc_cleanup_work); in create_pid_namespace()
121 return ns; in create_pid_namespace()
124 idr_destroy(&ns->idr); in create_pid_namespace()
125 kmem_cache_free(pid_ns_cachep, ns); in create_pid_namespace()
134 struct pid_namespace *ns = container_of(p, struct pid_namespace, rcu); in delayed_free_pidns() local
136 dec_pid_namespaces(ns->ucounts); in delayed_free_pidns()
137 put_user_ns(ns->user_ns); in delayed_free_pidns()
139 kmem_cache_free(pid_ns_cachep, ns); in delayed_free_pidns()
142 static void destroy_pid_namespace(struct pid_namespace *ns) in destroy_pid_namespace() argument
144 ns_free_inum(&ns->ns); in destroy_pid_namespace()
146 idr_destroy(&ns->idr); in destroy_pid_namespace()
147 call_rcu(&ns->rcu, delayed_free_pidns); in destroy_pid_namespace()
162 struct pid_namespace *ns; in free_pid_ns() local
164 ns = container_of(kref, struct pid_namespace, kref); in free_pid_ns()
165 destroy_pid_namespace(ns); in free_pid_ns()
168 void put_pid_ns(struct pid_namespace *ns) in put_pid_ns() argument
172 while (ns != &init_pid_ns) { in put_pid_ns()
173 parent = ns->parent; in put_pid_ns()
174 if (!kref_put(&ns->kref, free_pid_ns)) in put_pid_ns()
176 ns = parent; in put_pid_ns()
337 static inline struct pid_namespace *to_pid_ns(struct ns_common *ns) in to_pid_ns() argument
339 return container_of(ns, struct pid_namespace, ns); in to_pid_ns()
344 struct pid_namespace *ns; in pidns_get() local
347 ns = task_active_pid_ns(task); in pidns_get()
348 if (ns) in pidns_get()
349 get_pid_ns(ns); in pidns_get()
352 return ns ? &ns->ns : NULL; in pidns_get()
357 struct pid_namespace *ns = NULL; in pidns_for_children_get() local
361 ns = task->nsproxy->pid_ns_for_children; in pidns_for_children_get()
362 get_pid_ns(ns); in pidns_for_children_get()
366 if (ns) { in pidns_for_children_get()
368 if (!ns->child_reaper) { in pidns_for_children_get()
369 put_pid_ns(ns); in pidns_for_children_get()
370 ns = NULL; in pidns_for_children_get()
375 return ns ? &ns->ns : NULL; in pidns_for_children_get()
378 static void pidns_put(struct ns_common *ns) in pidns_put() argument
380 put_pid_ns(to_pid_ns(ns)); in pidns_put()
383 static int pidns_install(struct nsproxy *nsproxy, 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()