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#5784: Mitigate drwrap retaddr transparency violation #5896

Merged
merged 5 commits into from Mar 7, 2023

Conversation

abhinav92003
Copy link
Contributor

@abhinav92003 abhinav92003 commented Mar 7, 2023

Adds a new drwrap API, drwrap_get_retaddr_if_sentinel(), that allows
mitigation of a transparency violation under the DRWRAP_REPLACE_RETADDR drwrap
strategy where the return address on the stack is replaced with the address of
the internal replace_retaddr_sentinel() routine. This API modifies the passed-in
value to the actual return address of the inner-most nested wrapped function if
the passed-in value is replace_retaddr_sentinel() itself.

Fixes the value of the marker written by the kernel xfer event in drmemtrace by
using the new drwrap_get_retaddr_if_sentinel() API on the mcontext PC before
writing it out to the trace. Before, this caused many invariant errors of type 'Signal
handler return point incorrect' in traces collected on proprietary apps.

Verified on a large proprietary app that this error due to drwrap is fixed now,
whereas there were a few hundred instances before.

Fixes: #5784

Adds a new drwrap API, drwrap_replace_if_retaddr_sentinel, that allows
mitigation of a transparency violation under the DRWRAP_REPLACE_RETADDR
drwrap strategy where the return address on the stack is replaced with
the address of the internal replace_retaddr_sentinel() routine. This
API modified the passed-in value to the actual return address of the
wrapped function if the passed-in value is replace_retaddr_sentinel()
itself.

Fixes the value of the marker written by the kernel xfer event in
drmemtrace by using the new drwrap_replace_if_retaddr_sentinel() API
on the mcontext PC before writing it out to the trace. This caused
many invariant errors of type 'Signal handler return point incorrect'
in traces collected on proprietary apps.

Verified on a large proprietary app that this error due to drwrap is
fixed now, whereas there were a few hundred instances before.

Fixes: #5784
ext/drwrap/drwrap.h Outdated Show resolved Hide resolved
ext/drwrap/drwrap.h Outdated Show resolved Hide resolved
ext/drwrap/drwrap.h Outdated Show resolved Hide resolved
ext/drwrap/drwrap.c Show resolved Hide resolved
@abhinav92003 abhinav92003 merged commit 04dfa77 into master Mar 7, 2023
@abhinav92003 abhinav92003 deleted the i5784-fix-drwrap-signal-xfer-marker branch March 7, 2023 21:58
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.

drmemtrace: Incorrect kernel xfer marker for signals received at end of wrapped function
2 participants