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.75 (requested by jdolocek i...



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

description:
Pull up revision 1.75 (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/sys_process.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (60 lines):

diff -r 82f979683efe -r 49997fcf3479 sys/kern/sys_process.c
--- a/sys/kern/sys_process.c    Mon Jul 29 15:37:28 2002 +0000
+++ b/sys/kern/sys_process.c    Mon Jul 29 15:37:38 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_process.c,v 1.74 2002/05/09 15:44:45 thorpej Exp $ */
+/*     $NetBSD: sys_process.c,v 1.74.4.1 2002/07/29 15:37:38 lukem Exp $       */
 
 /*-
  * Copyright (c) 1993 Jan-Simon Pendry.
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.74 2002/05/09 15:44:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.74.4.1 2002/07/29 15:37:38 lukem Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -237,7 +237,7 @@
        case  PT_TRACE_ME:
                /* Just set the trace flag. */
                SET(t->p_flag, P_TRACED);
-               t->p_oppid = t->p_pptr->p_pid;
+               t->p_opptr = t->p_pptr;
                return (0);
 
        case  PT_WRITE_I:               /* XXX no separate I and D spaces */
@@ -337,15 +337,13 @@
 
                if (SCARG(uap, req) == PT_DETACH) {
                        /* give process back to original parent or init */
-                       if (t->p_oppid != t->p_pptr->p_pid) {
-                               struct proc *pp;
-
-                               pp = pfind(t->p_oppid);
+                       if (t->p_opptr != t->p_pptr) {
+                               struct proc *pp = t->p_opptr;
                                proc_reparent(t, pp ? pp : initproc);
                        }
 
                        /* not being traced any more */
-                       t->p_oppid = 0;
+                       t->p_opptr = NULL;
                        CLR(t->p_flag, P_TRACED|P_WAITED);
                }
 
@@ -381,9 +379,11 @@
                 * Stop the target.
                 */
                SET(t->p_flag, P_TRACED);
-               t->p_oppid = t->p_pptr->p_pid;
-               if (t->p_pptr != p)
+               t->p_opptr = t->p_pptr;
+               if (t->p_pptr != p) {
+                       t->p_pptr->p_flag |= P_CHTRACED;
                        proc_reparent(t, p);
+               }
                SCARG(uap, data) = SIGSTOP;
                goto sendsig;
 



Home | Main Index | Thread Index | Old Index