Lines Matching refs:ns

28 static struct ucounts *inc_ipc_namespaces(struct user_namespace *ns)  in inc_ipc_namespaces()  argument
30 return inc_ucount(ns, current_euid(), UCOUNT_IPC_NAMESPACES); in inc_ipc_namespaces()
41 struct ipc_namespace *ns; in create_ipc_ns() local
60 ns = kzalloc(sizeof(struct ipc_namespace), GFP_KERNEL_ACCOUNT); in create_ipc_ns()
61 if (ns == NULL) in create_ipc_ns()
64 err = ns_alloc_inum(&ns->ns); in create_ipc_ns()
67 ns->ns.ops = &ipcns_operations; in create_ipc_ns()
69 refcount_set(&ns->ns.count, 1); in create_ipc_ns()
70 ns->user_ns = get_user_ns(user_ns); in create_ipc_ns()
71 ns->ucounts = ucounts; in create_ipc_ns()
73 err = mq_init_ns(ns); in create_ipc_ns()
78 if (!setup_mq_sysctls(ns)) in create_ipc_ns()
81 if (!setup_ipc_sysctls(ns)) in create_ipc_ns()
84 err = msg_init_ns(ns); in create_ipc_ns()
88 sem_init_ns(ns); in create_ipc_ns()
89 shm_init_ns(ns); in create_ipc_ns()
91 return ns; in create_ipc_ns()
94 retire_mq_sysctls(ns); in create_ipc_ns()
97 put_user_ns(ns->user_ns); in create_ipc_ns()
98 ns_free_inum(&ns->ns); in create_ipc_ns()
100 kfree(ns); in create_ipc_ns()
108 struct user_namespace *user_ns, struct ipc_namespace *ns) in copy_ipcs() argument
111 return get_ipc_ns(ns); in copy_ipcs()
112 return create_ipc_ns(user_ns, ns); in copy_ipcs()
123 void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids, in free_ipcs() argument
140 free(ns, perm); in free_ipcs()
146 static void free_ipc_ns(struct ipc_namespace *ns) in free_ipc_ns() argument
152 mntput(ns->mq_mnt); in free_ipc_ns()
153 sem_exit_ns(ns); in free_ipc_ns()
154 msg_exit_ns(ns); in free_ipc_ns()
155 shm_exit_ns(ns); in free_ipc_ns()
157 retire_mq_sysctls(ns); in free_ipc_ns()
158 retire_ipc_sysctls(ns); in free_ipc_ns()
160 dec_ipc_namespaces(ns->ucounts); in free_ipc_ns()
161 put_user_ns(ns->user_ns); in free_ipc_ns()
162 ns_free_inum(&ns->ns); in free_ipc_ns()
163 kfree(ns); in free_ipc_ns()
198 void put_ipc_ns(struct ipc_namespace *ns) in put_ipc_ns() argument
200 if (refcount_dec_and_lock(&ns->ns.count, &mq_lock)) { in put_ipc_ns()
201 mq_clear_sbinfo(ns); in put_ipc_ns()
204 if (llist_add(&ns->mnt_llist, &free_ipc_list)) in put_ipc_ns()
209 static inline struct ipc_namespace *to_ipc_ns(struct ns_common *ns) in to_ipc_ns() argument
211 return container_of(ns, struct ipc_namespace, ns); in to_ipc_ns()
216 struct ipc_namespace *ns = NULL; in ipcns_get() local
222 ns = get_ipc_ns(nsproxy->ipc_ns); in ipcns_get()
225 return ns ? &ns->ns : NULL; in ipcns_get()
228 static void ipcns_put(struct ns_common *ns) in ipcns_put() argument
230 return put_ipc_ns(to_ipc_ns(ns)); in ipcns_put()
236 struct ipc_namespace *ns = to_ipc_ns(new); in ipcns_install() local
237 if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN) || in ipcns_install()
242 nsproxy->ipc_ns = get_ipc_ns(ns); in ipcns_install()
246 static struct user_namespace *ipcns_owner(struct ns_common *ns) in ipcns_owner() argument
248 return to_ipc_ns(ns)->user_ns; in ipcns_owner()