Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Correct reporting SIGTRAP TRAP_EXEC when SIGTRAP is...



details:   https://anonhg.NetBSD.org/src/rev/db8ea1b3d875
branches:  trunk
changeset: 323007:db8ea1b3d875
user:      kamil <kamil%NetBSD.org@localhost>
date:      Mon May 28 11:32:20 2018 +0000

description:
Correct reporting SIGTRAP TRAP_EXEC when SIGTRAP is masked

Switch from kpsignal(9) to sigswitch() as it allows to bypass signal
masking rules of a crash signal.

There are no regressions in existing tests.

Sponsored by <The NetBSD Foundation>

diffstat:

 sys/kern/kern_exec.c |  20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diffs (41 lines):

diff -r 8e8661fd0867 -r db8ea1b3d875 sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Mon May 28 11:15:48 2018 +0000
+++ b/sys/kern/kern_exec.c      Mon May 28 11:32:20 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exec.c,v 1.458 2018/05/06 13:40:51 kamil Exp $    */
+/*     $NetBSD: kern_exec.c,v 1.459 2018/05/28 11:32:20 kamil Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.458 2018/05/06 13:40:51 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.459 2018/05/28 11:32:20 kamil Exp $");
 
 #include "opt_exec.h"
 #include "opt_execfmt.h"
@@ -1269,13 +1269,15 @@
        mutex_enter(proc_lock);
 
        if ((p->p_slflag & (PSL_TRACED|PSL_SYSCALL)) == PSL_TRACED) {
-               ksiginfo_t ksi;
-
-               KSI_INIT_EMPTY(&ksi);
-               ksi.ksi_signo = SIGTRAP;
-               ksi.ksi_code = TRAP_EXEC;
-               ksi.ksi_lid = l->l_lid;
-               kpsignal(p, &ksi, NULL);
+               mutex_enter(p->p_lock);
+               p->p_xsig = SIGTRAP;
+               p->p_sigctx.ps_faked = true; // XXX
+               p->p_sigctx.ps_info._signo = p->p_xsig;
+               p->p_sigctx.ps_info._code = TRAP_EXEC;
+               sigswitch(0, SIGTRAP, false);
+               // XXX ktrpoint(KTR_PSIG)
+               mutex_exit(p->p_lock);
+               mutex_enter(proc_lock);
        }
 
        if (p->p_sflag & PS_STOPEXEC) {



Home | Main Index | Thread Index | Old Index