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

i#4197: Add new drwrap post-call scheme: replace retaddr #4221

Merged
merged 3 commits into from
Mar 26, 2020

Conversation

derekbruening
Copy link
Contributor

Adds an alternative scheme for achieving a post-call control point
that does not require flushing or shared data structure examination
per-call: replacing the return address with a sentinel.

When the new flag DRWRAP_REPLACE_RETADDR is set, the return address is
replaced with the address of a single return instruction in the client
library, with the real address saved. When a block is seen consisting
of that sentinel instruction, post-call callbacks are called, and then
control is sent to the saved real address using
dr_redirect_native_target().

Adds wrapping tests to drwrap-test.

This new scheme requires restoring return addresses on the stack on
detach or other state translation. Adds functionality to do so, along
with a new test client.drwrap-test-detach.

This requires the client's state restoration event be called for
addresses not in the code cache. Adds such a call.

Adds comments about translation problems with clean call mangling
which is filed as i#4219. The issues seen here are all limited to
traces, so the test works around the problems with -disable_traces.

Tested the core drwrap behavior on ARM and AArch64 but missing general
detach support there (#1578) prevents enabling the detach test there.

Issue: #4219
Fixes #4197

Adds an alternative scheme for achieving a post-call control point
that does not require flushing or shared data structure examination
per-call: replacing the return address with a sentinel.

When the new flag DRWRAP_REPLACE_RETADDR is set, the return address is
replaced with the address of a single return instruction in the client
library, with the real address saved.  When a block is seen consisting
of that sentinel instruction, post-call callbacks are called, and then
control is sent to the saved real address using
dr_redirect_native_target().

Adds wrapping tests to drwrap-test.

This new scheme requires restoring return addresses on the stack on
detach or other state translation.  Adds functionality to do so, along
with a new test client.drwrap-test-detach.

This requires the client's state restoration event be called for
addresses not in the code cache.  Adds such a call.

Adds comments about translation problems with clean call mangling
which is filed as i#4219.  The issues seen here are all limited to
traces, so the test works around the problems with -disable_traces.

Tested the core drwrap behavior on ARM and AArch64 but missing general
detach support there (#1578) prevents enabling the detach test there.

Issue: #4219
Fixes #4197
@derekbruening
Copy link
Contributor Author

Failures are 32-bit build missing a define: will fix now.

@derekbruening
Copy link
Contributor Author

The Travis Mac job is terminating mid-build. It is strange. It looks like another Travis issue. I filed #4223. There have been transient Travis Mac problems in the past. Hopefully this will go away on its own.

@derekbruening derekbruening merged commit 9bb0354 into master Mar 26, 2020
@derekbruening derekbruening deleted the i4197-drwrap-replace-retaddr branch March 26, 2020 19:07
derekbruening added a commit that referenced this pull request Mar 26, 2020
PR #4221 broke the Mac build, but Travis failed to show the failure in
the logs in the PR builds (some buffering issue filed as #4223).  We
fix the Mac build here.

Issue: #4197, #4223
derekbruening added a commit that referenced this pull request Mar 26, 2020
PR #4221 broke the Mac build, but Travis failed to show the failure in
the logs in the PR builds (some buffering issue filed as #4223).  We
fix the Mac build here.

Issue: #4197, #4223
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add drwrap mode with indirect handling but no expensive retaddr checking or flushing
2 participants