diff options
-rw-r--r-- | sys/arch/amd64/amd64/fpu.c | 4 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/syscall.c | 14 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/trap.c | 20 | ||||
-rw-r--r-- | sys/arch/hppa/hppa/trap.c | 46 | ||||
-rw-r--r-- | sys/arch/i386/i386/trap.c | 42 | ||||
-rw-r--r-- | sys/arch/i386/isa/npx.c | 4 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/m88110_fp.c | 4 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/trap.c | 30 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/fp_emulate.c | 4 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/trap.c | 18 | ||||
-rw-r--r-- | sys/arch/powerpc/powerpc/trap.c | 30 | ||||
-rw-r--r-- | sys/arch/sparc64/fpu/fpu.c | 10 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/emul.c | 10 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/trap.c | 48 | ||||
-rw-r--r-- | sys/dev/systrace.c | 14 | ||||
-rw-r--r-- | sys/kern/kern_ktrace.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 7 | ||||
-rw-r--r-- | sys/kern/kern_xxx.c | 12 | ||||
-rw-r--r-- | sys/sys/resourcevar.h | 4 |
19 files changed, 50 insertions, 278 deletions
diff --git a/sys/arch/amd64/amd64/fpu.c b/sys/arch/amd64/amd64/fpu.c index 1c36e6e7443..ae53cbf65fb 100644 --- a/sys/arch/amd64/amd64/fpu.c +++ b/sys/arch/amd64/amd64/fpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu.c,v 1.23 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: fpu.c,v 1.24 2011/07/07 18:11:23 art Exp $ */ /* $NetBSD: fpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /*- @@ -166,9 +166,7 @@ fputrap(struct trapframe *frame) sfp->fp_ex_sw = sfp->fp_fxsave.fx_fsw; code = x86fpflags_to_siginfo (statbits); sv.sival_ptr = (void *)frame->tf_rip; /* XXX - ? */ - KERNEL_LOCK(); trapsignal(p, SIGFPE, frame->tf_err, code, sv); - KERNEL_UNLOCK(); } static int diff --git a/sys/arch/amd64/amd64/syscall.c b/sys/arch/amd64/amd64/syscall.c index e43c2f61227..e8fa341ef92 100644 --- a/sys/arch/amd64/amd64/syscall.c +++ b/sys/arch/amd64/amd64/syscall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.c,v 1.17 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: syscall.c,v 1.18 2011/07/07 18:11:23 art Exp $ */ /* $NetBSD: syscall.c,v 1.1 2003/04/26 18:39:32 fvdl Exp $ */ /*- @@ -127,24 +127,18 @@ syscall(struct trapframe *frame) lock = !(callp->sy_flags & SY_NOLOCK); #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_call(p, code, argp); - KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - KERNEL_LOCK(); ktrsyscall(p, code, callp->sy_argsize, argp); - KERNEL_UNLOCK(); } #endif rval[0] = 0; rval[1] = frame->tf_rdx; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - KERNEL_LOCK(); error = systrace_redirect(code, p, argp, rval); - KERNEL_UNLOCK(); } else #endif { @@ -179,16 +173,12 @@ syscall(struct trapframe *frame) } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_ret(p, code, error, rval); - KERNEL_UNLOCK(); #endif userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, code, error, rval[0]); - KERNEL_UNLOCK(); } #endif } @@ -208,12 +198,10 @@ child_return(void *arg) userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, (p->p_flag & P_THREAD) ? SYS_rfork : (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); - KERNEL_UNLOCK(); } #endif } diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 10d1cc5ce2b..ff2c2330724 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.23 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: trap.c,v 1.24 2011/07/07 18:11:23 art Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -250,22 +250,16 @@ copyfault: frame_dump(frame); #endif sv.sival_ptr = (void *)frame->tf_rip; - KERNEL_LOCK(); trapsignal(p, SIGBUS, type & ~T_USER, BUS_OBJERR, sv); - KERNEL_UNLOCK(); goto out; case T_ALIGNFLT|T_USER: sv.sival_ptr = (void *)frame->tf_rip; - KERNEL_LOCK(); trapsignal(p, SIGBUS, type & ~T_USER, BUS_ADRALN, sv); - KERNEL_UNLOCK(); goto out; case T_PRIVINFLT|T_USER: /* privileged instruction fault */ sv.sival_ptr = (void *)frame->tf_rip; - KERNEL_LOCK(); trapsignal(p, SIGILL, type & ~T_USER, ILL_PRVOPC, sv); - KERNEL_UNLOCK(); goto out; case T_FPOPFLT|T_USER: /* coprocessor operand fault */ #ifdef TRAP_SIGDEBUG @@ -274,17 +268,13 @@ copyfault: frame_dump(frame); #endif sv.sival_ptr = (void *)frame->tf_rip; - KERNEL_LOCK(); trapsignal(p, SIGILL, type & ~T_USER, ILL_COPROC, sv); - KERNEL_UNLOCK(); goto out; case T_ASTFLT|T_USER: /* Allow process switch */ uvmexp.softs++; if (p->p_flag & P_OWEUPC) { - KERNEL_LOCK(); ADDUPROF(p); - KERNEL_UNLOCK(); } /* Allow a forced task switch. */ if (curcpu()->ci_want_resched) @@ -293,21 +283,15 @@ copyfault: case T_BOUND|T_USER: sv.sival_ptr = (void *)frame->tf_rip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_FLTSUB, sv); - KERNEL_UNLOCK(); goto out; case T_OFLOW|T_USER: sv.sival_ptr = (void *)frame->tf_rip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTOVF, sv); - KERNEL_UNLOCK(); goto out; case T_DIVIDE|T_USER: sv.sival_ptr = (void *)frame->tf_rip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTDIV, sv); - KERNEL_UNLOCK(); goto out; case T_ARITHTRAP|T_USER: @@ -421,9 +405,7 @@ faultcommon: #ifdef MATH_EMULATE trace: #endif - KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, TRAP_BRKPT, sv); - KERNEL_UNLOCK(); break; #if NISA > 0 diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c index 54dd8f20977..8a807ab25b8 100644 --- a/sys/arch/hppa/hppa/trap.c +++ b/sys/arch/hppa/hppa/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.116 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: trap.c,v 1.117 2011/07/07 18:11:23 art Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -146,9 +146,7 @@ userret(struct proc *p) p->p_md.md_astpending = 0; uvmexp.softs++; if (p->p_flag & P_OWEUPC) { - KERNEL_LOCK(); ADDUPROF(p); - KERNEL_UNLOCK(); } if (curcpu()->ci_want_resched) preempt(NULL); @@ -282,9 +280,7 @@ trap(int type, struct trapframe *frame) code = TRAP_TRACE; #endif /* pass to user debugger */ - KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, code, sv); - KERNEL_UNLOCK(); } break; @@ -293,9 +289,7 @@ trap(int type, struct trapframe *frame) ss_clear_breakpoints(p); /* pass to user debugger */ - KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, TRAP_TRACE, sv); - KERNEL_UNLOCK(); break; #endif @@ -335,9 +329,7 @@ trap(int type, struct trapframe *frame) fpp[0] &= ~(((u_int64_t)HPPA_FPU_T) << 32); sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, flt, sv); - KERNEL_UNLOCK(); } break; @@ -347,46 +339,34 @@ trap(int type, struct trapframe *frame) case T_EMULATION | T_USER: sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_COPROC, sv); - KERNEL_UNLOCK(); break; case T_OVERFLOW | T_USER: sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTOVF, sv); - KERNEL_UNLOCK(); break; case T_CONDITION | T_USER: sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTDIV, sv); - KERNEL_UNLOCK(); break; case T_PRIV_OP | T_USER: sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_PRVOPC, sv); - KERNEL_UNLOCK(); break; case T_PRIV_REG | T_USER: sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_PRVREG, sv); - KERNEL_UNLOCK(); break; /* these should never got here */ case T_HIGHERPL | T_USER: case T_LOWERPL | T_USER: sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, SEGV_ACCERR, sv); - KERNEL_UNLOCK(); break; /* @@ -405,9 +385,7 @@ trap(int type, struct trapframe *frame) case T_IPROT | T_USER: sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, SEGV_ACCERR, sv); - KERNEL_UNLOCK(); break; case T_ITLBMISSNA: @@ -449,9 +427,7 @@ trap(int type, struct trapframe *frame) KERNEL_UNLOCK(); } else if (type & T_USER) { sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGILL, type & ~T_USER, ILL_ILLTRP, sv); - KERNEL_UNLOCK(); } else panic("trap: %s @ 0x%x:0x%x for 0x%x:0x%x irr 0x%08x", tts, frame->tf_iisq_head, frame->tf_iioq_head, @@ -489,9 +465,7 @@ datacc: if ((type & T_USER && va >= VM_MAXUSER_ADDRESS) || (type & T_USER && map->pmap->pm_space != space)) { sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, SEGV_MAPERR, sv); - KERNEL_UNLOCK(); break; } @@ -519,11 +493,9 @@ datacc: if (ret != 0) { if (type & T_USER) { sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, ret == EACCES? SEGV_ACCERR : SEGV_MAPERR, sv); - KERNEL_UNLOCK(); } else { if (p && p->p_addr->u_pcb.pcb_onfault) { frame->tf_iioq_tail = 4 + @@ -544,9 +516,7 @@ datacc: case T_DATALIGN | T_USER: datalign_user: sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGBUS, vftype, BUS_ADRALN, sv); - KERNEL_UNLOCK(); break; case T_INTERRUPT: @@ -568,9 +538,7 @@ datalign_user: } if (type & T_USER) { sv.sival_int = va; - KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_ILLOPC, sv); - KERNEL_UNLOCK(); break; } /* FALLTHROUGH */ @@ -646,12 +614,10 @@ child_return(void *arg) userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, (p->p_flag & P_THREAD) ? SYS_rfork : (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); - KERNEL_UNLOCK(); } #endif } @@ -869,15 +835,11 @@ syscall(struct trapframe *frame) } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_call(p, code, args); - KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - KERNEL_LOCK(); ktrsyscall(p, code, callp->sy_argsize, args); - KERNEL_UNLOCK(); } #endif if (error) @@ -887,9 +849,7 @@ syscall(struct trapframe *frame) rval[1] = frame->tf_ret1; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - KERNEL_LOCK(); oerror = error = systrace_redirect(code, p, args, rval); - KERNEL_UNLOCK(); } else #endif { @@ -922,16 +882,12 @@ syscall(struct trapframe *frame) break; } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_ret(p, code, oerror, rval); - KERNEL_UNLOCK(); #endif userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, code, oerror, rval[0]); - KERNEL_UNLOCK(); } #endif #ifdef DIAGNOSTIC diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index a141cc608e1..8c48ed8283c 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.98 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: trap.c,v 1.99 2011/07/07 18:11:23 art Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -322,46 +322,34 @@ trap(struct trapframe *frame) case T_TSSFLT|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGBUS, vftype, BUS_OBJERR, sv); - KERNEL_UNLOCK(); goto out; case T_SEGNPFLT|T_USER: case T_STKFLT|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGSEGV, vftype, SEGV_MAPERR, sv); - KERNEL_UNLOCK(); goto out; case T_ALIGNFLT|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGBUS, vftype, BUS_ADRALN, sv); - KERNEL_UNLOCK(); goto out; case T_PRIVINFLT|T_USER: /* privileged instruction fault */ sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_PRVOPC, sv); - KERNEL_UNLOCK(); goto out; case T_FPOPFLT|T_USER: /* coprocessor operand fault */ sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGILL, type &~ T_USER, ILL_COPROC, sv); - KERNEL_UNLOCK(); goto out; case T_ASTFLT|T_USER: /* Allow process switch */ uvmexp.softs++; if (p->p_flag & P_OWEUPC) { - KERNEL_LOCK(); ADDUPROF(p); - KERNEL_UNLOCK(); } if (want_resched) preempt(NULL); @@ -371,36 +359,26 @@ trap(struct trapframe *frame) printf("pid %d killed due to lack of floating point\n", p->p_pid); sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGKILL, type &~ T_USER, FPE_FLTINV, sv); - KERNEL_UNLOCK(); goto out; } case T_BOUND|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_FLTSUB, sv); - KERNEL_UNLOCK(); goto out; case T_OFLOW|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTOVF, sv); - KERNEL_UNLOCK(); goto out; case T_DIVIDE|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, type &~ T_USER, FPE_INTDIV, sv); - KERNEL_UNLOCK(); goto out; case T_ARITHTRAP|T_USER: sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, frame->tf_err, FPE_INTOVF, sv); - KERNEL_UNLOCK(); goto out; case T_XFTRAP|T_USER: @@ -506,15 +484,11 @@ trap(struct trapframe *frame) case T_BPTFLT|T_USER: /* bpt instruction fault */ sv.sival_int = rcr2(); - KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, TRAP_BRKPT, sv); - KERNEL_UNLOCK(); break; case T_TRCTRAP|T_USER: /* trace trap */ sv.sival_int = rcr2(); - KERNEL_LOCK(); trapsignal(p, SIGTRAP, type &~ T_USER, TRAP_TRACE, sv); - KERNEL_UNLOCK(); break; #if NISA > 0 @@ -667,16 +641,12 @@ syscall(struct trapframe *frame) lock = !(callp->sy_flags & SY_NOLOCK); #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_call(p, code, args); - KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - KERNEL_LOCK(); ktrsyscall(p, code, argsize, args); - KERNEL_UNLOCK(); } #endif @@ -688,15 +658,13 @@ syscall(struct trapframe *frame) #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - KERNEL_LOCK(); orig_error = error = systrace_redirect(code, p, args, rval); - KERNEL_UNLOCK(); } else #endif { if (lock) KERNEL_LOCK(); - orig_error = error = (*callp->sy_call)(p, args, rval); + orig_error = error = (*callp->sy_call)(p, args, rval); if (lock) KERNEL_UNLOCK(); } @@ -728,16 +696,12 @@ syscall(struct trapframe *frame) } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_ret(p, code, orig_error, rval); - KERNEL_UNLOCK(); #endif userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, code, orig_error, rval[0]); - KERNEL_UNLOCK(); } #endif #ifdef DIAGNOSTIC @@ -764,12 +728,10 @@ child_return(void *arg) userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, (p->p_flag & P_THREAD) ? SYS_rfork : (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); - KERNEL_UNLOCK(); } #endif } diff --git a/sys/arch/i386/isa/npx.c b/sys/arch/i386/isa/npx.c index e13e64f646b..a35f451c5f1 100644 --- a/sys/arch/i386/isa/npx.c +++ b/sys/arch/i386/isa/npx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npx.c,v 1.55 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: npx.c,v 1.56 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: npx.c,v 1.57 1996/05/12 23:12:24 mycroft Exp $ */ #if 0 @@ -578,9 +578,7 @@ npxtrap(struct trapframe *frame) addr->sv_xmm.sv_ex_tw = addr->sv_xmm.sv_env.en_tw; code = x86fpflags_to_siginfo (statbits); sv.sival_int = frame->tf_eip; - KERNEL_LOCK(); trapsignal(p, SIGFPE, frame->tf_err, code, sv); - KERNEL_UNLOCK(); } static int diff --git a/sys/arch/m88k/m88k/m88110_fp.c b/sys/arch/m88k/m88k/m88110_fp.c index 64a31cb1ccf..b3f06309ec0 100644 --- a/sys/arch/m88k/m88k/m88110_fp.c +++ b/sys/arch/m88k/m88k/m88110_fp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m88110_fp.c,v 1.4 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: m88110_fp.c,v 1.5 2011/07/07 18:11:24 art Exp $ */ /* * Copyright (c) 2007, Miodrag Vallat. @@ -215,9 +215,7 @@ m88110_fpu_exception(struct trapframe *frame) deliver: sv.sival_ptr = (void *)fault_addr; - KERNEL_LOCK(); trapsignal(p, sig, 0, fault_type, sv); - KERNEL_UNLOCK(); } } diff --git a/sys/arch/m88k/m88k/trap.c b/sys/arch/m88k/m88k/trap.c index 2e213623c3a..032579fc8b4 100644 --- a/sys/arch/m88k/m88k/trap.c +++ b/sys/arch/m88k/m88k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.76 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: trap.c,v 1.77 2011/07/07 18:11:24 art Exp $ */ /* * Copyright (c) 2004, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -223,9 +223,7 @@ ast(struct trapframe *frame) uvmexp.softs++; p->p_md.md_astpending = 0; if (p->p_flag & P_OWEUPC) { - KERNEL_LOCK(); ADDUPROF(p); - KERNEL_UNLOCK(); } if (ci->ci_want_resched) preempt(NULL); @@ -602,9 +600,7 @@ user_fault: if (sig) { sv.sival_ptr = (void *)fault_addr; - KERNEL_LOCK(); trapsignal(p, sig, fault_code, fault_type, sv); - KERNEL_UNLOCK(); /* * don't want multiple faults - we are going to * deliver signal. @@ -1117,9 +1113,7 @@ m88110_user_fault: if (sig) { deliver: sv.sival_ptr = (void *)fault_addr; - KERNEL_LOCK(); trapsignal(p, sig, fault_code, fault_type, sv); - KERNEL_UNLOCK(); } userexit: @@ -1204,24 +1198,18 @@ m88100_syscall(register_t code, struct trapframe *tf) goto bad; #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_call(p, code, args); - KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - KERNEL_LOCK(); ktrsyscall(p, code, callp->sy_argsize, args); - KERNEL_UNLOCK(); } #endif rval[0] = 0; rval[1] = tf->tf_r[3]; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - KERNEL_LOCK(); error = systrace_redirect(code, p, args, rval); - KERNEL_UNLOCK(); } else #endif { @@ -1289,16 +1277,12 @@ bad: break; } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_ret(p, code, error, rval); - KERNEL_UNLOCK(); #endif userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, code, error, rval[0]); - KERNEL_UNLOCK(); } #endif } @@ -1368,24 +1352,18 @@ m88110_syscall(register_t code, struct trapframe *tf) goto bad; #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_call(p, code, args); - KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - KERNEL_LOCK(); ktrsyscall(p, code, callp->sy_argsize, args); - KERNEL_UNLOCK(); } #endif rval[0] = 0; rval[1] = tf->tf_r[3]; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - KERNEL_LOCK(); error = systrace_redirect(code, p, args, rval); - KERNEL_UNLOCK(); } else #endif { @@ -1456,16 +1434,12 @@ bad: } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_ret(p, code, error, rval); - KERNEL_UNLOCK(); #endif userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, code, error, rval[0]); - KERNEL_UNLOCK(); } #endif } @@ -1506,12 +1480,10 @@ child_return(arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, (p->p_flag & P_THREAD) ? SYS_rfork : (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); - KERNEL_UNLOCK(); } #endif } diff --git a/sys/arch/mips64/mips64/fp_emulate.c b/sys/arch/mips64/mips64/fp_emulate.c index f23f883a3e2..8daad01d48c 100644 --- a/sys/arch/mips64/mips64/fp_emulate.c +++ b/sys/arch/mips64/mips64/fp_emulate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fp_emulate.c,v 1.4 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: fp_emulate.c,v 1.5 2011/07/07 18:11:24 art Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -385,9 +385,7 @@ deliver: if (sig != SIGBUS && sig != SIGSEGV) #endif sv.sival_ptr = (void *)pc; - KERNEL_LOCK(); trapsignal(p, sig, 0, fault_type, sv); - KERNEL_UNLOCK(); } } diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c index d7fb139f748..88e2e89dad4 100644 --- a/sys/arch/mips64/mips64/trap.c +++ b/sys/arch/mips64/mips64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.74 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: trap.c,v 1.75 2011/07/07 18:11:24 art Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -166,9 +166,7 @@ ast() p->p_md.md_astpending = 0; if (p->p_flag & P_OWEUPC) { - KERNEL_LOCK(); ADDUPROF(p); - KERNEL_UNLOCK(); } if (ci->ci_want_resched) preempt(NULL); @@ -498,15 +496,11 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr } } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_call(p, code, args.i); - KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - KERNEL_LOCK(); ktrsyscall(p, code, callp->sy_argsize, args.i); - KERNEL_UNLOCK(); } #endif rval[0] = 0; @@ -518,9 +512,7 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - KERNEL_LOCK(); i = systrace_redirect(code, p, args.i, rval); - KERNEL_UNLOCK(); } else #endif { @@ -550,15 +542,11 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr locr0->a3 = 1; } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_ret(p, code, i, rval); - KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, code, i, rval[0]); - KERNEL_UNLOCK(); } #endif goto out; @@ -804,9 +792,7 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr p->p_md.md_regs->cause = trapframe->cause; p->p_md.md_regs->badvaddr = trapframe->badvaddr; sv.sival_ptr = (void *)trapframe->badvaddr; - KERNEL_LOCK(); trapsignal(p, i, ucode, typ, sv); - KERNEL_UNLOCK(); out: /* * Note: we should only get here if returning to user mode. @@ -832,12 +818,10 @@ child_return(arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, (p->p_flag & P_THREAD) ? SYS_rfork : (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); - KERNEL_UNLOCK(); } #endif } diff --git a/sys/arch/powerpc/powerpc/trap.c b/sys/arch/powerpc/powerpc/trap.c index 7153267bbe3..a37d7452668 100644 --- a/sys/arch/powerpc/powerpc/trap.c +++ b/sys/arch/powerpc/powerpc/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.85 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: trap.c,v 1.86 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: trap.c,v 1.3 1996/10/13 03:31:37 christos Exp $ */ /* @@ -275,9 +275,7 @@ trap(struct trapframe *frame) case EXC_TRC|EXC_USER: { sv.sival_int = frame->srr0; - KERNEL_LOCK(); trapsignal(p, SIGTRAP, type, TRAP_TRACE, sv); - KERNEL_UNLOCK(); } break; @@ -402,9 +400,7 @@ printf("isi iar %x lr %x\n", frame->srr0, frame->lr); /* XXX Likely that returning from this trap is bogus... */ /* XXX Have to make sure that sigreturn does the right thing. */ sv.sival_int = frame->srr0; - KERNEL_LOCK(); trapsignal(p, SIGSEGV, VM_PROT_EXECUTE, SEGV_MAPERR, sv); - KERNEL_UNLOCK(); break; case EXC_SC|EXC_USER: { @@ -470,27 +466,21 @@ printf("isi iar %x lr %x\n", frame->srr0, frame->lr); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - KERNEL_LOCK(); ktrsyscall(p, code, argsize, params); - KERNEL_UNLOCK(); } #endif rval[0] = 0; rval[1] = frame->fixreg[FIRSTARG + 1]; #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_call(p, code, params); - KERNEL_UNLOCK(); #endif #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - KERNEL_LOCK(); error = systrace_redirect(code, p, params, rval); - KERNEL_UNLOCK(); } else #endif { @@ -528,15 +518,11 @@ syscall_bad: break; } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_ret(p, code, error, rval); - KERNEL_UNLOCK(); #endif #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, code, error, rval[0]); - KERNEL_UNLOCK(); } #endif } @@ -559,10 +545,8 @@ syscall_bad: frame->srr0 += 4; else { sv.sival_int = frame->srr0; - KERNEL_LOCK(); trapsignal(p, SIGSEGV, VM_PROT_EXECUTE, SEGV_MAPERR, sv); - KERNEL_UNLOCK(); } break; @@ -616,9 +600,7 @@ mpc_print_pci_stat(); errnum++; #endif sv.sival_int = frame->srr0; - KERNEL_LOCK(); trapsignal(p, SIGTRAP, type, TRAP_BRKPT, sv); - KERNEL_UNLOCK(); break; } #if 0 @@ -637,9 +619,7 @@ for (i = 0; i < errnum; i++) { } #endif sv.sival_int = frame->srr0; - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); - KERNEL_UNLOCK(); break; } case EXC_PGM: @@ -667,25 +647,19 @@ for (i = 0; i < errnum; i++) { break; #else /* ALTIVEC */ sv.sival_int = frame->srr0; - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); - KERNEL_UNLOCK(); break; #endif case EXC_VECAST|EXC_USER: - KERNEL_LOCK(); trapsignal(p, SIGFPE, 0, FPE_FLTRES, sv); - KERNEL_UNLOCK(); break; case EXC_AST|EXC_USER: uvmexp.softs++; p->p_md.md_astpending = 0; /* we are about to do it */ if (p->p_flag & P_OWEUPC) { - KERNEL_LOCK(); ADDUPROF(p); - KERNEL_UNLOCK(); } if (ci->ci_want_resched) preempt(NULL); @@ -732,12 +706,10 @@ child_return(void *arg) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, (p->p_flag & P_THREAD) ? SYS_rfork : (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); - KERNEL_UNLOCK(); } #endif } diff --git a/sys/arch/sparc64/fpu/fpu.c b/sys/arch/sparc64/fpu/fpu.c index 6c524414a0a..82ecd01693f 100644 --- a/sys/arch/sparc64/fpu/fpu.c +++ b/sys/arch/sparc64/fpu/fpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpu.c,v 1.15 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: fpu.c,v 1.16 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: fpu.c,v 1.11 2000/12/06 01:47:50 mrg Exp $ */ /* @@ -214,9 +214,7 @@ fpu_cleanup(p, fs) case FSR_TT_IEEE: if ((i = fsr & FSR_CX) == 0) panic("fpu ieee trap, but no exception"); - KERNEL_LOCK(); trapsignal(p, SIGFPE, fpu_codes[i - 1], fpu_types[i - 1], sv); - KERNEL_UNLOCK(); break; /* XXX should return, but queue remains */ case FSR_TT_UNFIN: @@ -239,9 +237,7 @@ fpu_cleanup(p, fs) log(LOG_ERR, "fpu hardware error (%s[%d])\n", p->p_comm, p->p_pid); uprintf("%s[%d]: fpu hardware error\n", p->p_comm, p->p_pid); - KERNEL_LOCK(); trapsignal(p, SIGFPE, -1, FPE_FLTINV, sv); /* ??? */ - KERNEL_UNLOCK(); goto out; default: @@ -264,17 +260,13 @@ fpu_cleanup(p, fs) continue; case FPE: - KERNEL_LOCK(); trapsignal(p, SIGFPE, fpu_codes[(fs->fs_fsr & FSR_CX) - 1], fpu_types[(fs->fs_fsr & FSR_CX) - 1], sv); - KERNEL_UNLOCK(); break; case NOTFPU: - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_COPROC, sv); - KERNEL_UNLOCK(); break; default: diff --git a/sys/arch/sparc64/sparc64/emul.c b/sys/arch/sparc64/sparc64/emul.c index 2e18cac3518..d83f2737586 100644 --- a/sys/arch/sparc64/sparc64/emul.c +++ b/sys/arch/sparc64/sparc64/emul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: emul.c,v 1.20 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: emul.c,v 1.21 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: emul.c,v 1.8 2001/06/29 23:58:40 eeh Exp $ */ /*- @@ -333,9 +333,7 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf) if (asi < ASI_PRIMARY) { /* privileged asi */ - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_PRVOPC, sv); - KERNEL_UNLOCK(); return (0); } if (asi > ASI_SECONDARY_NOFAULT_LITTLE || @@ -346,17 +344,13 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf) if ((freg & 3) != 0) { /* only valid for %fN where N % 4 = 0 */ - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPN, sv); - KERNEL_UNLOCK(); return (0); } if ((addr & 3) != 0) { /* request is not aligned */ - KERNEL_LOCK(); trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); - KERNEL_UNLOCK(); return (0); } @@ -393,10 +387,8 @@ emul_qf(int32_t insv, struct proc *p, union sigval sv, struct trapframe *tf) return (1); segv: - KERNEL_LOCK(); trapsignal(p, SIGSEGV, isload ? VM_PROT_READ : VM_PROT_WRITE, SEGV_MAPERR, sv); - KERNEL_UNLOCK(); return (0); } diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c index 57472c808a1..2c1dbce8386 100644 --- a/sys/arch/sparc64/sparc64/trap.c +++ b/sys/arch/sparc64/sparc64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.71 2011/07/06 22:26:44 kettenis Exp $ */ +/* $OpenBSD: trap.c,v 1.72 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */ /* @@ -466,17 +466,13 @@ dopanic: pc, (long)tf->tf_npc, pstate, PSTATE_BITS); /* NOTREACHED */ } - KERNEL_LOCK(); trapsignal(p, SIGILL, type, ILL_ILLOPC, sv); - KERNEL_UNLOCK(); break; case T_AST: p->p_md.md_astpending = 0; if (p->p_flag & P_OWEUPC) { - KERNEL_LOCK(); ADDUPROF(p); - KERNEL_UNLOCK(); } if (curcpu()->ci_want_resched) preempt(NULL); @@ -493,9 +489,7 @@ dopanic: */ write_user_windows(); if (rwindow_save(p) == -1) { - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_BADSTK, sv); - KERNEL_UNLOCK(); } break; @@ -505,9 +499,7 @@ dopanic: if (copyin((caddr_t)pc, &ins, sizeof(ins)) != 0) { /* XXX Can this happen? */ - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); - KERNEL_UNLOCK(); break; } if (ins.i_any.i_op == IOP_mem && @@ -526,9 +518,7 @@ dopanic: ADVANCE; break; } - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); /* XXX code? */ - KERNEL_UNLOCK(); break; } @@ -536,9 +526,7 @@ dopanic: case T_TEXTFAULT: case T_PRIVINST: case T_PRIVACT: - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); /* XXX code? */ - KERNEL_UNLOCK(); break; case T_FPDISABLED: { @@ -589,9 +577,7 @@ dopanic: if (copyin((caddr_t)pc, &ins, sizeof(ins)) != 0) { /* XXX Can this happen? */ - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); - KERNEL_UNLOCK(); break; } if (ins.i_any.i_op == IOP_mem && @@ -602,9 +588,7 @@ dopanic: if (emul_qf(ins.i_int, p, sv, tf)) ADVANCE; } else { - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); - KERNEL_UNLOCK(); } break; } @@ -647,9 +631,7 @@ dopanic: } /* XXX sv.sival_ptr should be the fault address! */ - KERNEL_LOCK(); trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); /* XXX code? */ - KERNEL_UNLOCK(); break; case T_FP_IEEE_754: @@ -684,22 +666,16 @@ dopanic: break; case T_TAGOF: - KERNEL_LOCK(); trapsignal(p, SIGEMT, 0, EMT_TAGOVF, sv); /* XXX code? */ - KERNEL_UNLOCK(); break; case T_BREAKPOINT: - KERNEL_LOCK(); trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv); - KERNEL_UNLOCK(); break; case T_DIV0: ADVANCE; - KERNEL_LOCK(); trapsignal(p, SIGFPE, 0, FPE_INTDIV, sv); - KERNEL_UNLOCK(); break; case T_CLEANWIN: @@ -715,25 +691,19 @@ dopanic: case T_RANGECHECK: ADVANCE; - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPN, sv); /* XXX code? */ - KERNEL_UNLOCK(); break; case T_FIXALIGN: uprintf("T_FIXALIGN\n"); ADVANCE; - KERNEL_LOCK(); trapsignal(p, SIGILL, 0, ILL_ILLOPN, sv); /* XXX code? */ - KERNEL_UNLOCK(); break; case T_INTOF: uprintf("T_INTOF\n"); /* XXX */ ADVANCE; - KERNEL_LOCK(); trapsignal(p, SIGFPE, FPE_INTOVF_TRAP, FPE_INTOVF, sv); - KERNEL_UNLOCK(); break; } userret(p); @@ -1001,9 +971,7 @@ data_access_error(tf, type, afva, afsr, sfva, sfsr) return; } - KERNEL_LOCK(); trapsignal(p, SIGSEGV, VM_PROT_READ|VM_PROT_WRITE, SEGV_MAPERR, sv); - KERNEL_UNLOCK(); out: if ((tstate & TSTATE_PRIV) == 0) { @@ -1140,9 +1108,7 @@ text_access_error(tf, type, pc, sfsr, afva, afsr) panic("text_access_error: kernel memory error"); /* User fault -- Berr */ - KERNEL_LOCK(); trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); - KERNEL_UNLOCK(); } if ((sfsr & SFSR_FV) == 0 || (sfsr & SFSR_FT) == 0) @@ -1326,9 +1292,7 @@ syscall(tf, code, pc) #ifdef KTRACE if (KTRPOINT(p, KTR_SYSCALL)) { - KERNEL_LOCK(); ktrsyscall(p, code, callp->sy_argsize, args); - KERNEL_UNLOCK(); } #endif if (error) @@ -1339,17 +1303,13 @@ syscall(tf, code, pc) } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_call(p, code, args); - KERNEL_UNLOCK(); #endif rval[0] = 0; rval[1] = tf->tf_out[1]; #if NSYSTRACE > 0 if (ISSET(p->p_flag, P_SYSTRACE)) { - KERNEL_LOCK(); error = systrace_redirect(code, p, args, rval); - KERNEL_UNLOCK(); } else #endif { @@ -1399,16 +1359,12 @@ syscall(tf, code, pc) } #ifdef SYSCALL_DEBUG - KERNEL_LOCK(); scdebug_ret(p, code, error, rval); - KERNEL_UNLOCK(); #endif userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, code, error, rval[0]); - KERNEL_UNLOCK(); } #endif share_fpu(p, tf); @@ -1436,12 +1392,10 @@ child_return(arg) userret(p); #ifdef KTRACE if (KTRPOINT(p, KTR_SYSRET)) { - KERNEL_LOCK(); ktrsysret(p, (p->p_flag & P_THREAD) ? SYS_rfork : (p->p_p->ps_flags & PS_PPWAIT) ? SYS_vfork : SYS_fork, 0, 0); - KERNEL_UNLOCK(); } #endif } diff --git a/sys/dev/systrace.c b/sys/dev/systrace.c index 41973126df4..30edad61778 100644 --- a/sys/dev/systrace.c +++ b/sys/dev/systrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace.c,v 1.57 2011/06/24 22:48:36 djm Exp $ */ +/* $OpenBSD: systrace.c,v 1.58 2011/07/07 18:11:24 art Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -664,15 +664,18 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) gid_t oldgid; int policy, error = 0, report = 0, maycontrol = 0, issuser = 0; + KERNEL_LOCK(); systrace_lock(); strp = p->p_systrace; if (strp == NULL) { systrace_unlock(); + KERNEL_UNLOCK(); return (EINVAL); } if (code < 0 || code >= p->p_emul->e_nsysent) { systrace_unlock(); + KERNEL_UNLOCK(); return (EINVAL); } @@ -732,6 +735,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) psignal(p, SIGKILL); } else if (policy == SYSTR_POLICY_PERMIT) error = (*callp->sy_call)(p, v, retval); + KERNEL_UNLOCK(); return (error); } @@ -747,13 +751,16 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) error = systrace_msg_ask(fst, strp, code, callp->sy_argsize, v); /* lock has been released in systrace_msg_ask() */ - if (error) + if (error) { + KERNEL_UNLOCK(); return (error); + } /* We might have detached by now for some reason */ systrace_lock(); if ((strp = p->p_systrace) == NULL) { systrace_unlock(); + KERNEL_UNLOCK(); return (error); } @@ -801,6 +808,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) systrace_lock(); if ((strp = p->p_systrace) == NULL) { systrace_unlock(); + KERNEL_UNLOCK(); return (error); } @@ -822,6 +830,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) if (ISSET(p->p_p->ps_flags, PS_SUGID | PS_SUGIDEXEC)) { if ((fst = strp->parent) == NULL || !fst->issuser) { systrace_unlock(); + KERNEL_UNLOCK(); return (error); } } @@ -870,6 +879,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) out_unlock: rw_exit_write(&fst->lock); out: + KERNEL_UNLOCK(); return (error); } diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index f3df06a9368..4ca73fced3c 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.51 2011/06/02 16:29:20 deraadt Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.52 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -100,6 +100,7 @@ ktrsyscall(struct proc *p, register_t code, size_t argsize, register_t args[]) u_int nargs = 0; int i; + KERNEL_LOCK(); if (code == SYS___sysctl && (p->p_emul->e_flags & EMUL_NATIVE)) { /* * The native sysctl encoding stores the mib[] @@ -126,6 +127,7 @@ ktrsyscall(struct proc *p, register_t code, size_t argsize, register_t args[]) ktrwrite(p, &kth); free(ktp, M_TEMP); p->p_traceflag &= ~KTRFAC_ACTIVE; + KERNEL_UNLOCK(); } void @@ -134,6 +136,8 @@ ktrsysret(struct proc *p, register_t code, int error, register_t retval) struct ktr_header kth; struct ktr_sysret ktp; + KERNEL_LOCK(); + p->p_traceflag |= KTRFAC_ACTIVE; ktrinitheader(&kth, p, KTR_SYSRET); ktp.ktr_code = code; @@ -145,6 +149,7 @@ ktrsysret(struct proc *p, register_t code, int error, register_t retval) ktrwrite(p, &kth); p->p_traceflag &= ~KTRFAC_ACTIVE; + KERNEL_UNLOCK(); } void diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 4d747c2f826..c0b5f18dc3f 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.123 2011/07/06 21:41:37 art Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.124 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -726,9 +726,11 @@ void trapsignal(struct proc *p, int signum, u_long code, int type, union sigval sigval) { - struct sigacts *ps = p->p_sigacts; + struct sigacts *ps; int mask; + KERNEL_LOCK(); + ps = p->p_sigacts; mask = sigmask(signum); if ((p->p_flag & P_TRACED) == 0 && (ps->ps_sigcatch & mask) != 0 && (p->p_sigmask & mask) == 0) { @@ -758,6 +760,7 @@ trapsignal(struct proc *p, int signum, u_long code, int type, p->p_sigval = sigval; ptsignal(p, signum, STHREAD); } + KERNEL_UNLOCK(); } /* diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c index 41166b3e20c..c694d2662da 100644 --- a/sys/kern/kern_xxx.c +++ b/sys/kern/kern_xxx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_xxx.c,v 1.19 2011/06/26 22:40:00 deraadt Exp $ */ +/* $OpenBSD: kern_xxx.c,v 1.20 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: kern_xxx.c,v 1.32 1996/04/22 01:38:41 christos Exp $ */ /* @@ -109,11 +109,12 @@ scdebug_call(struct proc *p, register_t code, register_t args[]) if (!(scdebug & SCDEBUG_CALLS)) return; + KERNEL_LOCK(); em = p->p_emul; sy = &em->e_sysent[code]; if (!(scdebug & SCDEBUG_ALL || code < 0 || code >= em->e_nsysent || sy->sy_call == sys_nosys)) - return; + goto out; printf("proc %d (%s): %s num ", p->p_pid, p->p_comm, em->e_name); if (code < 0 || code >= em->e_nsysent) @@ -130,6 +131,8 @@ scdebug_call(struct proc *p, register_t code, register_t args[]) } } printf("\n"); +out: + KERNEL_UNLOCK(); } void @@ -141,11 +144,12 @@ scdebug_ret(struct proc *p, register_t code, int error, register_t retval[]) if (!(scdebug & SCDEBUG_RETURNS)) return; + KERNEL_LOCK(); em = p->p_emul; sy = &em->e_sysent[code]; if (!(scdebug & SCDEBUG_ALL || code < 0 || code >= em->e_nsysent || sy->sy_call == sys_nosys)) - return; + goto out; printf("proc %d (%s): %s num ", p->p_pid, p->p_comm, em->e_name); if (code < 0 || code >= em->e_nsysent) @@ -154,5 +158,7 @@ scdebug_ret(struct proc *p, register_t code, int error, register_t retval[]) printf("%d ret: err = %d, rv = 0x%lx,0x%lx", code, error, (long)retval[0], (long)retval[1]); printf("\n"); +out: + KERNEL_UNLOCK(); } #endif /* SYSCALL_DEBUG */ diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h index e1c636d6a82..76a93587a62 100644 --- a/sys/sys/resourcevar.h +++ b/sys/sys/resourcevar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: resourcevar.h,v 1.12 2010/06/29 20:14:46 guenther Exp $ */ +/* $OpenBSD: resourcevar.h,v 1.13 2011/07/07 18:11:24 art Exp $ */ /* $NetBSD: resourcevar.h,v 1.12 1995/11/22 23:01:53 cgd Exp $ */ /* @@ -76,10 +76,12 @@ struct plimit { /* add user profiling from AST */ #define ADDUPROF(p) \ do { \ + KERNEL_LOCK(); \ atomic_clearbits_int(&(p)->p_flag, P_OWEUPC); \ addupc_task((p), (p)->p_stats->p_prof.pr_addr, \ (p)->p_stats->p_prof.pr_ticks); \ (p)->p_stats->p_prof.pr_ticks = 0; \ + KERNEL_UNLOCK(); \ } while (0) #ifdef _KERNEL |