svn commit: r247820 - head/sys/cddl/contrib/opensolaris/uts/intel/dtrace

Justin T. Gibbs gibbs at FreeBSD.org
Mon Mar 4 22:07:37 UTC 2013


Author: gibbs
Date: Mon Mar  4 22:07:36 2013
New Revision: 247820
URL: http://svnweb.freebsd.org/changeset/base/247820

Log:
  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
  Reviewed by:	gnn, rpaulo
  MFC after:	1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c

Modified: head/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Mon Mar  4 22:04:14 2013	(r247819)
+++ head/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Mon Mar  4 22:07:36 2013	(r247820)
@@ -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