diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-09-20 10:07:38 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-09-20 10:07:38 +0000 |
commit | f75895c8d498d00978f5079c7b064838be0d44df (patch) | |
tree | 893c63fb30ee71be6f44142abacefa6724687bca | |
parent | 0faff0d1c28321e10a7b139d1f43692b863a49ab (diff) |
MD trap() passes a MD "traptype" and siginfo-style "code" up to the MI
layers. Then things get terribly confusing because the various MI layers
swap variable names for parameters, local variables, and structure fields
numerous times. Unconfuse all this mess.
Note that exec_elf.c coredump cpi_sigcode used to contain the MD traptype
but will now contain the MI siginfo-style "code" value.
ok miod kettenis pirofti
-rw-r--r-- | sys/kern/kern_sig.c | 47 | ||||
-rw-r--r-- | sys/sys/proc.h | 6 |
2 files changed, 26 insertions, 27 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 3ee7dc8bbcd..d3bbc7671d4 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.126 2011/07/11 15:40:47 guenther Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.127 2011/09/20 10:07:37 deraadt Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -679,7 +679,7 @@ pgsignal(struct pgrp *pgrp, int signum, int checkctty) * Otherwise, post it normally. */ void -trapsignal(struct proc *p, int signum, u_long code, int type, +trapsignal(struct proc *p, int signum, u_long trapno, int code, union sigval sigval) { struct sigacts *ps = p->p_sigacts; @@ -692,14 +692,14 @@ trapsignal(struct proc *p, int signum, u_long code, int type, if (KTRPOINT(p, KTR_PSIG)) { siginfo_t si; - initsiginfo(&si, signum, code, type, sigval); + initsiginfo(&si, signum, trapno, code, sigval); ktrpsig(p, signum, ps->ps_sigact[signum], - p->p_sigmask, type, &si); + p->p_sigmask, code, &si); } #endif p->p_stats->p_ru.ru_nsignals++; (*p->p_emul->e_sendsig)(ps->ps_sigact[signum], signum, - p->p_sigmask, code, type, sigval); + p->p_sigmask, trapno, code, sigval); p->p_sigmask |= ps->ps_catchmask[signum]; if ((ps->ps_sigreset & mask) != 0) { ps->ps_sigcatch &= ~mask; @@ -709,8 +709,8 @@ trapsignal(struct proc *p, int signum, u_long code, int type, } } else { p->p_sisig = signum; - p->p_sicode = code; /* XXX for core dump/debugger */ - p->p_sitype = type; + p->p_sitrapno = trapno; /* XXX for core dump/debugger */ + p->p_sicode = code; p->p_sigval = sigval; ptsignal(p, signum, STHREAD); } @@ -1195,10 +1195,10 @@ postsig(int signum) struct proc *p = curproc; struct sigacts *ps = p->p_sigacts; sig_t action; - u_long code; + u_long trapno; int mask, returnmask; union sigval sigval; - int s, type; + int s, code; #ifdef DIAGNOSTIC if (signum == 0) @@ -1211,15 +1211,14 @@ postsig(int signum) atomic_clearbits_int(&p->p_siglist, mask); action = ps->ps_sigact[signum]; sigval.sival_ptr = 0; - type = SI_USER; if (p->p_sisig != signum) { - code = 0; - type = SI_USER; + trapno = 0; + code = SI_USER; sigval.sival_ptr = 0; } else { + trapno = p->p_sitrapno; code = p->p_sicode; - type = p->p_sitype; sigval = p->p_sigval; } @@ -1227,9 +1226,9 @@ postsig(int signum) if (KTRPOINT(p, KTR_PSIG)) { siginfo_t si; - initsiginfo(&si, signum, code, type, sigval); + initsiginfo(&si, signum, trapno, code, sigval); ktrpsig(p, signum, action, p->p_flag & P_SIGSUSPEND ? - p->p_oldmask : p->p_sigmask, type, &si); + p->p_oldmask : p->p_sigmask, code, &si); } #endif if (action == SIG_DFL) { @@ -1277,13 +1276,13 @@ postsig(int signum) p->p_stats->p_ru.ru_nsignals++; if (p->p_sisig == signum) { p->p_sisig = 0; - p->p_sicode = 0; - p->p_sitype = SI_USER; + p->p_sitrapno = 0; + p->p_sicode = SI_USER; p->p_sigval.sival_ptr = NULL; } - (*p->p_emul->e_sendsig)(action, signum, returnmask, code, - type, sigval); + (*p->p_emul->e_sendsig)(action, signum, returnmask, trapno, + code, sigval); } KERNEL_UNLOCK(); @@ -1431,7 +1430,7 @@ coredump_trad(struct proc *p, void *cookie) strlcpy(core.c_name, p->p_comm, sizeof(core.c_name)); core.c_nseg = 0; core.c_signo = p->p_sisig; - core.c_ucode = p->p_sicode; + core.c_ucode = p->p_sitrapno; core.c_cpusize = 0; core.c_tsize = (u_long)ptoa(vm->vm_tsize); core.c_dsize = (u_long)ptoa(vm->vm_dsize); @@ -1561,13 +1560,13 @@ sys_thrsigdivert(struct proc *p, void *v, register_t *retval) } void -initsiginfo(siginfo_t *si, int sig, u_long code, int type, union sigval val) +initsiginfo(siginfo_t *si, int sig, u_long trapno, int code, union sigval val) { bzero(si, sizeof *si); si->si_signo = sig; - si->si_code = type; - if (type == SI_USER) { + si->si_code = code; + if (code == SI_USER) { si->si_value = val; } else { switch (sig) { @@ -1576,7 +1575,7 @@ initsiginfo(siginfo_t *si, int sig, u_long code, int type, union sigval val) case SIGBUS: case SIGFPE: si->si_addr = val.sival_ptr; - si->si_trapno = code; + si->si_trapno = trapno; break; case SIGXFSZ: break; diff --git a/sys/sys/proc.h b/sys/sys/proc.h index d1cc7498d63..3a4aa490181 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.142 2011/09/18 23:07:32 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.143 2011/09/20 10:07:37 deraadt Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -292,9 +292,9 @@ struct proc { sigset_t p_oldmask; /* Saved mask from before sigpause */ union sigval p_sigval; /* For core dump/debugger XXX */ - long p_sicode; /* For core dump/debugger XXX */ int p_sisig; /* For core dump/debugger XXX */ - int p_sitype; /* For core dump/debugger XXX */ + int p_sicode; /* For core dump/debugger XXX */ + long p_sitrapno; /* For core dump/debugger XXX */ struct user *p_addr; /* Kernel virtual addr of u-area */ struct mdproc p_md; /* Any machine-dependent fields. */ |