Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Enhance the signal routing of a trapsignal under a ...



details:   https://anonhg.NetBSD.org/src/rev/b8a6f7a710ac
branches:  trunk
changeset: 319369:b8a6f7a710ac
user:      kamil <kamil%NetBSD.org@localhost>
date:      Mon May 28 13:12:54 2018 +0000

description:
Enhance the signal routing of a trapsignal under a debugger

Stop resetting signal masks for crash signals under a debugger.

If we set a trap (either software or hardware one) in the code, we don't
want to see reset of signal handlers in a traced child as a knock-on effect
in the original code.

Maintain the vfork(2) + ptrace(2) special case functional.

No regressions are observed in ATF ptrace(2) and kernel/t_trapsignal tests.

Sponsored by <The NetBSD Foundation>

diffstat:

 sys/kern/kern_sig.c |  19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r fbadd7025cd3 -r b8a6f7a710ac sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Mon May 28 12:42:45 2018 +0000
+++ b/sys/kern/kern_sig.c       Mon May 28 13:12:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.347 2018/05/20 04:00:35 kamil Exp $     */
+/*     $NetBSD: kern_sig.c,v 1.348 2018/05/28 13:12:54 kamil Exp $     */
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.347 2018/05/20 04:00:35 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.348 2018/05/28 13:12:54 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -904,13 +904,24 @@
        KASSERT(!cpu_intr_p());
        mutex_enter(proc_lock);
        mutex_enter(p->p_lock);
+
+       if (ISSET(p->p_slflag, PSL_TRACED) && (p->p_pptr != p->p_opptr)) {
+               p->p_xsig = signo;
+               p->p_sigctx.ps_faked = true; // XXX
+               p->p_sigctx.ps_info._signo = signo;
+               p->p_sigctx.ps_info._code = ksi->ksi_code;
+               sigswitch(0, signo, false);
+               // XXX ktrpoint(KTR_PSIG)
+               mutex_exit(p->p_lock);
+               return;
+       }
+
        mask = &l->l_sigmask;
        ps = p->p_sigacts;
 
-       const bool traced = (p->p_slflag & PSL_TRACED) != 0;
        const bool caught = sigismember(&p->p_sigctx.ps_sigcatch, signo);
        const bool masked = sigismember(mask, signo);
-       if (!traced && caught && !masked) {
+       if (caught && !masked) {
                mutex_exit(proc_lock);
                l->l_ru.ru_nsignals++;
                kpsendsig(l, ksi, mask);



Home | Main Index | Thread Index | Old Index