Source-Changes-HG archive

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

[src/trunk]: src/sys/kern child_return():



details:   https://anonhg.NetBSD.org/src/rev/f13b8ee56f21
branches:  trunk
changeset: 969798:f13b8ee56f21
user:      ad <ad%NetBSD.org@localhost>
date:      Sun Mar 01 21:37:26 2020 +0000

description:
child_return():

- This was assuming arg == curlwp, but NULL is passed to lwp_create(), as
  evidenced by a random panic during testing.  How did this ever work?

- Replace a goto.

diffstat:

 sys/kern/kern_fork.c |  21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diffs (49 lines):

diff -r 0bf8226ebab4 -r f13b8ee56f21 sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c      Sun Mar 01 20:59:52 2020 +0000
+++ b/sys/kern/kern_fork.c      Sun Mar 01 21:37:26 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_fork.c,v 1.218 2020/01/29 15:47:52 ad Exp $       */
+/*     $NetBSD: kern_fork.c,v 1.219 2020/03/01 21:37:26 ad Exp $       */
 
 /*-
  * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008, 2019
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.218 2020/01/29 15:47:52 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.219 2020/03/01 21:37:26 ad Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -627,23 +627,20 @@
 void
 child_return(void *arg)
 {
-       struct lwp *l = arg;
+       struct lwp *l = curlwp;
        struct proc *p = l->l_proc;
 
-       if (p->p_slflag & PSL_TRACED) {
+       if ((p->p_slflag & PSL_TRACED) != 0) {
                /* Paranoid check */
                mutex_enter(proc_lock);
-               if (!(p->p_slflag & PSL_TRACED)) {
+               if ((p->p_slflag & PSL_TRACED) != 0) {
+                       mutex_enter(p->p_lock);
+                       eventswitch(TRAP_CHLD, ISSET(p->p_lflag, PL_PPWAIT) ?
+                           PTRACE_VFORK : PTRACE_FORK, p->p_opptr->p_pid);
+               } else
                        mutex_exit(proc_lock);
-                       goto my_tracer_is_gone;
-               }
-               mutex_enter(p->p_lock);
-               eventswitch(TRAP_CHLD,
-                   ISSET(p->p_lflag, PL_PPWAIT) ? PTRACE_VFORK : PTRACE_FORK,
-                   p->p_opptr->p_pid);
        }
 
-my_tracer_is_gone:
        md_child_return(l);
 
        /*



Home | Main Index | Thread Index | Old Index