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 /ipc/compat.c | |
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>
Diffstat (limited to 'ipc/compat.c')
-rw-r--r-- | ipc/compat.c | 158 |
1 files changed, 66 insertions, 92 deletions
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) |