diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-03 14:36:44 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-03-03 23:00:27 -0500 |
commit | 0e65a81b105a3f646793d46740ad90fa5c067986 (patch) | |
tree | 3ebab1b2110a978c1e86ee2ee378d33b4a191826 | |
parent | 56e41d3c5aa84d679eebdb3cb8a70b03c5fbd6c3 (diff) |
get rid of compat_sys_semctl() and friends in case of ARCH_WANT_OLD_COMPAT_IPC
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | arch/mips/kernel/linux32.c | 24 | ||||
-rw-r--r-- | arch/mips/kernel/scall64-n32.S | 6 | ||||
-rw-r--r-- | include/linux/compat.h | 17 | ||||
-rw-r--r-- | ipc/compat.c | 158 |
4 files changed, 73 insertions, 132 deletions
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c index 7c57b8d7b255..d1d576b765f5 100644 --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c | |||
@@ -119,30 +119,6 @@ SYSCALL_DEFINE6(32_pwrite, unsigned int, fd, const char __user *, buf, | |||
119 | return sys_pwrite64(fd, buf, count, merge_64(a4, a5)); | 119 | return sys_pwrite64(fd, buf, count, merge_64(a4, a5)); |
120 | } | 120 | } |
121 | 121 | ||
122 | #ifdef CONFIG_MIPS32_N32 | ||
123 | SYSCALL_DEFINE4(n32_semctl, int, semid, int, semnum, int, cmd, u32, arg) | ||
124 | { | ||
125 | /* compat_sys_semctl expects a pointer to union semun */ | ||
126 | u32 __user *uptr = compat_alloc_user_space(sizeof(u32)); | ||
127 | if (put_user(arg, uptr)) | ||
128 | return -EFAULT; | ||
129 | return compat_sys_semctl(semid, semnum, cmd, uptr); | ||
130 | } | ||
131 | |||
132 | SYSCALL_DEFINE4(n32_msgsnd, int, msqid, u32, msgp, unsigned int, msgsz, | ||
133 | int, msgflg) | ||
134 | { | ||
135 | return compat_sys_msgsnd(msqid, msgsz, msgflg, compat_ptr(msgp)); | ||
136 | } | ||
137 | |||
138 | SYSCALL_DEFINE5(n32_msgrcv, int, msqid, u32, msgp, size_t, msgsz, | ||
139 | int, msgtyp, int, msgflg) | ||
140 | { | ||
141 | return compat_sys_msgrcv(msqid, msgsz, msgtyp, msgflg, IPC_64, | ||
142 | compat_ptr(msgp)); | ||
143 | } | ||
144 | #endif | ||
145 | |||
146 | SYSCALL_DEFINE1(32_personality, unsigned long, personality) | 122 | SYSCALL_DEFINE1(32_personality, unsigned long, personality) |
147 | { | 123 | { |
148 | unsigned int p = personality & 0xffffffff; | 124 | unsigned int p = personality & 0xffffffff; |
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S index 9b4df498fc5b..edcb6594e7b5 100644 --- a/arch/mips/kernel/scall64-n32.S +++ b/arch/mips/kernel/scall64-n32.S | |||
@@ -168,11 +168,11 @@ EXPORT(sysn32_call_table) | |||
168 | PTR sys_newuname | 168 | PTR sys_newuname |
169 | PTR sys_semget | 169 | PTR sys_semget |
170 | PTR sys_semop | 170 | PTR sys_semop |
171 | PTR sys_n32_semctl | 171 | PTR compat_sys_semctl |
172 | PTR sys_shmdt /* 6065 */ | 172 | PTR sys_shmdt /* 6065 */ |
173 | PTR sys_msgget | 173 | PTR sys_msgget |
174 | PTR sys_n32_msgsnd | 174 | PTR compat_sys_msgsnd |
175 | PTR sys_n32_msgrcv | 175 | PTR compat_sys_msgrcv |
176 | PTR compat_sys_msgctl | 176 | PTR compat_sys_msgctl |
177 | PTR compat_sys_fcntl /* 6070 */ | 177 | PTR compat_sys_fcntl /* 6070 */ |
178 | PTR sys_flock | 178 | PTR sys_flock |
diff --git a/include/linux/compat.h b/include/linux/compat.h index 79a4781ac502..2bfe67329dc4 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h | |||
@@ -311,22 +311,13 @@ asmlinkage long | |||
311 | compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, | 311 | compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, |
312 | compat_size_t __user *len_ptr); | 312 | compat_size_t __user *len_ptr); |
313 | 313 | ||
314 | #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC | ||
315 | long compat_sys_semctl(int first, int second, int third, void __user *uptr); | ||
316 | long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); | ||
317 | long compat_sys_msgrcv(int first, int second, int msgtyp, int third, | ||
318 | int version, void __user *uptr); | ||
319 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, | ||
320 | void __user *uptr); | ||
321 | asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32); | 314 | asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32); |
322 | #else | 315 | asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); |
323 | long compat_sys_semctl(int semid, int semnum, int cmd, int arg); | 316 | asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg); |
324 | long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp, | 317 | asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp, |
325 | compat_ssize_t msgsz, int msgflg); | 318 | compat_ssize_t msgsz, int msgflg); |
326 | long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp, | 319 | asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp, |
327 | compat_ssize_t msgsz, long msgtyp, int msgflg); | 320 | compat_ssize_t msgsz, long msgtyp, int msgflg); |
328 | long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); | ||
329 | #endif | ||
330 | long compat_sys_msgctl(int first, int second, void __user *uptr); | 321 | long compat_sys_msgctl(int first, int second, void __user *uptr); |
331 | long compat_sys_shmctl(int first, int second, void __user *uptr); | 322 | long compat_sys_shmctl(int first, int second, void __user *uptr); |
332 | long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, | 323 | long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, |
diff --git a/ipc/compat.c b/ipc/compat.c index 1da2e2eb9d70..6cb6a4df86e4 100644 --- a/ipc/compat.c +++ b/ipc/compat.c | |||
@@ -306,7 +306,7 @@ static long do_compat_semctl(int first, int second, int third, u32 pad) | |||
306 | return err; | 306 | return err; |
307 | } | 307 | } |
308 | 308 | ||
309 | long compat_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz) | 309 | static long compat_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz) |
310 | { | 310 | { |
311 | struct compat_msgbuf __user *msgp = dest; | 311 | struct compat_msgbuf __user *msgp = dest; |
312 | size_t msgsz; | 312 | size_t msgsz; |
@@ -320,59 +320,16 @@ long compat_do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz) | |||
320 | return msgsz; | 320 | return msgsz; |
321 | } | 321 | } |
322 | 322 | ||
323 | #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC | 323 | #ifndef COMPAT_SHMLBA |
324 | long compat_sys_semctl(int first, int second, int third, void __user *uptr) | 324 | #define COMPAT_SHMLBA SHMLBA |
325 | { | 325 | #endif |
326 | u32 pad; | ||
327 | |||
328 | if (!uptr) | ||
329 | return -EINVAL; | ||
330 | if (get_user(pad, (u32 __user *) uptr)) | ||
331 | return -EFAULT; | ||
332 | return do_compat_semctl(first, second, third, pad); | ||
333 | } | ||
334 | |||
335 | long compat_sys_msgsnd(int first, int second, int third, void __user *uptr) | ||
336 | { | ||
337 | struct compat_msgbuf __user *up = uptr; | ||
338 | long type; | ||
339 | |||
340 | if (first < 0) | ||
341 | return -EINVAL; | ||
342 | if (second < 0) | ||
343 | return -EINVAL; | ||
344 | |||
345 | if (get_user(type, &up->mtype)) | ||
346 | return -EFAULT; | ||
347 | |||
348 | return do_msgsnd(first, type, up->mtext, second, third); | ||
349 | } | ||
350 | |||
351 | long compat_sys_msgrcv(int first, int second, int msgtyp, int third, | ||
352 | int version, void __user *uptr) | ||
353 | { | ||
354 | if (first < 0) | ||
355 | return -EINVAL; | ||
356 | if (second < 0) | ||
357 | return -EINVAL; | ||
358 | |||
359 | if (!version) { | ||
360 | struct compat_ipc_kludge ipck; | ||
361 | if (!uptr) | ||
362 | return -EINVAL; | ||
363 | if (copy_from_user (&ipck, uptr, sizeof(ipck))) | ||
364 | return -EFAULT; | ||
365 | uptr = compat_ptr(ipck.msgp); | ||
366 | msgtyp = ipck.msgtyp; | ||
367 | } | ||
368 | return do_msgrcv(first, uptr, second, msgtyp, third, | ||
369 | compat_do_msg_fill); | ||
370 | } | ||
371 | 326 | ||
327 | #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC | ||
372 | COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second, | 328 | COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second, |
373 | u32, third, compat_uptr_t, ptr, u32, fifth) | 329 | u32, third, compat_uptr_t, ptr, u32, fifth) |
374 | { | 330 | { |
375 | int version; | 331 | int version; |
332 | u32 pad; | ||
376 | 333 | ||
377 | version = call >> 16; /* hack for backward compatibility */ | 334 | version = call >> 16; /* hack for backward compatibility */ |
378 | call &= 0xffff; | 335 | call &= 0xffff; |
@@ -387,21 +344,59 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second, | |||
387 | case SEMGET: | 344 | case SEMGET: |
388 | return sys_semget(first, second, third); | 345 | return sys_semget(first, second, third); |
389 | case SEMCTL: | 346 | case SEMCTL: |
390 | return compat_sys_semctl(first, second, third, compat_ptr(ptr)); | 347 | if (!ptr) |
348 | return -EINVAL; | ||
349 | if (get_user(pad, (u32 __user *) compat_ptr(ptr))) | ||
350 | return -EFAULT; | ||
351 | return do_compat_semctl(first, second, third, pad); | ||
352 | |||
353 | case MSGSND: { | ||
354 | struct compat_msgbuf __user *up = compat_ptr(ptr); | ||
355 | compat_long_t type; | ||
356 | |||
357 | if (first < 0 || second < 0) | ||
358 | return -EINVAL; | ||
391 | 359 | ||
392 | case MSGSND: | 360 | if (get_user(type, &up->mtype)) |
393 | return compat_sys_msgsnd(first, second, third, compat_ptr(ptr)); | 361 | return -EFAULT; |
394 | case MSGRCV: | 362 | |
395 | return compat_sys_msgrcv(first, second, fifth, third, | 363 | return do_msgsnd(first, type, up->mtext, second, third); |
396 | version, compat_ptr(ptr)); | 364 | } |
365 | case MSGRCV: { | ||
366 | void __user *uptr = compat_ptr(ptr); | ||
367 | |||
368 | if (first < 0 || second < 0) | ||
369 | return -EINVAL; | ||
370 | |||
371 | if (!version) { | ||
372 | struct compat_ipc_kludge ipck; | ||
373 | if (!uptr) | ||
374 | return -EINVAL; | ||
375 | if (copy_from_user (&ipck, uptr, sizeof(ipck))) | ||
376 | return -EFAULT; | ||
377 | uptr = compat_ptr(ipck.msgp); | ||
378 | fifth = ipck.msgtyp; | ||
379 | } | ||
380 | return do_msgrcv(first, uptr, second, fifth, third, | ||
381 | compat_do_msg_fill); | ||
382 | } | ||
397 | case MSGGET: | 383 | case MSGGET: |
398 | return sys_msgget(first, second); | 384 | return sys_msgget(first, second); |
399 | case MSGCTL: | 385 | case MSGCTL: |
400 | return compat_sys_msgctl(first, second, compat_ptr(ptr)); | 386 | return compat_sys_msgctl(first, second, compat_ptr(ptr)); |
401 | 387 | ||
402 | case SHMAT: | 388 | case SHMAT: { |
403 | return compat_sys_shmat(first, second, third, version, | 389 | int err; |
404 | compat_ptr(ptr)); | 390 | unsigned long raddr; |
391 | |||
392 | if (version == 1) | ||
393 | return -EINVAL; | ||
394 | err = do_shmat(first, compat_ptr(ptr), second, &raddr, | ||
395 | COMPAT_SHMLBA); | ||
396 | if (err < 0) | ||
397 | return err; | ||
398 | return put_user(raddr, (compat_ulong_t *)compat_ptr(third)); | ||
399 | } | ||
405 | case SHMDT: | 400 | case SHMDT: |
406 | return sys_shmdt(compat_ptr(ptr)); | 401 | return sys_shmdt(compat_ptr(ptr)); |
407 | case SHMGET: | 402 | case SHMGET: |
@@ -412,29 +407,30 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second, | |||
412 | 407 | ||
413 | return -ENOSYS; | 408 | return -ENOSYS; |
414 | } | 409 | } |
415 | #else | 410 | #endif |
416 | long compat_sys_semctl(int semid, int semnum, int cmd, int arg) | 411 | |
412 | COMPAT_SYSCALL_DEFINE4(semctl, int, semid, int, semnum, int, cmd, int, arg) | ||
417 | { | 413 | { |
418 | return do_compat_semctl(semid, semnum, cmd, arg); | 414 | return do_compat_semctl(semid, semnum, cmd, arg); |
419 | } | 415 | } |
420 | 416 | ||
421 | long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp, | 417 | COMPAT_SYSCALL_DEFINE4(msgsnd, int, msqid, compat_uptr_t, msgp, |
422 | compat_ssize_t msgsz, int msgflg) | 418 | compat_ssize_t, msgsz, int, msgflg) |
423 | { | 419 | { |
420 | struct compat_msgbuf __user *up = compat_ptr(msgp); | ||
424 | compat_long_t mtype; | 421 | compat_long_t mtype; |
425 | 422 | ||
426 | if (get_user(mtype, &msgp->mtype)) | 423 | if (get_user(mtype, &up->mtype)) |
427 | return -EFAULT; | 424 | return -EFAULT; |
428 | return do_msgsnd(msqid, mtype, msgp->mtext, (ssize_t)msgsz, msgflg); | 425 | return do_msgsnd(msqid, mtype, up->mtext, (ssize_t)msgsz, msgflg); |
429 | } | 426 | } |
430 | 427 | ||
431 | long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp, | 428 | COMPAT_SYSCALL_DEFINE5(msgrcv, int, msqid, compat_uptr_t, msgp, |
432 | compat_ssize_t msgsz, long msgtyp, int msgflg) | 429 | compat_ssize_t, msgsz, long, msgtyp, int, msgflg) |
433 | { | 430 | { |
434 | return do_msgrcv(msqid, msgp, (ssize_t)msgsz, msgtyp, msgflg, | 431 | return do_msgrcv(msqid, compat_ptr(msgp), (ssize_t)msgsz, msgtyp, |
435 | compat_do_msg_fill); | 432 | msgflg, compat_do_msg_fill); |
436 | } | 433 | } |
437 | #endif | ||
438 | 434 | ||
439 | static inline int get_compat_msqid64(struct msqid64_ds *m64, | 435 | static inline int get_compat_msqid64(struct msqid64_ds *m64, |
440 | struct compat_msqid64_ds __user *up64) | 436 | struct compat_msqid64_ds __user *up64) |
@@ -552,28 +548,7 @@ long compat_sys_msgctl(int first, int second, void __user *uptr) | |||
552 | return err; | 548 | return err; |
553 | } | 549 | } |
554 | 550 | ||
555 | #ifndef COMPAT_SHMLBA | 551 | COMPAT_SYSCALL_DEFINE3(shmat, int, shmid, compat_uptr_t, shmaddr, int, shmflg) |
556 | #define COMPAT_SHMLBA SHMLBA | ||
557 | #endif | ||
558 | |||
559 | #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC | ||
560 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, | ||
561 | void __user *uptr) | ||
562 | { | ||
563 | int err; | ||
564 | unsigned long raddr; | ||
565 | compat_ulong_t __user *uaddr; | ||
566 | |||
567 | if (version == 1) | ||
568 | return -EINVAL; | ||
569 | err = do_shmat(first, uptr, second, &raddr, COMPAT_SHMLBA); | ||
570 | if (err < 0) | ||
571 | return err; | ||
572 | uaddr = compat_ptr(third); | ||
573 | return put_user(raddr, uaddr); | ||
574 | } | ||
575 | #else | ||
576 | long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) | ||
577 | { | 552 | { |
578 | unsigned long ret; | 553 | unsigned long ret; |
579 | long err; | 554 | long err; |
@@ -584,7 +559,6 @@ long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) | |||
584 | force_successful_syscall_return(); | 559 | force_successful_syscall_return(); |
585 | return (long)ret; | 560 | return (long)ret; |
586 | } | 561 | } |
587 | #endif | ||
588 | 562 | ||
589 | static inline int get_compat_shmid64_ds(struct shmid64_ds *s64, | 563 | static inline int get_compat_shmid64_ds(struct shmid64_ds *s64, |
590 | struct compat_shmid64_ds __user *up64) | 564 | struct compat_shmid64_ds __user *up64) |