Lines Matching full:ns
63 static struct ucounts *inc_pid_namespaces(struct user_namespace *ns) in inc_pid_namespaces() argument
65 return inc_ucount(ns, current_euid(), UCOUNT_PID_NAMESPACES); in inc_pid_namespaces()
78 struct pid_namespace *ns; in create_pid_namespace() local
95 ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL); in create_pid_namespace()
96 if (ns == NULL) in create_pid_namespace()
99 idr_init(&ns->idr); in create_pid_namespace()
101 ns->pid_cachep = create_pid_cachep(level); in create_pid_namespace()
102 if (ns->pid_cachep == NULL) in create_pid_namespace()
105 err = ns_alloc_inum(&ns->ns); in create_pid_namespace()
108 ns->ns.ops = &pidns_operations; in create_pid_namespace()
110 ns->pid_max = PID_MAX_LIMIT; in create_pid_namespace()
111 err = register_pidns_sysctls(ns); in create_pid_namespace()
115 refcount_set(&ns->ns.count, 1); in create_pid_namespace()
116 ns->level = level; in create_pid_namespace()
117 ns->parent = get_pid_ns(parent_pid_ns); in create_pid_namespace()
118 ns->user_ns = get_user_ns(user_ns); in create_pid_namespace()
119 ns->ucounts = ucounts; in create_pid_namespace()
120 ns->pid_allocated = PIDNS_ADDING; in create_pid_namespace()
121 INIT_WORK(&ns->work, destroy_pid_namespace_work); in create_pid_namespace()
124 ns->memfd_noexec_scope = pidns_memfd_noexec_scope(parent_pid_ns); in create_pid_namespace()
127 return ns; in create_pid_namespace()
130 ns_free_inum(&ns->ns); in create_pid_namespace()
132 idr_destroy(&ns->idr); in create_pid_namespace()
133 kmem_cache_free(pid_ns_cachep, ns); in create_pid_namespace()
142 struct pid_namespace *ns = container_of(p, struct pid_namespace, rcu); in delayed_free_pidns() local
144 dec_pid_namespaces(ns->ucounts); in delayed_free_pidns()
145 put_user_ns(ns->user_ns); in delayed_free_pidns()
147 kmem_cache_free(pid_ns_cachep, ns); in delayed_free_pidns()
150 static void destroy_pid_namespace(struct pid_namespace *ns) in destroy_pid_namespace() argument
152 unregister_pidns_sysctls(ns); in destroy_pid_namespace()
154 ns_free_inum(&ns->ns); in destroy_pid_namespace()
156 idr_destroy(&ns->idr); in destroy_pid_namespace()
157 call_rcu(&ns->rcu, delayed_free_pidns); in destroy_pid_namespace()
162 struct pid_namespace *ns = in destroy_pid_namespace_work() local
168 parent = ns->parent; in destroy_pid_namespace_work()
169 destroy_pid_namespace(ns); in destroy_pid_namespace_work()
170 ns = parent; in destroy_pid_namespace_work()
171 } while (ns != &init_pid_ns && refcount_dec_and_test(&ns->ns.count)); in destroy_pid_namespace_work()
184 void put_pid_ns(struct pid_namespace *ns) in put_pid_ns() argument
186 if (ns && ns != &init_pid_ns && refcount_dec_and_test(&ns->ns.count)) in put_pid_ns()
187 schedule_work(&ns->work); in put_pid_ns()
347 static inline struct pid_namespace *to_pid_ns(struct ns_common *ns) in to_pid_ns() argument
349 return container_of(ns, struct pid_namespace, ns); in to_pid_ns()
354 struct pid_namespace *ns; in pidns_get() local
357 ns = task_active_pid_ns(task); in pidns_get()
358 if (ns) in pidns_get()
359 get_pid_ns(ns); in pidns_get()
362 return ns ? &ns->ns : NULL; in pidns_get()
367 struct pid_namespace *ns = NULL; in pidns_for_children_get() local
371 ns = task->nsproxy->pid_ns_for_children; in pidns_for_children_get()
372 get_pid_ns(ns); in pidns_for_children_get()
376 if (ns) { in pidns_for_children_get()
378 if (!ns->child_reaper) { in pidns_for_children_get()
379 put_pid_ns(ns); in pidns_for_children_get()
380 ns = NULL; in pidns_for_children_get()
385 return ns ? &ns->ns : NULL; in pidns_for_children_get()
388 static void pidns_put(struct ns_common *ns) in pidns_put() argument
390 put_pid_ns(to_pid_ns(ns)); in pidns_put()
393 static int pidns_install(struct nsset *nsset, struct ns_common *ns) in pidns_install() argument
397 struct pid_namespace *ancestor, *new = to_pid_ns(ns); in pidns_install()
425 static struct ns_common *pidns_get_parent(struct ns_common *ns) in pidns_get_parent() argument
431 pid_ns = p = to_pid_ns(ns)->parent; in pidns_get_parent()
440 return &get_pid_ns(pid_ns)->ns; in pidns_get_parent()
443 static struct user_namespace *pidns_owner(struct ns_common *ns) in pidns_owner() argument
445 return to_pid_ns(ns)->user_ns; in pidns_owner()