aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index fe92471e19c7..c47e87278a92 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -83,8 +83,11 @@ void shm_init_ns(struct ipc_namespace *ns)
83 * Called with shm_ids.rw_mutex (writer) and the shp structure locked. 83 * Called with shm_ids.rw_mutex (writer) and the shp structure locked.
84 * Only shm_ids.rw_mutex remains locked on exit. 84 * Only shm_ids.rw_mutex remains locked on exit.
85 */ 85 */
86static void do_shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *shp) 86static void do_shm_rmid(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp)
87{ 87{
88 struct shmid_kernel *shp;
89 shp = container_of(ipcp, struct shmid_kernel, shm_perm);
90
88 if (shp->shm_nattch){ 91 if (shp->shm_nattch){
89 shp->shm_perm.mode |= SHM_DEST; 92 shp->shm_perm.mode |= SHM_DEST;
90 /* Do not find it any more */ 93 /* Do not find it any more */
@@ -97,25 +100,7 @@ static void do_shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *shp)
97#ifdef CONFIG_IPC_NS 100#ifdef CONFIG_IPC_NS
98void shm_exit_ns(struct ipc_namespace *ns) 101void shm_exit_ns(struct ipc_namespace *ns)
99{ 102{
100 struct shmid_kernel *shp; 103 free_ipcs(ns, &shm_ids(ns), do_shm_rmid);
101 struct kern_ipc_perm *perm;
102 int next_id;
103 int total, in_use;
104
105 down_write(&shm_ids(ns).rw_mutex);
106
107 in_use = shm_ids(ns).in_use;
108
109 for (total = 0, next_id = 0; total < in_use; next_id++) {
110 perm = idr_find(&shm_ids(ns).ipcs_idr, next_id);
111 if (perm == NULL)
112 continue;
113 ipc_lock_by_ptr(perm);
114 shp = container_of(perm, struct shmid_kernel, shm_perm);
115 do_shm_rmid(ns, shp);
116 total++;
117 }
118 up_write(&shm_ids(ns).rw_mutex);
119} 104}
120#endif 105#endif
121 106
@@ -832,7 +817,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
832 if (err) 817 if (err)
833 goto out_unlock_up; 818 goto out_unlock_up;
834 819
835 do_shm_rmid(ns, shp); 820 do_shm_rmid(ns, &shp->shm_perm);
836 up_write(&shm_ids(ns).rw_mutex); 821 up_write(&shm_ids(ns).rw_mutex);
837 goto out; 822 goto out;
838 } 823 }