Lines Matching refs:ns

109 	struct aa_ns *ns;  in alloc_ns()  local
111 ns = kzalloc(sizeof(*ns), GFP_KERNEL); in alloc_ns()
112 AA_DEBUG("%s(%p)\n", __func__, ns); in alloc_ns()
113 if (!ns) in alloc_ns()
115 if (!aa_policy_init(&ns->base, prefix, name, GFP_KERNEL)) in alloc_ns()
118 INIT_LIST_HEAD(&ns->sub_ns); in alloc_ns()
119 INIT_LIST_HEAD(&ns->rawdata_list); in alloc_ns()
120 mutex_init(&ns->lock); in alloc_ns()
121 init_waitqueue_head(&ns->wait); in alloc_ns()
124 ns->unconfined = alloc_unconfined("unconfined"); in alloc_ns()
125 if (!ns->unconfined) in alloc_ns()
128 ns->unconfined->ns = ns; in alloc_ns()
130 atomic_set(&ns->uniq_null, 0); in alloc_ns()
132 aa_labelset_init(&ns->labels); in alloc_ns()
134 return ns; in alloc_ns()
137 kfree_sensitive(ns->base.hname); in alloc_ns()
139 kfree_sensitive(ns); in alloc_ns()
150 void aa_free_ns(struct aa_ns *ns) in aa_free_ns() argument
152 if (!ns) in aa_free_ns()
155 aa_policy_destroy(&ns->base); in aa_free_ns()
156 aa_labelset_destroy(&ns->labels); in aa_free_ns()
157 aa_put_ns(ns->parent); in aa_free_ns()
159 ns->unconfined->ns = NULL; in aa_free_ns()
160 aa_free_profile(ns->unconfined); in aa_free_ns()
161 kfree_sensitive(ns); in aa_free_ns()
177 struct aa_ns *ns = NULL; in aa_findn_ns() local
180 ns = aa_get_ns(__aa_findn_ns(&root->sub_ns, name, n)); in aa_findn_ns()
183 return ns; in aa_findn_ns()
215 struct aa_ns *ns = view; in __aa_lookupn_ns() local
220 ns = __aa_findn_ns(&ns->sub_ns, hname, split - hname); in __aa_lookupn_ns()
221 if (!ns) in __aa_lookupn_ns()
229 return __aa_findn_ns(&ns->sub_ns, hname, n); in __aa_lookupn_ns()
246 struct aa_ns *ns = NULL; in aa_lookupn_ns() local
249 ns = aa_get_ns(__aa_lookupn_ns(view, name, n)); in aa_lookupn_ns()
252 return ns; in aa_lookupn_ns()
258 struct aa_ns *ns; in __aa_create_ns() local
265 ns = alloc_ns(parent->base.hname, name); in __aa_create_ns()
266 if (!ns) in __aa_create_ns()
268 ns->level = parent->level + 1; in __aa_create_ns()
269 mutex_lock_nested(&ns->lock, ns->level); in __aa_create_ns()
270 error = __aafs_ns_mkdir(ns, ns_subns_dir(parent), name, dir); in __aa_create_ns()
273 ns->base.name); in __aa_create_ns()
274 mutex_unlock(&ns->lock); in __aa_create_ns()
275 aa_free_ns(ns); in __aa_create_ns()
278 ns->parent = aa_get_ns(parent); in __aa_create_ns()
279 list_add_rcu(&ns->base.list, &parent->sub_ns); in __aa_create_ns()
281 aa_get_ns(ns); in __aa_create_ns()
282 mutex_unlock(&ns->lock); in __aa_create_ns()
284 return ns; in __aa_create_ns()
298 struct aa_ns *ns; in __aa_find_or_create_ns() local
304 ns = aa_get_ns(__aa_find_ns(&parent->sub_ns, name)); in __aa_find_or_create_ns()
305 if (!ns) in __aa_find_or_create_ns()
306 ns = __aa_create_ns(parent, name, dir); in __aa_find_or_create_ns()
308 ns = ERR_PTR(-EEXIST); in __aa_find_or_create_ns()
311 return ns; in __aa_find_or_create_ns()
323 struct aa_ns *ns; in aa_prepare_ns() local
328 ns = aa_get_ns(__aa_find_ns(&parent->sub_ns, name)); in aa_prepare_ns()
329 if (!ns) in aa_prepare_ns()
330 ns = __aa_create_ns(parent, name, NULL); in aa_prepare_ns()
334 return ns; in aa_prepare_ns()
343 static void destroy_ns(struct aa_ns *ns) in destroy_ns() argument
345 if (!ns) in destroy_ns()
348 mutex_lock_nested(&ns->lock, ns->level); in destroy_ns()
350 __aa_profile_list_release(&ns->base.profiles); in destroy_ns()
353 __ns_list_release(&ns->sub_ns); in destroy_ns()
355 if (ns->parent) { in destroy_ns()
358 write_lock_irqsave(&ns->labels.lock, flags); in destroy_ns()
359 __aa_proxy_redirect(ns_unconfined(ns), in destroy_ns()
360 ns_unconfined(ns->parent)); in destroy_ns()
361 write_unlock_irqrestore(&ns->labels.lock, flags); in destroy_ns()
363 __aafs_ns_rmdir(ns); in destroy_ns()
364 mutex_unlock(&ns->lock); in destroy_ns()
373 void __aa_remove_ns(struct aa_ns *ns) in __aa_remove_ns() argument
376 list_del_rcu(&ns->base.list); in __aa_remove_ns()
377 destroy_ns(ns); in __aa_remove_ns()
378 aa_put_ns(ns); in __aa_remove_ns()
389 struct aa_ns *ns, *tmp; in __ns_list_release() local
391 list_for_each_entry_safe(ns, tmp, head, base.list) in __ns_list_release()
392 __aa_remove_ns(ns); in __ns_list_release()
418 root_ns->unconfined->ns = aa_get_ns(root_ns); in aa_alloc_root_ns()
428 struct aa_ns *ns = root_ns; in aa_free_root_ns() local
433 destroy_ns(ns); in aa_free_root_ns()
434 aa_put_ns(ns); in aa_free_root_ns()