>Number:         164724
>Category:       kern
>Synopsis:       Signal bug in Dtrace
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 03 02:10:12 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Pedro Giffuni
>Release:        9.0-release
>Organization:
>Environment:
FreeBSD pcbsd-8714 9.0-RELEASE FreeBSD 9.0-RELEASE #3: Tue Dec 27 14:14:29 PST 
2011     
r...@build9x64.pcbsd.org:/usr/obj/builds/amd64/pcbsd-build90/fbsd-source/9.0/sys/GENERIC
  amd64
>Description:
Last year Bryan Cantrill found a nasty bug in Dtrace:

http://dtrace.org/blogs/bmc/2011/03/09/when-magic-collides/

He warns "you are not expected to understand this", and not
really being used to Dtrace I haven't really reproduced it.

The fix, however, was relatively easy so I adapted the patch
here:

http://dtrace.org/resources/bmc/dtrace-signal.patch

to work on FreeBSD's port.
>How-To-Repeat:

>Fix:
Patch attached

Patch attached with submission follows:

Index: cddl/dev/dtrace/i386/dtrace_subr.c
===================================================================
--- cddl/dev/dtrace/i386/dtrace_subr.c  (revision 230923)
+++ cddl/dev/dtrace/i386/dtrace_subr.c  (working copy)
@@ -27,6 +27,10 @@
  * Use is subject to license terms.
  */
 
+/*
+ * Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ */
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/types.h>
@@ -298,14 +302,15 @@
        }
 
        /*
-        * If we've executed the original instruction, but haven't performed
-        * the jmp back to t->t_dtrace_npc or the clean up of any registers
-        * used to emulate %rip-relative instructions in 64-bit mode, do that
-        * here and take the signal right away. We detect this condition by
-        * seeing if the program counter is the range [scrpc + isz, astpc).
+        * If we have executed the original instruction, but we have performed
+        * neither the jmp back to t->t_dtrace_npc nor the clean up of any
+        * registers used to emulate %rip-relative instructions in 64-bit mode,
+        * we'll save ourselves some effort by doing that here and taking the
+        * signal right away.  We detect this condition by seeing if the program
+        * counter is the range [scrpc + isz, astpc).
         */
-       if (t->t_dtrace_astpc - rp->r_pc <
-           t->t_dtrace_astpc - t->t_dtrace_scrpc - isz) {
+       if (rp->r_pc >= t->t_dtrace_scrpc + isz &&
+           rp->r_pc < t->t_dtrace_astpc) {
 #ifdef __amd64
                /*
                 * If there is a scratch register and we're on the
Index: cddl/dev/dtrace/amd64/dtrace_subr.c
===================================================================
--- cddl/dev/dtrace/amd64/dtrace_subr.c (revision 230923)
+++ cddl/dev/dtrace/amd64/dtrace_subr.c (working copy)
@@ -27,6 +27,10 @@
  * Use is subject to license terms.
  */
 
+/*
+ * Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ */
+
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/types.h>
@@ -297,14 +301,15 @@
        }
 
        /*
-        * If we've executed the original instruction, but haven't performed
-        * the jmp back to t->t_dtrace_npc or the clean up of any registers
-        * used to emulate %rip-relative instructions in 64-bit mode, do that
-        * here and take the signal right away. We detect this condition by
-        * seeing if the program counter is the range [scrpc + isz, astpc).
+        * If we have executed the original instruction, but we have performed
+        * neither the jmp back to t->t_dtrace_npc nor the clean up of any
+        * registers used to emulate %rip-relative instructions in 64-bit mode,
+        * we'll save ourselves some effort by doing that here and taking the
+        * signal right away.  We detect this condition by seeing if the program
+        * counter is the range [scrpc + isz, astpc).
         */
-       if (t->t_dtrace_astpc - rp->r_pc <
-           t->t_dtrace_astpc - t->t_dtrace_scrpc - isz) {
+       if (rp->r_pc >= t->t_dtrace_scrpc + isz &&
+           rp->r_pc < t->t_dtrace_astpc) {
 #ifdef __amd64
                /*
                 * If there is a scratch register and we're on the


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"

Reply via email to