Module Name: src Committed By: kamil Date: Mon May 28 11:32:20 UTC 2018
Modified Files: src/sys/kern: kern_exec.c Log Message: 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> To generate a diff of this commit: cvs rdiff -u -r1.458 -r1.459 src/sys/kern/kern_exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.458 src/sys/kern/kern_exec.c:1.459 --- src/sys/kern/kern_exec.c:1.458 Sun May 6 13:40:51 2018 +++ src/sys/kern/kern_exec.c Mon May 28 11:32:20 2018 @@ -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 @@ execve_runproc(struct lwp *l, struct exe 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) {