Source-Changes-HG archive

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

[src/netbsd-1-6]: src/sys/kern Pull up revision 1.95 (requested by jdolocek i...



details:   https://anonhg.NetBSD.org/src/rev/82f979683efe
branches:  netbsd-1-6
changeset: 528638:82f979683efe
user:      lukem <lukem%NetBSD.org@localhost>
date:      Mon Jul 29 15:37:28 2002 +0000

description:
Pull up revision 1.95 (requested by jdolocek in ticket #557):
Make sure that the pointer to old parent process for ptraced children
gets reset properly when the old parent exits before the child. A flag
is set in old parent process when the child is reparented in ptrace(2).
If it's set when process is exiting, all running processes have their
'old parent process' pointer checked and reset if appropriate. Also
change to use 'struct proc *' pointer directly, rather than pid_t.
This fixes security/14444 by David Sainty.
Reviewed by Christos Zoulas.

diffstat:

 sys/kern/kern_exit.c |  32 ++++++++++++++++++++++++++------
 1 files changed, 26 insertions(+), 6 deletions(-)

diffs (61 lines):

diff -r 69b23ead68c0 -r 82f979683efe sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Mon Jul 29 15:37:12 2002 +0000
+++ b/sys/kern/kern_exit.c      Mon Jul 29 15:37:28 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exit.c,v 1.93 2002/03/17 23:41:30 christos Exp $  */
+/*     $NetBSD: kern_exit.c,v 1.93.6.1 2002/07/29 15:37:28 lukem Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.93 2002/03/17 23:41:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.93.6.1 2002/07/29 15:37:28 lukem Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_sysv.h"
@@ -252,6 +252,27 @@
        }
 
        /*
+        * Reset p_opptr pointer of all former children which got
+        * traced by another process and were reparented. We reset
+        * it to NULL here; the trace detach code then reparents
+        * the child to initproc. We only check allproc list, since
+        * eventual former children on zombproc list won't reference
+        * p_opptr anymore.
+        */
+       if (p->p_flag & P_CHTRACED) {
+               struct proc *t;
+
+               proclist_lock_read();
+
+               LIST_FOREACH(t, &allproc, p_list) {
+                       if (t->p_opptr == p)
+                               t->p_opptr = NULL;
+               }
+
+               proclist_unlock_read();
+       }
+
+       /*
         * Save exit status and final rusage info, adding in child rusage
         * info and self times.
         */
@@ -453,11 +474,10 @@
                         * parent the exit signal.  The rest of the cleanup
                         * will be done when the old parent waits on the child.
                         */
-                       if ((p->p_flag & P_TRACED) &&
-                           p->p_oppid != p->p_pptr->p_pid) {
-                               t = pfind(p->p_oppid);
+                       if ((p->p_flag & P_TRACED) && p->p_opptr != p->p_pptr){
+                               t = p->p_opptr;
                                proc_reparent(p, t ? t : initproc);
-                               p->p_oppid = 0;
+                               p->p_opptr = NULL;
                                p->p_flag &= ~(P_TRACED|P_WAITED|P_FSTRACE);
                                if (p->p_exitsig != 0)
                                        psignal(p->p_pptr, P_EXITSIG(p));



Home | Main Index | Thread Index | Old Index