aboutsummaryrefslogtreecommitdiff
path: root/sys/cddl/dev/dtrace
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2019-02-21 22:54:17 +0000
committerMark Johnston <markj@FreeBSD.org>2019-02-21 22:54:17 +0000
commit4f1b715c8487f7a6d45083dbe998e82a971f48b4 (patch)
treef9920c102daf3505c78a07f8a93f201192ecf4bb /sys/cddl/dev/dtrace
parentc0ca37d17b451f3eedbb95041475280b721451a7 (diff)
downloadsrc-4f1b715c8487f7a6d45083dbe998e82a971f48b4.tar.gz
src-4f1b715c8487f7a6d45083dbe998e82a971f48b4.zip
Fix a tracepoint lookup race in fasttrap_pid_probe().
fasttrap hooks the userspace breakpoint handler; the hook looks up the breakpoint address in a hash table of tracepoints. It is possible for the tracepoint to be removed by a different thread in between the breakpoint trap and the hash table lookup, in which case SIGTRAP gets delivered to the target process. Fix the problem by adding a per-process generation counter that gets incremented when a tracepoint belonging to that process is removed. Then, when a lookup fails, the trapping instruction is restarted if the thread's counter doesn't match that of the process. Reviewed by: cem MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19273
Notes
Notes: svn path=/head/; revision=344452
Diffstat (limited to 'sys/cddl/dev/dtrace')
-rw-r--r--sys/cddl/dev/dtrace/dtrace_cddl.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/cddl/dev/dtrace/dtrace_cddl.h b/sys/cddl/dev/dtrace/dtrace_cddl.h
index b69da4d18da1..344fe562bff9 100644
--- a/sys/cddl/dev/dtrace/dtrace_cddl.h
+++ b/sys/cddl/dev/dtrace/dtrace_cddl.h
@@ -37,7 +37,7 @@ typedef struct kdtrace_proc {
u_int64_t p_dtrace_count; /* Number of DTrace tracepoints */
void *p_dtrace_helpers; /* DTrace helpers, if any */
int p_dtrace_model;
-
+ uint64_t p_fasttrap_tp_gen; /* Tracepoint hash table gen */
} kdtrace_proc_t;
/*
@@ -86,6 +86,7 @@ typedef struct kdtrace_thread {
u_int64_t td_hrtime; /* Last time on cpu. */
void *td_dtrace_sscr; /* Saved scratch space location. */
void *td_systrace_args; /* syscall probe arguments. */
+ uint64_t td_fasttrap_tp_gen; /* Tracepoint hash table gen. */
} kdtrace_thread_t;
/*
@@ -113,10 +114,12 @@ typedef struct kdtrace_thread {
#define t_dtrace_regv td_dtrace->td_dtrace_regv
#define t_dtrace_sscr td_dtrace->td_dtrace_sscr
#define t_dtrace_systrace_args td_dtrace->td_systrace_args
+#define t_fasttrap_tp_gen td_dtrace->td_fasttrap_tp_gen
#define p_dtrace_helpers p_dtrace->p_dtrace_helpers
#define p_dtrace_count p_dtrace->p_dtrace_count
#define p_dtrace_probes p_dtrace->p_dtrace_probes
#define p_model p_dtrace->p_dtrace_model
+#define p_fasttrap_tp_gen p_dtrace->p_fasttrap_tp_gen
#define DATAMODEL_NATIVE 0
#ifdef __amd64__