summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2014-06-21 20:58:30 +0000
committerguenther <guenther@openbsd.org>2014-06-21 20:58:30 +0000
commit79de137a5b69a1a906a99975f4aeefa7cd223b1a (patch)
tree2052b80cd2983767a35f1694dc3acd2681461567
parentalways compare memcmp against 0, for clarity. (diff)
downloadwireguard-openbsd-79de137a5b69a1a906a99975f4aeefa7cd223b1a.tar.xz
wireguard-openbsd-79de137a5b69a1a906a99975f4aeefa7cd223b1a.zip
If the kernel generates a deadly trap signal (SEGV, BUS, etc) for
an untraced process but finds it blocking or ignoring it, just kill the process instead of looping. It's undefined behavor in POSIX but quite annoying when encountered in practice. improvements from kettenis@ ok matthew@
-rw-r--r--sys/kern/kern_sig.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 0c15c8e1477..d1bc53bf39c 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.166 2014/05/04 05:03:26 guenther Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.167 2014/06/21 20:58:30 guenther Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -761,6 +761,17 @@ trapsignal(struct proc *p, int signum, u_long trapno, int code,
p->p_sitrapno = trapno; /* XXX for core dump/debugger */
p->p_sicode = code;
p->p_sigval = sigval;
+
+ /*
+ * Signals like SIGBUS and SIGSEGV should not, when
+ * generated by the kernel, be ignorable or blockable.
+ * If it is and we're not being traced, then just kill
+ * the process.
+ */
+ if ((pr->ps_flags & PS_TRACED) == 0 &&
+ (sigprop[signum] & SA_KILL) &&
+ ((p->p_sigmask & mask) || (ps->ps_sigignore & mask)))
+ sigexit(p, signum);
ptsignal(p, signum, STHREAD);
}
}