Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 If the process is traced, resulting from a ...



details:   https://anonhg.NetBSD.org/src/rev/50a105fe9f00
branches:  trunk
changeset: 769188:50a105fe9f00
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Sep 02 20:01:20 2011 +0000

description:
If the process is traced, resulting from a PTRACE_FORK inherited setting,
stop it right now.

XXX[1]: Cannot make this MI, because I cannot wrap child_return because there
is MD code that checks fun == child_return. I think it is better to have an
mi child_return() and add a cpu_child_return()?
XXX[2]: Why do we need to stop so early? Perhaps stopping just after exec
is better?

diffstat:

 sys/arch/x86/x86/syscall.c |  16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diffs (37 lines):

diff -r c8c9ed7ad810 -r 50a105fe9f00 sys/arch/x86/x86/syscall.c
--- a/sys/arch/x86/x86/syscall.c        Fri Sep 02 16:26:21 2011 +0000
+++ b/sys/arch/x86/x86/syscall.c        Fri Sep 02 20:01:20 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.3 2009/11/21 03:11:02 rmind Exp $        */
+/*     $NetBSD: syscall.c,v 1.4 2011/09/02 20:01:20 christos Exp $     */
 
 /*-
  * Copyright (c) 1998, 2000, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.3 2009/11/21 03:11:02 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.4 2011/09/02 20:01:20 christos Exp $");
 
 #include "opt_sa.h"
 
@@ -67,6 +67,18 @@
 {
        struct lwp *l = arg;
        struct trapframe *tf = l->l_md.md_regs;
+       struct proc *p = l->l_proc;
+
+       if (p->p_slflag & PSL_TRACED) {
+               ksiginfo_t ksi;
+
+               mutex_enter(proc_lock);
+                KSI_INIT_EMPTY(&ksi);
+                ksi.ksi_signo = SIGTRAP;
+                ksi.ksi_lid = l->l_lid; 
+                kpsignal(p, &ksi, NULL);
+               mutex_exit(proc_lock);
+       }
 
        X86_TF_RAX(tf) = 0;
        X86_TF_RFLAGS(tf) &= ~PSL_C;



Home | Main Index | Thread Index | Old Index