Lines Matching refs:ns

22 static struct ucounts *inc_ipc_namespaces(struct user_namespace *ns)  in inc_ipc_namespaces()  argument
24 return inc_ucount(ns, current_euid(), UCOUNT_IPC_NAMESPACES); in inc_ipc_namespaces()
35 struct ipc_namespace *ns; in create_ipc_ns() local
45 ns = kzalloc(sizeof(struct ipc_namespace), GFP_KERNEL_ACCOUNT); in create_ipc_ns()
46 if (ns == NULL) in create_ipc_ns()
49 err = ns_alloc_inum(&ns->ns); in create_ipc_ns()
52 ns->ns.ops = &ipcns_operations; in create_ipc_ns()
54 refcount_set(&ns->ns.count, 1); in create_ipc_ns()
55 ns->user_ns = get_user_ns(user_ns); in create_ipc_ns()
56 ns->ucounts = ucounts; in create_ipc_ns()
58 err = mq_init_ns(ns); in create_ipc_ns()
62 sem_init_ns(ns); in create_ipc_ns()
63 msg_init_ns(ns); in create_ipc_ns()
64 shm_init_ns(ns); in create_ipc_ns()
66 return ns; in create_ipc_ns()
69 put_user_ns(ns->user_ns); in create_ipc_ns()
70 ns_free_inum(&ns->ns); in create_ipc_ns()
72 kfree(ns); in create_ipc_ns()
80 struct user_namespace *user_ns, struct ipc_namespace *ns) in copy_ipcs() argument
83 return get_ipc_ns(ns); in copy_ipcs()
84 return create_ipc_ns(user_ns, ns); in copy_ipcs()
95 void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, in free_ipcs() argument
112 free(ns, perm); in free_ipcs()
118 static void free_ipc_ns(struct ipc_namespace *ns) in free_ipc_ns() argument
123 mq_put_mnt(ns); in free_ipc_ns()
124 sem_exit_ns(ns); in free_ipc_ns()
125 msg_exit_ns(ns); in free_ipc_ns()
126 shm_exit_ns(ns); in free_ipc_ns()
128 dec_ipc_namespaces(ns->ucounts); in free_ipc_ns()
129 put_user_ns(ns->user_ns); in free_ipc_ns()
130 ns_free_inum(&ns->ns); in free_ipc_ns()
131 kfree(ns); in free_ipc_ns()
165 void put_ipc_ns(struct ipc_namespace *ns) in put_ipc_ns() argument
167 if (refcount_dec_and_lock(&ns->ns.count, &mq_lock)) { in put_ipc_ns()
168 mq_clear_sbinfo(ns); in put_ipc_ns()
171 if (llist_add(&ns->mnt_llist, &free_ipc_list)) in put_ipc_ns()
176 static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns) in to_ipc_ns() argument
178 return container_of(ns, struct ipc_namespace, ns); in to_ipc_ns()
183 struct ipc_namespace *ns = NULL; in ipcns_get() local
189 ns = get_ipc_ns(nsproxy->ipc_ns); in ipcns_get()
192 return ns ? &ns->ns : NULL; in ipcns_get()
195 static void ipcns_put(struct ns_common *ns) in ipcns_put() argument
197 return put_ipc_ns(to_ipc_ns(ns)); in ipcns_put()
203 struct ipc_namespace *ns = to_ipc_ns(new); in ipcns_install() local
204 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || in ipcns_install()
209 nsproxy->ipc_ns = get_ipc_ns(ns); in ipcns_install()
213 static struct user_namespace *ipcns_owner(struct ns_common *ns) in ipcns_owner() argument
215 return to_ipc_ns(ns)->user_ns; in ipcns_owner()