aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipc/msg.c5
-rw-r--r--ipc/sem.c10
-rw-r--r--ipc/shm.c5
-rw-r--r--ipc/util.h9
4 files changed, 12 insertions, 17 deletions
diff --git a/ipc/msg.c b/ipc/msg.c
index 413bf9c7aec3..4f1f26393501 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -74,8 +74,7 @@ static struct ipc_ids init_msg_ids;
74#define msg_ids(ns) (*((ns)->ids[IPC_MSG_IDS])) 74#define msg_ids(ns) (*((ns)->ids[IPC_MSG_IDS]))
75 75
76#define msg_unlock(msq) ipc_unlock(&(msq)->q_perm) 76#define msg_unlock(msq) ipc_unlock(&(msq)->q_perm)
77#define msg_buildid(ns, id, seq) \ 77#define msg_buildid(id, seq) ipc_buildid(id, seq)
78 ipc_buildid(&msg_ids(ns), id, seq)
79 78
80static void freeque(struct ipc_namespace *, struct msg_queue *); 79static void freeque(struct ipc_namespace *, struct msg_queue *);
81static int newque(struct ipc_namespace *, struct ipc_params *); 80static int newque(struct ipc_namespace *, struct ipc_params *);
@@ -211,7 +210,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
211 return -ENOSPC; 210 return -ENOSPC;
212 } 211 }
213 212
214 msq->q_perm.id = msg_buildid(ns, id, msq->q_perm.seq); 213 msq->q_perm.id = msg_buildid(id, msq->q_perm.seq);
215 msq->q_stime = msq->q_rtime = 0; 214 msq->q_stime = msq->q_rtime = 0;
216 msq->q_ctime = get_seconds(); 215 msq->q_ctime = get_seconds();
217 msq->q_cbytes = msq->q_qnum = 0; 216 msq->q_cbytes = msq->q_qnum = 0;
diff --git a/ipc/sem.c b/ipc/sem.c
index 019e21332dd6..40ab34d832a6 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -89,10 +89,8 @@
89#define sem_ids(ns) (*((ns)->ids[IPC_SEM_IDS])) 89#define sem_ids(ns) (*((ns)->ids[IPC_SEM_IDS]))
90 90
91#define sem_unlock(sma) ipc_unlock(&(sma)->sem_perm) 91#define sem_unlock(sma) ipc_unlock(&(sma)->sem_perm)
92#define sem_checkid(ns, sma, semid) \ 92#define sem_checkid(sma, semid) ipc_checkid(&sma->sem_perm, semid)
93 ipc_checkid(&sem_ids(ns),&sma->sem_perm,semid) 93#define sem_buildid(id, seq) ipc_buildid(id, seq)
94#define sem_buildid(ns, id, seq) \
95 ipc_buildid(&sem_ids(ns), id, seq)
96 94
97static struct ipc_ids init_sem_ids; 95static struct ipc_ids init_sem_ids;
98 96
@@ -292,7 +290,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params)
292 } 290 }
293 ns->used_sems += nsems; 291 ns->used_sems += nsems;
294 292
295 sma->sem_perm.id = sem_buildid(ns, id, sma->sem_perm.seq); 293 sma->sem_perm.id = sem_buildid(id, sma->sem_perm.seq);
296 sma->sem_base = (struct sem *) &sma[1]; 294 sma->sem_base = (struct sem *) &sma[1];
297 /* sma->sem_pending = NULL; */ 295 /* sma->sem_pending = NULL; */
298 sma->sem_pending_last = &sma->sem_pending; 296 sma->sem_pending_last = &sma->sem_pending;
@@ -1386,7 +1384,7 @@ void exit_sem(struct task_struct *tsk)
1386 if (u->semid == -1) 1384 if (u->semid == -1)
1387 goto next_entry; 1385 goto next_entry;
1388 1386
1389 BUG_ON(sem_checkid(ns,sma,u->semid)); 1387 BUG_ON(sem_checkid(sma, u->semid));
1390 1388
1391 /* remove u from the sma->undo list */ 1389 /* remove u from the sma->undo list */
1392 for (unp = &sma->undo; (un = *unp); unp = &un->id_next) { 1390 for (unp = &sma->undo; (un = *unp); unp = &un->id_next) {
diff --git a/ipc/shm.c b/ipc/shm.c
index b27d31f3aaba..05c97c7513c2 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -61,8 +61,7 @@ static struct ipc_ids init_shm_ids;
61 61
62#define shm_unlock(shp) \ 62#define shm_unlock(shp) \
63 ipc_unlock(&(shp)->shm_perm) 63 ipc_unlock(&(shp)->shm_perm)
64#define shm_buildid(ns, id, seq) \ 64#define shm_buildid(id, seq) ipc_buildid(id, seq)
65 ipc_buildid(&shm_ids(ns), id, seq)
66 65
67static int newseg(struct ipc_namespace *, struct ipc_params *); 66static int newseg(struct ipc_namespace *, struct ipc_params *);
68static void shm_open(struct vm_area_struct *vma); 67static void shm_open(struct vm_area_struct *vma);
@@ -445,7 +444,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
445 shp->shm_ctim = get_seconds(); 444 shp->shm_ctim = get_seconds();
446 shp->shm_segsz = size; 445 shp->shm_segsz = size;
447 shp->shm_nattch = 0; 446 shp->shm_nattch = 0;
448 shp->shm_perm.id = shm_buildid(ns, id, shp->shm_perm.seq); 447 shp->shm_perm.id = shm_buildid(id, shp->shm_perm.seq);
449 shp->shm_file = file; 448 shp->shm_file = file;
450 /* 449 /*
451 * shmid gets reported as "inode#" in /proc/pid/maps. 450 * shmid gets reported as "inode#" in /proc/pid/maps.
diff --git a/ipc/util.h b/ipc/util.h
index bd47687077e0..9ffea40457ce 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -134,7 +134,7 @@ extern int ipcget_new(struct ipc_namespace *, struct ipc_ids *,
134extern int ipcget_public(struct ipc_namespace *, struct ipc_ids *, 134extern int ipcget_public(struct ipc_namespace *, struct ipc_ids *,
135 struct ipc_ops *, struct ipc_params *); 135 struct ipc_ops *, struct ipc_params *);
136 136
137static inline int ipc_buildid(struct ipc_ids *ids, int id, int seq) 137static inline int ipc_buildid(int id, int seq)
138{ 138{
139 return SEQ_MULTIPLIER * seq + id; 139 return SEQ_MULTIPLIER * seq + id;
140} 140}
@@ -142,8 +142,7 @@ static inline int ipc_buildid(struct ipc_ids *ids, int id, int seq)
142/* 142/*
143 * Must be called with ipcp locked 143 * Must be called with ipcp locked
144 */ 144 */
145static inline int ipc_checkid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp, 145static inline int ipc_checkid(struct kern_ipc_perm *ipcp, int uid)
146 int uid)
147{ 146{
148 if (uid / SEQ_MULTIPLIER != ipcp->seq) 147 if (uid / SEQ_MULTIPLIER != ipcp->seq)
149 return 1; 148 return 1;
@@ -171,7 +170,7 @@ static inline struct kern_ipc_perm *ipc_lock_check_down(struct ipc_ids *ids,
171 if (IS_ERR(out)) 170 if (IS_ERR(out))
172 return out; 171 return out;
173 172
174 if (ipc_checkid(ids, out, id)) { 173 if (ipc_checkid(out, id)) {
175 ipc_unlock(out); 174 ipc_unlock(out);
176 return ERR_PTR(-EIDRM); 175 return ERR_PTR(-EIDRM);
177 } 176 }
@@ -188,7 +187,7 @@ static inline struct kern_ipc_perm *ipc_lock_check(struct ipc_ids *ids,
188 if (IS_ERR(out)) 187 if (IS_ERR(out))
189 return out; 188 return out;
190 189
191 if (ipc_checkid(ids, out, id)) { 190 if (ipc_checkid(out, id)) {
192 ipc_unlock(out); 191 ipc_unlock(out);
193 return ERR_PTR(-EIDRM); 192 return ERR_PTR(-EIDRM);
194 } 193 }