-
Notifications
You must be signed in to change notification settings - Fork 5
optimize how we patch blocking syscalls #23
Comments
@wangbj - I need you to unpack this for me a bit further, because I don't understand why we need to ever allow the code to return to the instruction after the original syscall ( If we turn the very 1st attempt to execute the syscall into a trap, then the handler runs before the syscall ever gets to -- effectively a prehook. If we do ultimately execute a blocking syscall, it should be via the In fact, I think the following theorem should hold in general:
If this theorem is false for our design (and worse, cannot be made true), then I want to understand why. |
You're right, there's a bug when handling |
Wait, so does the theorem hold? It's hard for me to understand how that linked patch connects to the issue of patching blocking syscalls (which is an issue even if we never call fork/exec, right?). |
I believe so, there's a To elaborate we won't try to patch a syscall site, if it was recorded in |
I have a query which I feel is related to discussion. What would be the control flow in which |
This is the |
With current design, if a
syscall
blocks, systrace don't patch it until it returns. The reason behind that is because if we do patch, when the originalsyscall
is blocked, after it resumes it see invalid instructions after the two-bytesyscall
instruction. best case is we getSIGILL
orSIGSEGV
, worst case it the trailthree-byte
could be a valid instruction sequence, which lead to undefined behavior.Though we still cannot patch when a
syscall
is blocked, we can however make the blocking window a lot shorter, such as modifying thesyscall
parameters, to make it non-blocking. Another approach is we can also patch certain syscalls before hand, so that we wouldn't have to worry about it later.building
glibc
can easily expose this issue: the build process seems create tons of pipes, and causes lots of blocking read/write.The text was updated successfully, but these errors were encountered: