svn commit: r247077 - in stable/9/sys: kern sys

Konstantin Belousov kib at FreeBSD.org
Thu Feb 21 05:47:54 UTC 2013


Author: kib
Date: Thu Feb 21 05:47:52 2013
New Revision: 247077
URL: http://svnweb.freebsd.org/changeset/base/247077

Log:
  MFC r246484:
  Allow ptrace(2) operation on the child created by vfork(2), if the
  debugger is not the parent.

Modified:
  stable/9/sys/kern/kern_exec.c
  stable/9/sys/kern/kern_exit.c
  stable/9/sys/kern/kern_sig.c
  stable/9/sys/kern/sys_process.c
  stable/9/sys/sys/proc.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_exec.c
==============================================================================
--- stable/9/sys/kern/kern_exec.c	Thu Feb 21 05:38:11 2013	(r247076)
+++ stable/9/sys/kern/kern_exec.c	Thu Feb 21 05:47:52 2013	(r247077)
@@ -646,7 +646,7 @@ interpret:
 	 */
 	p->p_flag |= P_EXEC;
 	if (p->p_pptr && (p->p_flag & P_PPWAIT)) {
-		p->p_flag &= ~P_PPWAIT;
+		p->p_flag &= ~(P_PPWAIT | P_PPTRACE);
 		cv_broadcast(&p->p_pwait);
 	}
 

Modified: stable/9/sys/kern/kern_exit.c
==============================================================================
--- stable/9/sys/kern/kern_exit.c	Thu Feb 21 05:38:11 2013	(r247076)
+++ stable/9/sys/kern/kern_exit.c	Thu Feb 21 05:47:52 2013	(r247077)
@@ -259,7 +259,7 @@ exit1(struct thread *td, int rv)
 	PROC_LOCK(p);
 	rv = p->p_xstat;	/* Event handler could change exit status */
 	stopprofclock(p);
-	p->p_flag &= ~(P_TRACED | P_PPWAIT);
+	p->p_flag &= ~(P_TRACED | P_PPWAIT | P_PPTRACE);
 
 	/*
 	 * Stop the real interval timer.  If the handler is currently

Modified: stable/9/sys/kern/kern_sig.c
==============================================================================
--- stable/9/sys/kern/kern_sig.c	Thu Feb 21 05:38:11 2013	(r247076)
+++ stable/9/sys/kern/kern_sig.c	Thu Feb 21 05:47:52 2013	(r247077)
@@ -2565,7 +2565,7 @@ issignal(struct thread *td, int stop_all
 			sigqueue_delete(&p->p_sigqueue, sig);
 			continue;
 		}
-		if (p->p_flag & P_TRACED && (p->p_flag & P_PPWAIT) == 0) {
+		if (p->p_flag & P_TRACED && (p->p_flag & P_PPTRACE) == 0) {
 			/*
 			 * If traced, always stop.
 			 * Remove old signal from queue before the stop.

Modified: stable/9/sys/kern/sys_process.c
==============================================================================
--- stable/9/sys/kern/sys_process.c	Thu Feb 21 05:38:11 2013	(r247076)
+++ stable/9/sys/kern/sys_process.c	Thu Feb 21 05:47:52 2013	(r247077)
@@ -824,6 +824,8 @@ kern_ptrace(struct thread *td, int req, 
 	case PT_TRACE_ME:
 		/* set my trace flag and "owner" so it can read/write me */
 		p->p_flag |= P_TRACED;
+		if (p->p_flag & P_PPWAIT)
+			p->p_flag |= P_PPTRACE;
 		p->p_oppid = p->p_pptr->p_pid;
 		break;
 

Modified: stable/9/sys/sys/proc.h
==============================================================================
--- stable/9/sys/sys/proc.h	Thu Feb 21 05:38:11 2013	(r247076)
+++ stable/9/sys/sys/proc.h	Thu Feb 21 05:47:52 2013	(r247077)
@@ -636,6 +636,7 @@ struct proc {
 #define	P_INMEM		0x10000000 /* Loaded into memory. */
 #define	P_SWAPPINGOUT	0x20000000 /* Process is being swapped out. */
 #define	P_SWAPPINGIN	0x40000000 /* Process is being swapped in. */
+#define	P_PPTRACE	0x80000000 /* PT_TRACEME by vforked child. */
 
 #define	P_STOPPED	(P_STOPPED_SIG|P_STOPPED_SINGLE|P_STOPPED_TRACE)
 #define	P_SHOULDSTOP(p)	((p)->p_flag & P_STOPPED)


More information about the svn-src-stable-9 mailing list