diff options
author | Paul Mackerras <paulus@samba.org> | 2006-02-07 17:43:08 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-02-07 17:43:08 -0500 |
commit | 8f75015f33c3005e0bbf83ffc0d5e0b4262cc03d (patch) | |
tree | a3c34ad86ccdc904bb43af6cd1cb163231c29276 /arch/parisc/kernel/signal32.c | |
parent | 076d022c566fddde41fd4a858dd24bacad8304d7 (diff) | |
parent | e060e084e7d9e1c62d02cb6b8d3fe07db5317eaa (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
Diffstat (limited to 'arch/parisc/kernel/signal32.c')
-rw-r--r-- | arch/parisc/kernel/signal32.c | 102 |
1 files changed, 101 insertions, 1 deletions
diff --git a/arch/parisc/kernel/signal32.c b/arch/parisc/kernel/signal32.c index 0792e20efef3..a6b4231cafa1 100644 --- a/arch/parisc/kernel/signal32.c +++ b/arch/parisc/kernel/signal32.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
32 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
33 | 33 | ||
34 | #include <asm/compat_signal.h> | ||
35 | #include <asm/uaccess.h> | 34 | #include <asm/uaccess.h> |
36 | 35 | ||
37 | #include "signal32.h" | 36 | #include "signal32.h" |
@@ -398,3 +397,104 @@ setup_sigcontext32(struct compat_sigcontext __user *sc, struct compat_regfile __ | |||
398 | 397 | ||
399 | return err; | 398 | return err; |
400 | } | 399 | } |
400 | |||
401 | int | ||
402 | copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from) | ||
403 | { | ||
404 | unsigned long tmp; | ||
405 | int err; | ||
406 | |||
407 | if (!access_ok(VERIFY_READ, from, sizeof(compat_siginfo_t))) | ||
408 | return -EFAULT; | ||
409 | |||
410 | err = __get_user(to->si_signo, &from->si_signo); | ||
411 | err |= __get_user(to->si_errno, &from->si_errno); | ||
412 | err |= __get_user(to->si_code, &from->si_code); | ||
413 | |||
414 | if (to->si_code < 0) | ||
415 | err |= __copy_from_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE); | ||
416 | else { | ||
417 | switch (to->si_code >> 16) { | ||
418 | case __SI_CHLD >> 16: | ||
419 | err |= __get_user(to->si_utime, &from->si_utime); | ||
420 | err |= __get_user(to->si_stime, &from->si_stime); | ||
421 | err |= __get_user(to->si_status, &from->si_status); | ||
422 | default: | ||
423 | err |= __get_user(to->si_pid, &from->si_pid); | ||
424 | err |= __get_user(to->si_uid, &from->si_uid); | ||
425 | break; | ||
426 | case __SI_FAULT >> 16: | ||
427 | err |= __get_user(tmp, &from->si_addr); | ||
428 | to->si_addr = (void __user *) tmp; | ||
429 | break; | ||
430 | case __SI_POLL >> 16: | ||
431 | err |= __get_user(to->si_band, &from->si_band); | ||
432 | err |= __get_user(to->si_fd, &from->si_fd); | ||
433 | break; | ||
434 | case __SI_RT >> 16: /* This is not generated by the kernel as of now. */ | ||
435 | case __SI_MESGQ >> 16: | ||
436 | err |= __get_user(to->si_pid, &from->si_pid); | ||
437 | err |= __get_user(to->si_uid, &from->si_uid); | ||
438 | err |= __get_user(to->si_int, &from->si_int); | ||
439 | break; | ||
440 | } | ||
441 | } | ||
442 | return err; | ||
443 | } | ||
444 | |||
445 | int | ||
446 | copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from) | ||
447 | { | ||
448 | unsigned int addr; | ||
449 | int err; | ||
450 | |||
451 | if (!access_ok(VERIFY_WRITE, to, sizeof(compat_siginfo_t))) | ||
452 | return -EFAULT; | ||
453 | |||
454 | /* If you change siginfo_t structure, please be sure | ||
455 | this code is fixed accordingly. | ||
456 | It should never copy any pad contained in the structure | ||
457 | to avoid security leaks, but must copy the generic | ||
458 | 3 ints plus the relevant union member. | ||
459 | This routine must convert siginfo from 64bit to 32bit as well | ||
460 | at the same time. */ | ||
461 | err = __put_user(from->si_signo, &to->si_signo); | ||
462 | err |= __put_user(from->si_errno, &to->si_errno); | ||
463 | err |= __put_user((short)from->si_code, &to->si_code); | ||
464 | if (from->si_code < 0) | ||
465 | err |= __copy_to_user(&to->_sifields._pad, &from->_sifields._pad, SI_PAD_SIZE); | ||
466 | else { | ||
467 | switch (from->si_code >> 16) { | ||
468 | case __SI_CHLD >> 16: | ||
469 | err |= __put_user(from->si_utime, &to->si_utime); | ||
470 | err |= __put_user(from->si_stime, &to->si_stime); | ||
471 | err |= __put_user(from->si_status, &to->si_status); | ||
472 | default: | ||
473 | err |= __put_user(from->si_pid, &to->si_pid); | ||
474 | err |= __put_user(from->si_uid, &to->si_uid); | ||
475 | break; | ||
476 | case __SI_FAULT >> 16: | ||
477 | /* avoid type-checking warnings by copying _pad[0] in lieu of si_addr... */ | ||
478 | err |= __put_user(from->_sifields._pad[0], &to->si_addr); | ||
479 | break; | ||
480 | case __SI_POLL >> 16: | ||
481 | err |= __put_user(from->si_band, &to->si_band); | ||
482 | err |= __put_user(from->si_fd, &to->si_fd); | ||
483 | break; | ||
484 | case __SI_TIMER >> 16: | ||
485 | err |= __put_user(from->si_tid, &to->si_tid); | ||
486 | err |= __put_user(from->si_overrun, &to->si_overrun); | ||
487 | addr = (unsigned long) from->si_ptr; | ||
488 | err |= __put_user(addr, &to->si_ptr); | ||
489 | break; | ||
490 | case __SI_RT >> 16: /* Not generated by the kernel as of now. */ | ||
491 | case __SI_MESGQ >> 16: | ||
492 | err |= __put_user(from->si_uid, &to->si_uid); | ||
493 | err |= __put_user(from->si_pid, &to->si_pid); | ||
494 | addr = (unsigned long) from->si_ptr; | ||
495 | err |= __put_user(addr, &to->si_ptr); | ||
496 | break; | ||
497 | } | ||
498 | } | ||
499 | return err; | ||
500 | } | ||