aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/shm.c
diff options
context:
space:
mode:
Diffstat (limited to 'ipc/shm.c')
-rw-r--r--ipc/shm.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 8241264941a2..e2de16efe10d 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -139,13 +139,17 @@ void __init shm_init (void)
139 139
140static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id) 140static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id)
141{ 141{
142 return (struct shmid_kernel *) ipc_lock(&shm_ids(ns), id); 142 struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id);
143
144 return container_of(ipcp, struct shmid_kernel, shm_perm);
143} 145}
144 146
145static inline struct shmid_kernel *shm_lock_check(struct ipc_namespace *ns, 147static inline struct shmid_kernel *shm_lock_check(struct ipc_namespace *ns,
146 int id) 148 int id)
147{ 149{
148 return (struct shmid_kernel *) ipc_lock_check(&shm_ids(ns), id); 150 struct kern_ipc_perm *ipcp = ipc_lock_check(&shm_ids(ns), id);
151
152 return container_of(ipcp, struct shmid_kernel, shm_perm);
149} 153}
150 154
151static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s) 155static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s)
@@ -424,14 +428,21 @@ no_file:
424 return error; 428 return error;
425} 429}
426 430
427static inline int shm_security(void *shp, int shmflg) 431static inline int shm_security(struct kern_ipc_perm *ipcp, int shmflg)
428{ 432{
429 return security_shm_associate((struct shmid_kernel *) shp, shmflg); 433 struct shmid_kernel *shp;
434
435 shp = container_of(ipcp, struct shmid_kernel, shm_perm);
436 return security_shm_associate(shp, shmflg);
430} 437}
431 438
432static inline int shm_more_checks(void *shp, struct ipc_params *params) 439static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
440 struct ipc_params *params)
433{ 441{
434 if (((struct shmid_kernel *)shp)->shm_segsz < params->u.size) 442 struct shmid_kernel *shp;
443
444 shp = container_of(ipcp, struct shmid_kernel, shm_perm);
445 if (shp->shm_segsz < params->u.size)
435 return -EINVAL; 446 return -EINVAL;
436 447
437 return 0; 448 return 0;