From owner-svn-src-head@FreeBSD.ORG Mon Mar 4 22:07:37 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 883AB3A9; Mon, 4 Mar 2013 22:07:37 +0000 (UTC) (envelope-from gibbs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6259B180E; Mon, 4 Mar 2013 22:07:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r24M7blZ024136; Mon, 4 Mar 2013 22:07:37 GMT (envelope-from gibbs@svn.freebsd.org) Received: (from gibbs@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r24M7brA024135; Mon, 4 Mar 2013 22:07:37 GMT (envelope-from gibbs@svn.freebsd.org) Message-Id: <201303042207.r24M7brA024135@svn.freebsd.org> From: "Justin T. Gibbs" Date: Mon, 4 Mar 2013 22:07:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r247820 - head/sys/cddl/contrib/opensolaris/uts/intel/dtrace X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Mar 2013 22:07:37 -0000 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); }