svn commit: r248248 - in stable/9/sys/cddl/contrib/opensolaris/uts: common/dtrace intel/dtrace

Justin T. Gibbs gibbs at FreeBSD.org
Wed Mar 13 17:34:42 UTC 2013


Author: gibbs
Date: Wed Mar 13 17:34:42 2013
New Revision: 248248
URL: http://svnweb.freebsd.org/changeset/base/248248

Log:
  MFC kernel fixes to userland dtrace support.
  
  r247049
  -------
  Avoid panic when tearing down the DTrace pid provider for a
  process that has crashed.
  
  sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c:
  	In fasttrap_pid_disable(), we cannot PHOLD the proc
  	structure for a process that no longer exists, but
  	we still have other, fasttrap specific, state that
  	must be cleaned up for probes that existed in the
  	dead process.  Instead of returning early if the
  	process related to our probes isn't found,
  	conditionalize the locking and carry on with a NULL
  	proc pointer.  The rest of the fasttrap code already
  	understands that a NULL proc is possible and does
  	the right things in this case.
  
  r247820
  -------
  Fix assertion failure when using userland DTrace probes from
  the pid provider on a kernel compiled with INVARIANTS.
  
  sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c:
  	In fasttrap_probe_pid(), attempts to write to the
  	address space of the thread that fired the probe
  	must be performed with the process of the thread
  	held.  Use _PHOLD() to ensure this is the case.
  
  	In fasttrap_probe_pid(), use proc_write_regs() instead
  	of calling set_regs() directly.  proc_write_regs()
  	performs invariant checks to verify the calling
  	environment of set_regs().  PROC_LOCK()/UNLOCK() around
  	the call to proc_write_regs() so that it's invariants
  	are satisfied.
  
  Sponsored by:	Spectra Logic Corporation

Modified:
  stable/9/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
  stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
Directory Properties:
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)

Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
==============================================================================
--- stable/9/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c	Wed Mar 13 15:42:04 2013	(r248247)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c	Wed Mar 13 17:34:42 2013	(r248248)
@@ -1124,14 +1124,12 @@ fasttrap_pid_disable(void *arg, dtrace_i
 	 * provider lock as a point of mutual exclusion to prevent other
 	 * DTrace consumers from disabling this probe.
 	 */
-	if ((p = pfind(probe->ftp_pid)) == NULL) {
-		mutex_exit(&provider->ftp_mtx);
-		return;
-	}
+	if ((p = pfind(probe->ftp_pid)) != NULL) {
 #ifdef __FreeBSD__
-	_PHOLD(p);
-	PROC_UNLOCK(p);
+		_PHOLD(p);
+		PROC_UNLOCK(p);
 #endif
+	}
 
 	/*
 	 * Disable all the associated tracepoints (for fully enabled probes).
@@ -1168,7 +1166,8 @@ fasttrap_pid_disable(void *arg, dtrace_i
 		fasttrap_pid_cleanup();
 
 #ifdef __FreeBSD__
-	PRELE(p);
+	if (p != NULL)
+		PRELE(p);
 #endif
 	if (!probe->ftp_enabled)
 		return;

Modified: stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
==============================================================================
--- stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Wed Mar 13 15:42:04 2013	(r248247)
+++ stable/9/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Wed Mar 13 17:34:42 2013	(r248248)
@@ -1034,6 +1034,7 @@ fasttrap_pid_probe(struct reg *rp)
 #endif
 
 	PROC_LOCK(p);
+	_PHOLD(p);
 	pid = p->p_pid;
 #if defined(sun)
 	pid_mtx = &cpu_core[CPU->cpu_id].cpuc_pid_lock;
@@ -1059,6 +1060,7 @@ fasttrap_pid_probe(struct reg *rp)
 #if defined(sun)
 		mutex_exit(pid_mtx);
 #endif
+		_PRELE(p);
 		PROC_UNLOCK(p);
 		return (-1);
 	}
@@ -1732,7 +1734,6 @@ fasttrap_pid_probe(struct reg *rp)
 
 		ASSERT(i <= sizeof (scratch));
 
-
 #if defined(sun)
 		if (fasttrap_copyout(scratch, (char *)addr, i)) {
 #else
@@ -1794,7 +1795,11 @@ done:
 	}
 
 	rp->r_rip = new_pc;
-	set_regs(curthread, rp);
+
+	PROC_LOCK(p);
+	proc_write_regs(curthread, rp);
+	_PRELE(p);
+	PROC_UNLOCK(p);
 
 	return (0);
 }


More information about the svn-src-all mailing list