Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jun 2017 20:26:42 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319759 - head/sys/cddl/dev/dtrace/powerpc
Message-ID:  <201706092026.v59KQgmr066723@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Fri Jun  9 20:26:42 2017
New Revision: 319759
URL: https://svnweb.freebsd.org/changeset/base/319759

Log:
  Follow up r313841 on powerpc
  
  Close a potential race in reading the CPU dtrace flags, where a thread can
  start on one CPU, and partway through retrieving the flags be swapped out,
  while another thread traps and sets the CPU_DTRACE_NOFAULT.  This could
  cause the first thread to return without handling the fault.
  
  Discussed with:	markj@

Modified:
  head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c

Modified: head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c
==============================================================================
--- head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c	Fri Jun  9 19:57:27 2017	(r319758)
+++ head/sys/cddl/dev/dtrace/powerpc/dtrace_subr.c	Fri Jun  9 20:26:42 2017	(r319759)
@@ -267,6 +267,7 @@ dtrace_gethrestime(void)
 int
 dtrace_trap(struct trapframe *frame, u_int type)
 {
+	uint16_t nofault;
 
 	/*
 	 * A trap can occur while DTrace executes a probe. Before
@@ -277,7 +278,11 @@ dtrace_trap(struct trapframe *frame, u_int type)
 	 *
 	 * Check if DTrace has enabled 'no-fault' mode:
 	 */
-	if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) {
+	sched_pin();
+	nofault = cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT;
+	sched_unpin();
+	if (nofault) {
+		KASSERT((frame->srr1 & PSL_EE) == 0, ("interrupts enabled"));
 		/*
 		 * There are only a couple of trap types that are expected.
 		 * All the rest will be handled in the usual way.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706092026.v59KQgmr066723>