Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly track deferred syscall patching with the syscall event #3881

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Keno
Copy link
Member

@Keno Keno commented Nov 15, 2024

This fixes #3880 by moving the deferred syscall patching flag from Task to the corresponding syscall event. Both to avoid the assertion in that issue and for performance (since unpatched syscalls are traced), it is important that we (attempt to) patch the correct syscall ip.

Additionally, we add the ability for tests to make sure that a particular syscall was actually patched. In particular, our logic for bailing out when another task is in the patch region was accidentally preventing all future attempts at patching the same region, even if doing so would have succeeded. With that fixed up, the new test will make sure this doesn't regress.

As a side node for now, I'm not particularly convinced by the whole EV_SYSCALL_INTERRUPTION setup. Linux doesn't really have the concept - it just prepares the restart as it writes out the signal frame. To the extent that the presence or non-presence of EV_SYSCALL_INTERRUPTION on the stack has a semantic effect on how rr behaves, that's probably a sign that we're not matching Linux behavior properly, since it doesn't have this state. The change I made here works for our existing tests and the new tests, but it's probably not fully general.

This fixes #3880 by moving the deferred syscall patching flag from
Task to the corresponding syscall event. Both to avoid the assertion
in that issue and for performance (since unpatched syscalls are traced),
it is important that we (attempt to) patch the correct syscall ip.

Additionally, we add the ability for tests to make sure that a particular
syscall was actually patched. In particular, our logic for bailing out
when another task is in the patch region was accidentally preventing
all future attempts at patching the same region, even if doing so
would have succeeded. With that fixed up, the new test will make sure
this doesn't regress.
@Keno Keno requested a review from rocallahan November 15, 2024 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant