Lines Matching +full:5 +full:ns

77 	struct ipc_namespace	*ns;  member
86 struct ipc_namespace *ns; member
96 #define shm_ids(ns) ((ns)->ids[IPC_SHM_IDS]) argument
104 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp);
109 void shm_init_ns(struct ipc_namespace *ns) in shm_init_ns() argument
111 ns->shm_ctlmax = SHMMAX; in shm_init_ns()
112 ns->shm_ctlall = SHMALL; in shm_init_ns()
113 ns->shm_ctlmni = SHMMNI; in shm_init_ns()
114 ns->shm_rmid_forced = 0; in shm_init_ns()
115 ns->shm_tot = 0; in shm_init_ns()
116 ipc_init_ids(&shm_ids(ns)); in shm_init_ns()
123 static void do_shm_rmid(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) in do_shm_rmid() argument
128 WARN_ON(ns != shp->ns); in do_shm_rmid()
133 ipc_set_key_private(&shm_ids(ns), &shp->shm_perm); in do_shm_rmid()
136 shm_destroy(ns, shp); in do_shm_rmid()
140 void shm_exit_ns(struct ipc_namespace *ns) in shm_exit_ns() argument
142 free_ipcs(ns, &shm_ids(ns), do_shm_rmid); in shm_exit_ns()
143 idr_destroy(&ns->ids[IPC_SHM_IDS].ipcs_idr); in shm_exit_ns()
144 rhashtable_destroy(&ns->ids[IPC_SHM_IDS].key_ht); in shm_exit_ns()
167 static inline struct shmid_kernel *shm_obtain_object(struct ipc_namespace *ns, int id) in shm_obtain_object() argument
169 struct kern_ipc_perm *ipcp = ipc_obtain_object_idr(&shm_ids(ns), id); in shm_obtain_object()
177 static inline struct shmid_kernel *shm_obtain_object_check(struct ipc_namespace *ns, int id) in shm_obtain_object_check() argument
179 struct kern_ipc_perm *ipcp = ipc_obtain_object_check(&shm_ids(ns), id); in shm_obtain_object_check()
191 static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id) in shm_lock() argument
196 ipcp = ipc_obtain_object_idr(&shm_ids(ns), id); in shm_lock()
275 ipc_rmid(&shm_ids(s->ns), &s->shm_perm); in shm_rmid()
283 shp = shm_lock(sfd->ns, sfd->id); in __shm_open()
323 * @ns: namespace
329 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp) in shm_destroy() argument
335 ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT; in shm_destroy()
359 (shp->ns->shm_rmid_forced || in shm_may_destroy()
372 struct ipc_namespace *ns = sfd->ns; in __shm_close() local
374 down_write(&shm_ids(ns).rwsem); in __shm_close()
376 shp = shm_lock(ns, sfd->id); in __shm_close()
389 shm_destroy(ns, shp); in __shm_close()
393 up_write(&shm_ids(ns).rwsem); in __shm_close()
408 /* Called with ns->shm_ids(ns).rwsem locked */
411 struct ipc_namespace *ns = data; in shm_try_destroy_orphaned() local
426 shm_destroy(ns, shp); in shm_try_destroy_orphaned()
431 void shm_destroy_orphaned(struct ipc_namespace *ns) in shm_destroy_orphaned() argument
433 down_write(&shm_ids(ns).rwsem); in shm_destroy_orphaned()
434 if (shm_ids(ns).in_use) in shm_destroy_orphaned()
435 idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_orphaned, ns); in shm_destroy_orphaned()
436 up_write(&shm_ids(ns).rwsem); in shm_destroy_orphaned()
444 struct ipc_namespace *ns; in exit_shm() local
463 ns = shp->ns; in exit_shm()
470 if (!ns->shm_rmid_forced) in exit_shm()
478 ns = get_ipc_ns_not_zero(ns); in exit_shm()
479 if (!ns) { in exit_shm()
494 * 5) unlink the shm segment from the list of segments in exit_shm()
508 down_write(&shm_ids(ns).rwsem); in exit_shm()
518 shm_destroy(ns, shp); in exit_shm()
530 up_write(&shm_ids(ns).rwsem); in exit_shm()
531 put_ipc_ns(ns); /* paired with get_ipc_ns_not_zero */ in exit_shm()
619 put_ipc_ns(sfd->ns); in shm_release()
692 * @ns: namespace
697 static int newseg(struct ipc_namespace *ns, struct ipc_params *params) in newseg() argument
709 if (size < SHMMIN || size > ns->shm_ctlmax) in newseg()
715 if (ns->shm_tot + numpages < ns->shm_tot || in newseg()
716 ns->shm_tot + numpages > ns->shm_ctlall) in newseg()
775 error = ipc_addid(&shm_ids(ns), &shp->shm_perm, ns->shm_ctlmni); in newseg()
779 shp->ns = ns; in newseg()
791 ns->shm_tot += numpages; in newseg()
825 struct ipc_namespace *ns; in ksys_shmget() local
833 ns = current->nsproxy->ipc_ns; in ksys_shmget()
839 return ipcget(ns, &shm_ids(ns), &shm_ops, &shm_params); in ksys_shmget()
957 static void shm_get_stat(struct ipc_namespace *ns, unsigned long *rss, in shm_get_stat() argument
966 in_use = shm_ids(ns).in_use; in shm_get_stat()
972 ipc = idr_find(&shm_ids(ns).ipcs_idr, next_id); in shm_get_stat()
988 static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd, in shmctl_down() argument
995 down_write(&shm_ids(ns).rwsem); in shmctl_down()
998 ipcp = ipcctl_obtain_check(ns, &shm_ids(ns), shmid, cmd, in shmctl_down()
1015 do_shm_rmid(ns, ipcp); in shmctl_down()
1034 up_write(&shm_ids(ns).rwsem); in shmctl_down()
1038 static int shmctl_ipc_info(struct ipc_namespace *ns, in shmctl_ipc_info() argument
1044 shminfo->shmmni = shminfo->shmseg = ns->shm_ctlmni; in shmctl_ipc_info()
1045 shminfo->shmmax = ns->shm_ctlmax; in shmctl_ipc_info()
1046 shminfo->shmall = ns->shm_ctlall; in shmctl_ipc_info()
1048 down_read(&shm_ids(ns).rwsem); in shmctl_ipc_info()
1049 err = ipc_get_maxidx(&shm_ids(ns)); in shmctl_ipc_info()
1050 up_read(&shm_ids(ns).rwsem); in shmctl_ipc_info()
1057 static int shmctl_shm_info(struct ipc_namespace *ns, in shmctl_shm_info() argument
1063 down_read(&shm_ids(ns).rwsem); in shmctl_shm_info()
1064 shm_info->used_ids = shm_ids(ns).in_use; in shmctl_shm_info()
1065 shm_get_stat(ns, &shm_info->shm_rss, &shm_info->shm_swp); in shmctl_shm_info()
1066 shm_info->shm_tot = ns->shm_tot; in shmctl_shm_info()
1069 err = ipc_get_maxidx(&shm_ids(ns)); in shmctl_shm_info()
1070 up_read(&shm_ids(ns).rwsem); in shmctl_shm_info()
1077 static int shmctl_stat(struct ipc_namespace *ns, int shmid, in shmctl_stat() argument
1087 shp = shm_obtain_object(ns, shmid); in shmctl_stat()
1093 shp = shm_obtain_object_check(ns, shmid); in shmctl_stat()
1111 if (ipcperms(ns, &shp->shm_perm, S_IRUGO)) in shmctl_stat()
1161 static int shmctl_do_lock(struct ipc_namespace *ns, int shmid, int cmd) in shmctl_do_lock() argument
1168 shp = shm_obtain_object_check(ns, shmid); in shmctl_do_lock()
1187 if (!ns_capable(ns->user_ns, CAP_IPC_LOCK)) { in shmctl_do_lock()
1240 struct ipc_namespace *ns; in ksys_shmctl() local
1246 ns = current->nsproxy->ipc_ns; in ksys_shmctl()
1251 err = shmctl_ipc_info(ns, &shminfo); in ksys_shmctl()
1260 err = shmctl_shm_info(ns, &shm_info); in ksys_shmctl()
1270 err = shmctl_stat(ns, shmid, cmd, &sem64); in ksys_shmctl()
1282 return shmctl_down(ns, shmid, cmd, &sem64); in ksys_shmctl()
1285 return shmctl_do_lock(ns, shmid, cmd); in ksys_shmctl()
1434 struct ipc_namespace *ns; in compat_ksys_shmctl() local
1438 ns = current->nsproxy->ipc_ns; in compat_ksys_shmctl()
1446 err = shmctl_ipc_info(ns, &shminfo); in compat_ksys_shmctl()
1455 err = shmctl_shm_info(ns, &shm_info); in compat_ksys_shmctl()
1465 err = shmctl_stat(ns, shmid, cmd, &sem64); in compat_ksys_shmctl()
1477 return shmctl_down(ns, shmid, cmd, &sem64); in compat_ksys_shmctl()
1480 return shmctl_do_lock(ns, shmid, cmd); in compat_ksys_shmctl()
1525 struct ipc_namespace *ns; in do_shmat() local
1575 ns = current->nsproxy->ipc_ns; in do_shmat()
1577 shp = shm_obtain_object_check(ns, shmid); in do_shmat()
1584 if (ipcperms(ns, &shp->shm_perm, acc_mode)) in do_shmat()
1634 sfd->ns = get_ipc_ns(ns); in do_shmat()
1671 down_write(&shm_ids(ns).rwsem); in do_shmat()
1672 shp = shm_lock(ns, shmid); in do_shmat()
1676 shm_destroy(ns, shp); in do_shmat()
1679 up_write(&shm_ids(ns).rwsem); in do_shmat()
1853 "%10d %10d %4o " SIZE_SPEC " %5u %5u " in sysvipc_shm_proc_show()
1854 "%5lu %5u %5u %5u %5u %10llu %10llu %10llu " in sysvipc_shm_proc_show()