Lines Matching full:ns
62 static struct ucounts *inc_pid_namespaces(struct user_namespace *ns) in inc_pid_namespaces() argument
64 return inc_ucount(ns, current_euid(), UCOUNT_PID_NAMESPACES); in inc_pid_namespaces()
75 struct pid_namespace *ns; in create_pid_namespace() local
92 ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL); in create_pid_namespace()
93 if (ns == NULL) in create_pid_namespace()
96 idr_init(&ns->idr); in create_pid_namespace()
98 ns->pid_cachep = create_pid_cachep(level); in create_pid_namespace()
99 if (ns->pid_cachep == NULL) in create_pid_namespace()
102 err = ns_alloc_inum(&ns->ns); in create_pid_namespace()
105 ns->ns.ops = &pidns_operations; in create_pid_namespace()
107 refcount_set(&ns->ns.count, 1); in create_pid_namespace()
108 ns->level = level; in create_pid_namespace()
109 ns->parent = get_pid_ns(parent_pid_ns); in create_pid_namespace()
110 ns->user_ns = get_user_ns(user_ns); in create_pid_namespace()
111 ns->ucounts = ucounts; in create_pid_namespace()
112 ns->pid_allocated = PIDNS_ADDING; in create_pid_namespace()
114 ns->memfd_noexec_scope = pidns_memfd_noexec_scope(parent_pid_ns); in create_pid_namespace()
116 return ns; in create_pid_namespace()
119 idr_destroy(&ns->idr); in create_pid_namespace()
120 kmem_cache_free(pid_ns_cachep, ns); in create_pid_namespace()
129 struct pid_namespace *ns = container_of(p, struct pid_namespace, rcu); in delayed_free_pidns() local
131 dec_pid_namespaces(ns->ucounts); in delayed_free_pidns()
132 put_user_ns(ns->user_ns); in delayed_free_pidns()
134 kmem_cache_free(pid_ns_cachep, ns); in delayed_free_pidns()
137 static void destroy_pid_namespace(struct pid_namespace *ns) in destroy_pid_namespace() argument
139 ns_free_inum(&ns->ns); in destroy_pid_namespace()
141 idr_destroy(&ns->idr); in destroy_pid_namespace()
142 call_rcu(&ns->rcu, delayed_free_pidns); in destroy_pid_namespace()
155 void put_pid_ns(struct pid_namespace *ns) in put_pid_ns() argument
159 while (ns != &init_pid_ns) { in put_pid_ns()
160 parent = ns->parent; in put_pid_ns()
161 if (!refcount_dec_and_test(&ns->ns.count)) in put_pid_ns()
163 destroy_pid_namespace(ns); in put_pid_ns()
164 ns = parent; in put_pid_ns()
255 * 2) TASK A fork() twice -> TASK B (child reaper for new ns) in zap_pid_ns_processes()
291 * Writing directly to ns' last_pid field is OK, since this field in pid_ns_ctl_handler()
349 static inline struct pid_namespace *to_pid_ns(struct ns_common *ns) in to_pid_ns() argument
351 return container_of(ns, struct pid_namespace, ns); in to_pid_ns()
356 struct pid_namespace *ns; in pidns_get() local
359 ns = task_active_pid_ns(task); in pidns_get()
360 if (ns) in pidns_get()
361 get_pid_ns(ns); in pidns_get()
364 return ns ? &ns->ns : NULL; in pidns_get()
369 struct pid_namespace *ns = NULL; in pidns_for_children_get() local
373 ns = task->nsproxy->pid_ns_for_children; in pidns_for_children_get()
374 get_pid_ns(ns); in pidns_for_children_get()
378 if (ns) { in pidns_for_children_get()
380 if (!ns->child_reaper) { in pidns_for_children_get()
381 put_pid_ns(ns); in pidns_for_children_get()
382 ns = NULL; in pidns_for_children_get()
387 return ns ? &ns->ns : NULL; in pidns_for_children_get()
390 static void pidns_put(struct ns_common *ns) in pidns_put() argument
392 put_pid_ns(to_pid_ns(ns)); in pidns_put()
395 static int pidns_install(struct nsset *nsset, struct ns_common *ns) in pidns_install() argument
399 struct pid_namespace *ancestor, *new = to_pid_ns(ns); in pidns_install()
427 static struct ns_common *pidns_get_parent(struct ns_common *ns) in pidns_get_parent() argument
433 pid_ns = p = to_pid_ns(ns)->parent; in pidns_get_parent()
442 return &get_pid_ns(pid_ns)->ns; in pidns_get_parent()
445 static struct user_namespace *pidns_owner(struct ns_common *ns) in pidns_owner() argument
447 return to_pid_ns(ns)->user_ns; in pidns_owner()