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
This commit is contained in:
Justin T. Gibbs 2013-03-04 22:07:36 +00:00
parent ac42a1726a
commit 7e2a739f03

View File

@ -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 @@ fasttrap_pid_probe(struct reg *rp)
}
rp->r_rip = new_pc;
set_regs(curthread, rp);
PROC_LOCK(p);
proc_write_regs(curthread, rp);
_PRELE(p);
PROC_UNLOCK(p);
return (0);
}