Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Stop resetting signal context on a trap signal unde...
details: https://anonhg.NetBSD.org/src/rev/4d444c11ba1d
branches: trunk
changeset: 997462:4d444c11ba1d
user: kamil <kamil%NetBSD.org@localhost>
date: Fri Mar 08 23:32:30 2019 +0000
description:
Stop resetting signal context on a trap signal under a debugger
In case of a crash signal, notify debugger immediately passing the signal
regardless of signal masking/ignoring.
While there pass signals emitted by a debugger to debuggee. Debugger calls
proc_unstop() that sets p_stat to SACTIVE and this signal wasn't passed
to tracee.
This scenario appeared to be triggered in recently added crash signal ATF
ptrace(2) tests.
diffstat:
sys/kern/kern_sig.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diffs (57 lines):
diff -r 103ec9eda2ad -r 4d444c11ba1d sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c Fri Mar 08 23:10:52 2019 +0000
+++ b/sys/kern/kern_sig.c Fri Mar 08 23:32:30 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig.c,v 1.350 2018/11/29 10:27:36 maxv Exp $ */
+/* $NetBSD: kern_sig.c,v 1.351 2019/03/08 23:32:30 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.350 2018/11/29 10:27:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.351 2019/03/08 23:32:30 kamil Exp $");
#include "opt_ptrace.h"
#include "opt_dtrace.h"
@@ -911,13 +911,25 @@
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 && ISSET(p->p_lflag, PL_PPWAIT))) {
+ 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);
@@ -1678,7 +1690,9 @@
if (p->p_stat == SSTOP || (p->p_sflag & PS_STOPPING) != 0) {
sigswitch(PS_NOCLDSTOP, 0, true);
signo = sigchecktrace();
- } else
+ } else if (p->p_stat == SACTIVE)
+ signo = sigchecktrace();
+ else
signo = 0;
/* Signals from the debugger are "out of band". */
Home |
Main Index |
Thread Index |
Old Index