freebsd-dev/sys
Ryan Stone cddcb8b4dc On i386, fbt probes are implemented by writing an invalid opcode over
certain instructions in a function prologue or epilogue.  DTrace has a
hook into the invalid opcode fault handler that checks whether the fault
was due to an probe and if so, runs the DTrace magic.

Upon returning from an invalid opcode fault caused by a probe, DTrace must
emulate the instruction that was replaced with the invalid opcode and then
return control to the instruction following the invalid opcode.

There were a pair of related bugs in the emulation for the leave
instruction.  The leave instruction is used to pop off a stack frame prior
to returning from a function.  The emulation for this instruction must
move the trap frame for the invalid opcode fault down the stack to the
bottom of the stack frame that is being removed, and then execute an iret.

At two points in this process, the emulation code was storing values above
the current value of the stack pointer.  This opened up a window in which
if we were two take an interrupt, the trap frame for the interrupt would
overwrite the values stored on the stack, causing the system to panic
later.

The first bug was that at one point the emulation code saves the new value
for $esp above the current stack pointer value.  The fix is to save this
value instead inside of the original trap frame.  At this point we do
not need the original trap frame so this is safe.

The second bug is that when the emulate code loads $esp from the stack, it
points part-way through the new trap frame instead of at its beginning.
The emulation code adjusts the stack pointer to the correct value
immediately afterwards, but this still leaves a one instruction window in
which an interrupt would corrupt this trap frame.  Fix this by adjusting
the stack frame value before loading it into $esp.

This fixes panics in invop_leave on i386 when using fbt return probes.

Reviewed by:	rpaulo, attilio
MFC after:	1 week
2011-11-10 22:03:35 +00:00
..
amd64 Attempt to improve formatting and content of several comments for 2011-11-09 18:25:50 +00:00
arm Introduce the option VFS_ALLOW_NONMPSAFE and turn it on by default on 2011-11-08 10:18:07 +00:00
boot Revert some debugging printfs that crept into 223695. 2011-11-09 14:37:47 +00:00
bsm Add ECAPMODE, "Not permitted in capability mode", a new kernel errno 2011-03-01 13:14:28 +00:00
cam Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
cddl On i386, fbt probes are implemented by writing an invalid opcode over 2011-11-10 22:03:35 +00:00
compat Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
conf Comment out TI_JUMBO_HDRSPLIT. TI_JUMBO_HDRSPLIT requires TI_SF_BUF_JUMBO. 2011-11-08 23:19:22 +00:00
contrib Add missing PF_UNLOCK in pf_test 2011-10-30 14:55:00 +00:00
crypto Update Copyright. 2011-10-27 14:15:26 +00:00
ddb Follow up to r225203 refining break-to-debugger run-time configuration 2011-08-27 14:24:27 +00:00
dev Bump this up to where it used to be. 2011-11-09 23:28:47 +00:00
fs Lock the thread lock around block that retrieves td_wmesg. Otherwise, 2011-11-09 17:15:51 +00:00
gdb
geom Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
gnu Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
i386 Attempt to improve formatting and content of several comments for 2011-11-09 18:25:50 +00:00
ia64 Introduce the option VFS_ALLOW_NONMPSAFE and turn it on by default on 2011-11-08 10:18:07 +00:00
isa Move VT switching hack for suspend/resume from bus drivers to syscons.c 2011-05-09 18:46:49 +00:00
kern Simplify the code emitted by makeobjops.awk slightly. 2011-11-09 11:00:29 +00:00
kgssapi Add missing break statement to make sure all 3DES etypes really are treated 2011-10-10 09:13:07 +00:00
libkern Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs. 2011-11-07 06:44:47 +00:00
mips Introduce the option VFS_ALLOW_NONMPSAFE and turn it on by default on 2011-11-08 10:18:07 +00:00
modules Add a missing reference to AR9287. 2011-11-10 17:01:34 +00:00
net Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
net80211 .. add missing include from an incorrect merge. 2011-11-08 14:34:01 +00:00
netatalk
netgraph Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
netinet When loading addresses from INITs, always use the correct 2011-11-07 22:30:19 +00:00
netinet6 Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
netipsec Add missing va_end() in an error case to clean up after va_start() 2011-10-07 21:00:26 +00:00
netipx Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
netnatm
netncp Change ncp_scan_bindery_object() to pass a constant search string. 2011-10-16 08:44:03 +00:00
netsmb Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs. 2011-11-07 06:44:47 +00:00
nfs Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs. 2011-11-07 06:44:47 +00:00
nfsclient Merge 220876, 220877, and 221537 from the new NFS client to the old: 2011-08-09 15:29:58 +00:00
nfsserver Fix the NFS servers so that they can do a Lookup of "..", 2011-09-03 00:28:53 +00:00
nlm Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
ofed Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
opencrypto Add the fo_chown and fo_chmod methods to struct fileops and use them 2011-08-16 20:07:47 +00:00
pc98 Introduce the option VFS_ALLOW_NONMPSAFE and turn it on by default on 2011-11-08 10:18:07 +00:00
pci - Import the common MII bitbang'ing code from NetBSD and convert drivers to 2011-11-01 16:13:59 +00:00
powerpc Fix a bug where the pmap_cpu_bootstrap() ap argument could be clobbered. 2011-11-09 13:48:23 +00:00
rpc Both a crash reported on freebsd-current on Oct. 18 under the 2011-11-03 14:38:03 +00:00
security Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
sparc64 Introduce the option VFS_ALLOW_NONMPSAFE and turn it on by default on 2011-11-08 10:18:07 +00:00
sys Assert that _PRELE() is done for the held process. 2011-11-09 17:13:41 +00:00
teken Link the demo application against ncursesw to make Unicode work. 2011-10-13 14:20:27 +00:00
tools Restore the comment that I removed by accident. 2011-11-09 13:26:59 +00:00
ufs Use implementation independent inoNN_t scalars for on-disk UFS structures 2011-11-09 07:48:48 +00:00
vm Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
x86 Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs. 2011-11-07 15:43:11 +00:00
xdr
xen Properly handle suspend/resume events in the Xen device 2011-09-20 23:44:34 +00:00
Makefile Include sys/xen in cscope tag file generation. 2011-06-10 20:51:41 +00:00