From 728f699c4591bb13d48d44d1f3534b13b03c579d Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Wed, 22 Jul 2015 05:32:45 +0000 Subject: Slam signal handlers harder in tame_fail(), found by semarie. Also delete some prototype KTRACE code which is not headed in the right direction. --- sys/kern/kern_tame.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'sys/kern/kern_tame.c') diff --git a/sys/kern/kern_tame.c b/sys/kern/kern_tame.c index 4485efce57f..9751b130c32 100644 --- a/sys/kern/kern_tame.c +++ b/sys/kern/kern_tame.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_tame.c,v 1.12 2015/07/21 16:17:17 guenther Exp $ */ +/* $OpenBSD: kern_tame.c,v 1.13 2015/07/22 05:32:44 deraadt Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -41,6 +41,7 @@ #include +#include #include #include #include @@ -247,25 +248,13 @@ tame_fail(struct proc *p, int error, int code) { printf("tame: pid %d %s syscall %d\n", p->p_pid, p->p_comm, p->p_tame_syscall); -#ifdef KTRACE - if (KTRPOINT(p, KTR_PSIG)) { - siginfo_t si; - - memset(&si, 0, sizeof(si)); - if (p->p_p->ps_tame & _TM_ABORT) - si.si_signo = SIGABRT; - else - si.si_signo = SIGKILL; - si.si_code = code; - // si.si_syscall = p->p_tame_syscall; - /// si.si_nsysarg ... - ktrpsig(p, si.si_signo, SIG_DFL, p->p_sigmask, code, &si); - } -#endif - if (p->p_p->ps_tame & _TM_ABORT) { - /* Core dump requested */ - atomic_clearbits_int(&p->p_sigmask, sigmask(SIGABRT)); - atomic_clearbits_int(&p->p_p->ps_flags, PS_TAMED); + if (p->p_p->ps_tame & _TM_ABORT) { /* Core dump requested */ + struct sigaction sa; + + p->p_p->ps_tame = 0; /* Disable all TAME_ flags */ + memset(&sa, 0, sizeof sa); + sa.sa_handler = SIG_DFL; + setsigvec(p, SIGABRT, &sa); psignal(p, SIGABRT); } else psignal(p, SIGKILL); -- cgit v1.2.3