stephenrkell / libsystrap

Monitor, rewrite and/or otherwise trap system calls... on Linux/x86{,-64} only, for now.
GNU General Public License v3.0
59 stars 7 forks source link

Can't perform stack-replacing clone() in trap context #5

Open stephenrkell opened 3 years ago

stephenrkell commented 3 years ago

This is a known problem. I have seen this work successfully, but it is not reliable because the compiler doesn't know what we're doing. Once the stack is zapped, any locals not held in registers will be lost, and the compiler doesn't let us tell it to refrain from using the stack.

Although "rewrite in assembly" has been my tentative solution, it may be possible to clean up the code and retain a C-like solution by aggressive use of __asm__("rdx") and similar annotations on locals.

stephenrkell commented 3 years ago

This code has been overhauled in 7e070fb9353023b0701cd72cabffe417fad77391, and now has more chance of working, but is not yet tested.

stephenrkell commented 3 years ago

Following further fixes, this now passes a basic test as of 2ed8ffd5 -- still needs testing on 64-bit and in greater depth generally.

stephenrkell commented 3 years ago

This is now tested a bit more and some issues fixed as of 0b7ff5b5. It seems to work on 64-bit. Still not well-tested.