Skip to content

[asan] Intercept __makecontext_v2 on Solaris/SPARC #81588

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

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions compiler-rt/lib/asan/asan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,16 @@ static void ClearShadowMemoryForContextStack(uptr stack, uptr ssize) {
PoisonShadow(bottom, ssize, 0);
}

// Since Solaris 10/SPARC, ucp->uc_stack.ss_sp refers to the stack base address
// as on other targets. For binary compatibility, the new version uses a
// different external name, so we intercept that.
# if SANITIZER_SOLARIS && defined(__sparc__)
INTERCEPTOR(void, __makecontext_v2, struct ucontext_t *ucp, void (*func)(),
int argc, ...) {
# else
INTERCEPTOR(void, makecontext, struct ucontext_t *ucp, void (*func)(), int argc,
...) {
# endif
va_list ap;
uptr args[64];
// We don't know a better way to forward ... into REAL function. We can
Expand All @@ -373,7 +381,11 @@ INTERCEPTOR(void, makecontext, struct ucontext_t *ucp, void (*func)(), int argc,
ENUMERATE_ARRAY_16(0), ENUMERATE_ARRAY_16(16), ENUMERATE_ARRAY_16(32), \
ENUMERATE_ARRAY_16(48)

# if SANITIZER_SOLARIS && defined(__sparc__)
REAL(__makecontext_v2)
# else
REAL(makecontext)
# endif
((struct ucontext_t *)ucp, func, argc, ENUMERATE_ARRAY_64());

# undef ENUMERATE_ARRAY_4
Expand Down Expand Up @@ -780,7 +792,12 @@ void InitializeAsanInterceptors() {

# if ASAN_INTERCEPT_SWAPCONTEXT
ASAN_INTERCEPT_FUNC(swapcontext);
// See the makecontext interceptor above for an explanation.
# if SANITIZER_SOLARIS && defined(__sparc__)
ASAN_INTERCEPT_FUNC(__makecontext_v2);
# else
ASAN_INTERCEPT_FUNC(makecontext);
# endif
# endif
# if ASAN_INTERCEPT__LONGJMP
ASAN_INTERCEPT_FUNC(_longjmp);
Expand Down