327551 |
04-Jan-2018 |
markj |
MFC r326774, r326811: Pass the trap frame to fasttrap hooks. |
326129 |
23-Nov-2017 |
markj |
MFC r325887: Avoid holding the process in uread() and uwrite(). |
313120 |
03-Feb-2017 |
markj |
MFC r312893: Fix an off-by-one in an assertion on fasttrap tracepoint sizes. |
306572 |
02-Oct-2016 |
markj |
MFC r306304: Move implementations of uread() and uwrite() to the illumos compat layer. |
302408 |
08-Jul-2016 |
gjb |
Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle. Prune svn:mergeinfo from the new branch, as nothing has been merged here.
Additional commits post-branch will follow.
Approved by: re (implicit) Sponsored by: The FreeBSD Foundation |
296479 |
08-Mar-2016 |
markj |
Fix fasttrap tracepoint locking.
Upstream, tracepoints are protected by per-CPU mutexes. An unlinked tracepoint may be freed once all the tracepoint mutexes have been acquired and released - this is done in fasttrap_mod_barrier(). This mechanism was not properly ported: in some places, the proc lock is used in place of a tracepoint lock, and in others the locking is omitted entirely. This change implements tracepoint locking with an rmlock, where the read lock is used in fasttrap probe context. As a side effect, this fixes a recursion on the proc lock when the raise action is used from a userland probe.
MFC after: 1 month
|
291961 |
07-Dec-2015 |
markj |
Add helper functions proc_readmem() and proc_writemem().
These helper functions can be used to read in or write a buffer from or to an arbitrary process' address space. Without them, this can only be done using proc_rwmem(), which requires the caller to fill out a uio. This is onerous and results in code duplication; the new functions provide a simpler interface which is sufficient for most existing callers of proc_rwmem().
This change also adds a manual page for proc_rwmem() and the new functions.
Reviewed by: jhb, kib Differential Revision: https://reviews.freebsd.org/D4245
|
277300 |
17-Jan-2015 |
smh |
Mechanically convert cddl sun #ifdef's to illumos
Since the upstream for cddl code is now illumos not sun, mechanically convert all sun #ifdef's to illumos #ifdef's which have been used in all newer code for some time.
Also do a manual pass to correct the use if #ifdef comments as per style(9) as well as few uses of #if defined(__FreeBSD__) vs #ifndef illumos.
MFC after: 1 month Sponsored by: Multiplay
|
264434 |
14-Apr-2014 |
markj |
DTrace's pid provider works by inserting breakpoint instructions at probe sites and installing a hook at the kernel's trap handler. The fasttrap code will emulate the overwritten instruction in some common cases, but otherwise copies it out into some scratch space in the traced process' address space and ensures that it's executed after returning from the trap.
In Solaris and illumos, this (per-thread) scratch space comes from some reserved space in TLS, accessible via the fs segment register. This approach is somewhat unappealing on FreeBSD since it would require some modifications to rtld and jemalloc (for static TLS) to ensure that TLS is executable, and would thus introduce dependencies on their implementation details. I think it would also be impossible to safely trace static binaries compiled without these modifications.
This change implements the functionality in a different way, by having fasttrap map pages into the target process' address space on demand. Each page is divided into 64-byte chunks for use by individual threads, and fasttrap's process descriptor struct has been extended to keep track of any scratch space allocated for the corresponding process.
With this change it's possible to trace all libc functions in a program, e.g. with
pid$target:libc.so.*::entry {@[probefunc] = count();}
Previously this would generally cause the victim process to crash, as tracing memcpy on amd64 requires the functionality described above.
Tested by: Prashanth Kumar <pra_udupi@yahoo.co.in> (earlier version) MFC after: 6 weeks
|
262661 |
01-Mar-2014 |
markj |
Fix emulation of call and jmp instructions on i386 and for 32-bit processes on amd64.
Submitted by: Prashanth Kumar <pra_udupi@yahoo.co.in> MFC after: 2 weeks
|
262542 |
27-Feb-2014 |
markj |
Move some files that are identical on i386 and amd64 to an x86 subdirectory rather than keeping duplicate copies.
Discussed with: avg MFC after: 1 week
|
259535 |
18-Dec-2013 |
markj |
The fasttrap fork handler is responsible for removing tracepoints in the child process that were inherited from its parent. However, this should not be done in the case of a vfork, since the fork handler ends up removing the tracepoints from the shared vm space, and userland DTrace probes in the parent will no longer fire as a result.
Now the child of a vfork may trigger userland DTrace probes enabled in its parent, so modify the fasttrap probe handler to handle this case and handle the child process in the same way that it would handle the traced process. In particular, if once traces function foo() in a process that vforks, and the child calls foo(), fasttrap will treat this call as having come from the parent. This is the behaviour of the upstream code.
While here, add #ifdef guards to some code that isn't present upstream.
MFC after: 1 month
|
259211 |
11-Dec-2013 |
markj |
Correct the check for errors from proc_rwmem().
MFC after: 2 weeks
|
257679 |
05-Nov-2013 |
markj |
Use suword32 and suword64 instead of copyout(9). This fixes a bug in the emulation of the call instruction caused by reversing the uaddr and kaddr arguments when copying data out to userland: the suword* functions take the uaddr as the first argument whereas copyout(9) takes the kaddr as the first argument. This also partially undoes the fixes from r257143.
Submitted by: Prashanth Kumar <pra_udupi@yahoo.co.in> (original version) MFC after: 1 month
|
257143 |
26-Oct-2013 |
markj |
Fix a couple of bugs in the fasttrap emulation of a "push %rbp" instruction: the code was trying to save the stack pointer rather than the frame pointer, and the arguments to copyout(9) were reversed, so nothing ended up being saved on the stack. This would cause process crashes when the pid provider was being used to instrument calls of a function starting with this instruction.
Reported by: symbolics@gmx.com Tested by: symbolics@gmx.com (earlier version) MFC after: 2 weeks
|
256822 |
21-Oct-2013 |
markj |
When fetching function arguments out of a frame on amd64, explicitly select the register based on the argument index rather than relying on the fields in struct reg to be in the right order. This assumption is incorrect on FreeBSD and generally led to bogus argument values for the sixth argument of PID and USDT probes; the first five are passed directly to dtrace_probe() via the fasttrap trap handler and so were correctly handled.
MFC after: 2 weeks
|
247820 |
04-Mar-2013 |
gibbs |
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
|
227291 |
07-Nov-2011 |
rstone |
Replace fasttrap_copyout() with uwrite(). FreeBSD copyout() is not able to write to the .text section of a process.
Obtained from: rpaulo MFC after: 3 days
|
212494 |
12-Sep-2010 |
rpaulo |
Revamp locking a bit. This fixes three problems: * processes now can't go away while we are inserting probes (fixes a panic) * if a trap happens, we won't be holding the process lock (fixes a hang) * fix a LOR between the process lock and the fasttrap bucket list lock
Thanks to kib for pointing some problems. Sponsored by: The FreeBSD Foundation
|
211929 |
28-Aug-2010 |
rpaulo |
Remove debugging.
Sponsored by: The FreeBSD Foundation
|
211744 |
24-Aug-2010 |
rpaulo |
MD fasttrap implementation.
Sponsored by: The FreeBSD Foundation
|
209721 |
06-Jul-2010 |
rpaulo |
Merge from vendor-sys/opensolaris: * add fasttrap files
|
179194 |
22-May-2008 |
jb |
This commit was generated by cvs2svn to compensate for changes in r179193, which included commits to RCS files with non-trunk default branches.
|