24 #include <linux/errno.h>
27 #include <linux/msg.h>
28 #include <linux/shm.h>
30 #include <linux/ptrace.h>
33 #include <asm/uaccess.h>
117 #define sc_semopm (sem_ctls[2])
119 static inline int compat_ipc_parse_version(
int *
cmd)
121 #ifdef CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION
127 #ifndef ipc_parse_version
139 static inline int __get_compat_ipc64_perm(
struct ipc64_perm *p64,
150 static inline int __get_compat_ipc_perm(
struct ipc64_perm *
p,
161 static inline int __put_compat_ipc64_perm(
struct ipc64_perm *p64,
176 static inline int __put_compat_ipc_perm(
struct ipc64_perm *
p,
197 static inline int get_compat_semid64_ds(
struct semid64_ds *
s64,
202 return __get_compat_ipc64_perm(&s64->
sem_perm, &up64->sem_perm);
205 static inline int get_compat_semid_ds(
struct semid64_ds *
s,
210 return __get_compat_ipc_perm(&s->
sem_perm, &up->sem_perm);
213 static inline int put_compat_semid64_ds(
struct semid64_ds *s64,
220 err = __put_compat_ipc64_perm(&s64->
sem_perm, &up64->sem_perm);
227 static inline int put_compat_semid_ds(
struct semid64_ds *s,
234 err = __put_compat_ipc_perm(&s->
sem_perm, &up->sem_perm);
247 int version = compat_ipc_parse_version(&third);
249 memset(&s64, 0,
sizeof(s64));
252 fourth.val = (
int) pad;
254 fourth.__pad = compat_ptr(pad);
255 switch (third & (~
IPC_64)) {
266 err =
sys_semctl(first, second, third, fourth);
273 err =
sys_semctl(first, second, third, fourth);
278 else if (version ==
IPC_64)
279 err2 = put_compat_semid64_ds(&s64, compat_ptr(pad));
281 err2 = put_compat_semid_ds(&s64, compat_ptr(pad));
288 err = get_compat_semid64_ds(&s64, compat_ptr(pad));
290 err = get_compat_semid_ds(&s64, compat_ptr(pad));
299 err =
sys_semctl(first, second, third, fourth);
309 #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
318 return do_compat_semctl(first, second, third, pad);
338 int version,
void __user *uptr)
357 uptr = compat_ptr(ipck.msgp);
358 msgtyp = ipck.msgtyp;
372 return do_compat_semctl(semid, semnum, cmd, arg);
390 err =
do_msgrcv(msqid, &mtype, msgp->mtext, (
ssize_t)msgsz, msgtyp, msgflg);
401 static inline int get_compat_msqid64(
struct msqid64_ds *m64,
408 err = __get_compat_ipc64_perm(&m64->
msg_perm, &up64->msg_perm);
413 static inline int get_compat_msqid(
struct msqid64_ds *
m,
420 err = __get_compat_ipc_perm(&m->
msg_perm, &up->msg_perm);
425 static inline int put_compat_msqid64_ds(
struct msqid64_ds *m64,
432 err = __put_compat_ipc64_perm(&m64->
msg_perm, &up64->msg_perm);
444 static inline int put_compat_msqid_ds(
struct msqid64_ds *m,
451 err = __put_compat_ipc_perm(&m->
msg_perm, &up->msg_perm);
467 int version = compat_ipc_parse_version(&second);
470 memset(&m64, 0,
sizeof(m64));
472 switch (second & (~
IPC_64)) {
481 err = get_compat_msqid64(&m64, uptr);
483 err = get_compat_msqid(&m64, uptr);
502 else if (version ==
IPC_64)
503 err2 = put_compat_msqid64_ds(&m64, uptr);
505 err2 = put_compat_msqid_ds(&m64, uptr);
517 #ifndef COMPAT_SHMLBA
518 #define COMPAT_SHMLBA SHMLBA
521 #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
534 uaddr = compat_ptr(third);
551 static inline int get_compat_shmid64_ds(
struct shmid64_ds *s64,
556 return __get_compat_ipc64_perm(&s64->
shm_perm, &up64->shm_perm);
559 static inline int get_compat_shmid_ds(
struct shmid64_ds *s,
564 return __get_compat_ipc_perm(&s->
shm_perm, &up->shm_perm);
567 static inline int put_compat_shmid64_ds(
struct shmid64_ds *s64,
574 err = __put_compat_ipc64_perm(&s64->
shm_perm, &up64->shm_perm);
585 static inline int put_compat_shmid_ds(
struct shmid64_ds *s,
592 err = __put_compat_ipc_perm(&s->
shm_perm, &up->shm_perm);
603 static inline int put_compat_shminfo64(
struct shminfo64 *smi,
620 static inline int put_compat_shminfo(
struct shminfo64 *smi,
637 static inline int put_compat_shm_info(
struct shm_info __user *
ip,
646 err =
__put_user(si.used_ids, &uip->used_ids);
650 err |=
__put_user(si.swap_attempts, &uip->swap_attempts);
651 err |=
__put_user(si.swap_successes, &uip->swap_successes);
661 int version = compat_ipc_parse_version(&second);
663 memset(&s64, 0,
sizeof(s64));
665 switch (second & (~
IPC_64)) {
679 else if (version ==
IPC_64)
680 err2 = put_compat_shminfo64(&smi, uptr);
682 err2 = put_compat_shminfo(&smi, uptr);
690 err = get_compat_shmid64_ds(&s64, uptr);
692 err = get_compat_shmid_ds(&s64, uptr);
711 else if (version ==
IPC_64)
712 err2 = put_compat_shmid64_ds(&s64, uptr);
714 err2 = put_compat_shmid_ds(&s64, uptr);
724 err2 = put_compat_shm_info(p, uptr);