Skip to content

[sanitizer] Remove DTLS_on_libc_memalign #108120

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
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions compiler-rt/lib/asan/asan_malloc_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
# include "sanitizer_common/sanitizer_allocator_checks.h"
# include "sanitizer_common/sanitizer_allocator_dlsym.h"
# include "sanitizer_common/sanitizer_errno.h"
# include "sanitizer_common/sanitizer_tls_get_addr.h"

// ---------------------- Replacement functions ---------------- {{{1
using namespace __asan;
Expand Down Expand Up @@ -99,9 +98,7 @@ INTERCEPTOR(void*, memalign, uptr boundary, uptr size) {

INTERCEPTOR(void*, __libc_memalign, uptr boundary, uptr size) {
GET_STACK_TRACE_MALLOC;
void *res = asan_memalign(boundary, size, &stack, FROM_MALLOC);
DTLS_on_libc_memalign(res, size);
return res;
return asan_memalign(boundary, size, &stack, FROM_MALLOC);
}
#endif // SANITIZER_INTERCEPT_MEMALIGN

Expand Down
5 changes: 1 addition & 4 deletions compiler-rt/lib/dfsan/dfsan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ INTERCEPTOR(void *, reallocarray, void *ptr, SIZE_T nmemb, SIZE_T size) {
}

INTERCEPTOR(void *, __libc_memalign, SIZE_T alignment, SIZE_T size) {
void *ptr = dfsan_memalign(alignment, size);
if (ptr)
DTLS_on_libc_memalign(ptr, size);
return ptr;
return dfsan_memalign(alignment, size);
}

INTERCEPTOR(void *, aligned_alloc, SIZE_T alignment, SIZE_T size) {
Expand Down
6 changes: 1 addition & 5 deletions compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "sanitizer_common/sanitizer_allocator_dlsym.h"
#include "sanitizer_common/sanitizer_allocator_interface.h"
#include "sanitizer_common/sanitizer_mallinfo.h"
#include "sanitizer_common/sanitizer_tls_get_addr.h"

using namespace __hwasan;

Expand Down Expand Up @@ -62,10 +61,7 @@ void *__sanitizer_aligned_alloc(uptr alignment, uptr size) {
SANITIZER_INTERFACE_ATTRIBUTE
void *__sanitizer___libc_memalign(uptr alignment, uptr size) {
GET_MALLOC_STACK_TRACE;
void *ptr = hwasan_memalign(alignment, size, &stack);
if (ptr)
DTLS_on_libc_memalign(ptr, size);
return ptr;
return hwasan_memalign(alignment, size, &stack);
}

SANITIZER_INTERFACE_ATTRIBUTE
Expand Down
5 changes: 1 addition & 4 deletions compiler-rt/lib/lsan/lsan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#if SANITIZER_POSIX
#include "sanitizer_common/sanitizer_posix.h"
#endif
#include "sanitizer_common/sanitizer_tls_get_addr.h"
#include "lsan.h"
#include "lsan_allocator.h"
#include "lsan_common.h"
Expand Down Expand Up @@ -133,9 +132,7 @@ INTERCEPTOR(void*, memalign, uptr alignment, uptr size) {
INTERCEPTOR(void *, __libc_memalign, uptr alignment, uptr size) {
ENSURE_LSAN_INITED;
GET_STACK_TRACE_MALLOC;
void *res = lsan_memalign(alignment, size, stack);
DTLS_on_libc_memalign(res, size);
return res;
return lsan_memalign(alignment, size, stack);
}
#define LSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN INTERCEPT_FUNCTION(__libc_memalign)
#else
Expand Down
4 changes: 1 addition & 3 deletions compiler-rt/lib/memprof/memprof_malloc_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ INTERCEPTOR(void *, memalign, uptr boundary, uptr size) {

INTERCEPTOR(void *, __libc_memalign, uptr boundary, uptr size) {
GET_STACK_TRACE_MALLOC;
void *res = memprof_memalign(boundary, size, &stack, FROM_MALLOC);
DTLS_on_libc_memalign(res, size);
return res;
return memprof_memalign(boundary, size, &stack, FROM_MALLOC);
}
#endif // SANITIZER_INTERCEPT_MEMALIGN

Expand Down
6 changes: 1 addition & 5 deletions compiler-rt/lib/msan/msan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "sanitizer_common/sanitizer_platform_limits_netbsd.h"
#include "sanitizer_common/sanitizer_platform_limits_posix.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
#include "sanitizer_common/sanitizer_tls_get_addr.h"
#include "sanitizer_common/sanitizer_vector.h"

#if SANITIZER_NETBSD
Expand Down Expand Up @@ -185,10 +184,7 @@ INTERCEPTOR(void *, aligned_alloc, SIZE_T alignment, SIZE_T size) {
#if !SANITIZER_NETBSD
INTERCEPTOR(void *, __libc_memalign, SIZE_T alignment, SIZE_T size) {
GET_MALLOC_STACK_TRACE;
void *ptr = msan_memalign(alignment, size, &stack);
if (ptr)
DTLS_on_libc_memalign(ptr, size);
return ptr;
return msan_memalign(alignment, size, &stack);
}
#define MSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN INTERCEPT_FUNCTION(__libc_memalign)
#else
Expand Down
16 changes: 2 additions & 14 deletions compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static bool GetDTLSRange(uptr &tls_beg, uptr &tls_size) {
return false;
tls_beg = (uptr)start;
tls_size = __sanitizer_get_allocated_size(start);
VReport(2, "__tls_get_addr: glibc >=2.25 suspected; tls={%p,0x%zx}\n",
VReport(2, "__tls_get_addr: glibc DTLS suspected; tls={%p,0x%zx}\n",
(void *)tls_beg, tls_size);
return true;
}
Expand All @@ -137,11 +137,7 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
(void *)arg, arg->dso_id, arg->offset, res, (void *)tls_beg,
(void *)&tls_beg,
atomic_load(&number_of_live_dtls, memory_order_relaxed));
if (dtls.last_memalign_ptr == tls_beg) {
tls_size = dtls.last_memalign_size;
VReport(2, "__tls_get_addr: glibc <=2.24 suspected; tls={%p,0x%zx}\n",
(void *)tls_beg, tls_size);
} else if (tls_beg >= static_tls_begin && tls_beg < static_tls_end) {
if (tls_beg >= static_tls_begin && tls_beg < static_tls_end) {
// This is the static TLS block which was initialized / unpoisoned at thread
// creation.
VReport(2, "__tls_get_addr: static tls: %p\n", (void *)tls_beg);
Expand All @@ -160,13 +156,6 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
return dtv;
}

void DTLS_on_libc_memalign(void *ptr, uptr size) {
if (!common_flags()->intercept_tls_get_addr) return;
VReport(2, "DTLS_on_libc_memalign: %p 0x%zx\n", ptr, size);
dtls.last_memalign_ptr = reinterpret_cast<uptr>(ptr);
dtls.last_memalign_size = size;
}

DTLS *DTLS_Get() { return &dtls; }

bool DTLSInDestruction(DTLS *dtls) {
Expand All @@ -175,7 +164,6 @@ bool DTLSInDestruction(DTLS *dtls) {
}

#else
void DTLS_on_libc_memalign(void *ptr, uptr size) {}
DTLS::DTV *DTLS_on_tls_get_addr(void *arg, void *res,
unsigned long, unsigned long) { return 0; }
DTLS *DTLS_Get() { return 0; }
Expand Down
4 changes: 0 additions & 4 deletions compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ struct DTLS {
static_assert(sizeof(DTVBlock) <= 4096UL, "Unexpected block size");

atomic_uintptr_t dtv_block;

// Auxiliary fields, don't access them outside sanitizer_tls_get_addr.cpp
uptr last_memalign_size;
uptr last_memalign_ptr;
};

template <typename Fn>
Expand Down
Loading