Skip to content

[sanitizer] Adjust size for begin/start mismatch #109079

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
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
7 changes: 6 additions & 1 deletion compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "sanitizer_allocator_interface.h"
#include "sanitizer_atomic.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_flags.h"
#include "sanitizer_platform_interceptors.h"

Expand Down Expand Up @@ -116,10 +117,14 @@ SANITIZER_INTERFACE_WEAK_DEF(uptr, __sanitizer_get_dtls_size,
const void *start = __sanitizer_get_allocated_begin(tls_begin);
if (!start)
return 0;
CHECK_LE(start, tls_begin);
uptr tls_size = __sanitizer_get_allocated_size(start);
VReport(2, "__tls_get_addr: glibc DTLS suspected; tls={%p,0x%zx}\n",
tls_begin, tls_size);
return tls_size;
uptr offset =
(reinterpret_cast<uptr>(tls_begin) - reinterpret_cast<uptr>(start));
CHECK_LE(offset, tls_size);
return tls_size - offset;
}

DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
Expand Down
Loading