freebsd-dev/sys
Mark Johnston 0626f3e435 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
2014-04-14 00:22:42 +00:00
..
amd64 There is no need to save and restore the host's return address in the 2014-04-11 20:15:53 +00:00
arm Updates to i.MX53: 2014-04-08 04:05:04 +00:00
boot Improve the i.MX53 / Digi DTS: 2014-04-13 22:35:39 +00:00
bsm IFp4 @1192291: 2014-04-07 20:44:00 +00:00
cam Join CTL worker threads into one process for convenience. 2014-04-13 11:10:36 +00:00
cddl DTrace's pid provider works by inserting breakpoint instructions at probe 2014-04-14 00:22:42 +00:00
compat In freebsd32_sendmsg(), replace the call to sockargs() followed by a 2014-04-05 18:56:01 +00:00
conf Really, really, really only allow this option for amd64/i386 builds. 2014-04-09 18:44:54 +00:00
contrib Implement the final missing sysctls by moving ipf_auth_softc_t from 2014-04-07 19:32:56 +00:00
crypto NO_MAN= has been deprecated in favor of MAN= for some time, go ahead 2014-04-13 05:21:56 +00:00
ddb ddb: Minor style cleanups. 2014-03-31 16:37:41 +00:00
dev Add a missing comma between error message definitions. 2014-04-13 18:51:39 +00:00
fs Fix NFS deadlock vulnerability. [SA-14:05] 2014-04-08 18:27:32 +00:00
gdb
geom Align and round the partitionable disk space to 4K by default. 2014-04-12 20:28:39 +00:00
gnu Symbolic bindings for the dts files... 2014-02-28 16:51:33 +00:00
i386 Really, really, really only allow this option for amd64/i386 builds. 2014-04-09 18:44:54 +00:00
ia64 Rename __wchar_t so it no longer conflicts with __wchar_t from clang 3.4 2014-04-01 14:46:11 +00:00
isa Remove vestiges of knowing the ISA bus, which we gave up on around 20 2014-03-19 21:03:04 +00:00
kern Free buf after usage. 2014-04-13 21:23:15 +00:00
kgssapi
libkern Fix typo 2013-11-29 20:14:26 +00:00
mips Change kernel/rootfs hints to use search patterns instead of absolute 2014-04-04 15:52:45 +00:00
modules Spell imgact_binmisc correctly 2014-04-09 03:46:04 +00:00
net In if_freemulti(), relax the paranoid KASSERT() on ifma->ifma_protospec. 2014-04-10 18:43:02 +00:00
net80211 Remove IPX support. 2014-03-14 02:58:48 +00:00
netgraph Remove AppleTalk support. 2014-03-14 06:29:43 +00:00
netinet Some whitespace and style fixes. 2014-04-11 21:00:59 +00:00
netinet6 Properly release the in6_multi lock. 2014-04-12 02:05:31 +00:00
netipsec The check for local address spoofing lacks ifaddr locking. 2014-04-04 16:58:32 +00:00
netnatm
netpfil Free resources and error cases; re-indent a curly brace while here. 2014-04-13 21:13:33 +00:00
netsmb Update kernel inclusions of capability.h to use capsicum.h instead; some 2014-03-16 10:55:57 +00:00
nfs - Remove rt_metrics_lite and simply put its members into rtentry. 2014-03-05 01:17:47 +00:00
nfsclient For software builds, the NFS client does many small 2013-12-07 23:05:59 +00:00
nfsserver Update kernel inclusions of capability.h to use capsicum.h instead; some 2014-03-16 10:55:57 +00:00
nlm Correct a typo in nlm_find_host_by_addr(): the intention of the 2014-03-11 00:25:55 +00:00
ofed Rename global cnt to vm_cnt to avoid shadowing. 2014-03-22 10:26:09 +00:00
opencrypto allow the kern.cryptodevallowsoft sysctl to enable symetric/hashes too... 2014-03-11 01:45:46 +00:00
pc98 Rename global cnt to vm_cnt to avoid shadowing. 2014-03-22 10:26:09 +00:00
pci Increase the number of TX DMA segments from 32 to 35. It turned 2014-03-31 01:54:59 +00:00
powerpc Small performance optimization. Clobber only cr0, rather than the entire CR. 2014-04-11 06:17:44 +00:00
rpc Fix lock acquisition in case no request space available, missed in r260097. 2014-02-04 00:00:01 +00:00
security audit: plug FILEDESC_LOCK leak in audit_canon_path. 2014-03-21 01:30:33 +00:00
sparc64 Rename __wchar_t so it no longer conflicts with __wchar_t from clang 3.4 2014-04-01 14:46:11 +00:00
sys Hide internal details of sbintime_t implementation wrapping INT64_MAX into 2014-04-12 23:29:29 +00:00
teken Fix typo. 2014-02-06 13:28:06 +00:00
tools Update NetBSD Foundation copyrights to 2-clause BSD 2014-03-18 01:40:25 +00:00
ufs Update comment to explain search order reverted to historical order 2014-03-22 11:26:39 +00:00
vm Rename global cnt to vm_cnt to avoid shadowing. 2014-03-22 10:26:09 +00:00
x86 Make this compile with gcc. 2014-04-05 22:43:18 +00:00
xdr
xen Make this compile with gcc. 2014-04-05 22:43:18 +00:00
Makefile Remove AppleTalk support. 2014-03-14 06:29:43 +00:00