-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Reland "[sanitizer] Add CHECKs to validate calculated TLS range" #108122
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
Closed
vitalybuka
wants to merge
10
commits into
main
from
revert-108112-revert-107941-users/vitalybuka/spr/sanitizer-add-checks-to-validate-calculated-tls-range
Closed
Reland "[sanitizer] Add CHECKs to validate calculated TLS range" #108122
vitalybuka
wants to merge
10
commits into
main
from
revert-108112-revert-107941-users/vitalybuka/spr/sanitizer-add-checks-to-validate-calculated-tls-range
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesReverts llvm/llvm-project#108112 Full diff: https://github.com/llvm/llvm-project/pull/108122.diff 1 Files Affected:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
index 666e6f3b351067..a1107ff7d24737 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
@@ -151,6 +151,10 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
// This may happen inside the DTOR of main thread, so just ignore it.
tls_size = 0;
}
+ if (tls_size) {
+ CHECK_LE(tls_beg, reinterpret_cast<uptr>(res));
+ CHECK_LT(reinterpret_cast<uptr>(res), tls_beg + tls_size);
+ }
dtv->beg = tls_beg;
dtv->size = tls_size;
return dtv;
|
d924f90
to
d92d55f
Compare
d92d55f
to
730ca7d
Compare
You can test this locally with the following command:git-clang-format --diff 695cb55ccb34a3cf659c12e1cbca1b916372a199 98f470287a4671173197fd1cd3c8141d2282144a --extensions c,cpp -- compiler-rt/lib/msan/msan_allocator.cpp compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp compiler-rt/test/asan/TestCases/Linux/stress_dtls.c compiler-rt/test/sanitizer_common/TestCases/Linux/getgrouplist.cpp View the diff from clang-format here.diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/getgrouplist.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/getgrouplist.cpp
index 884d0f2a5e..73d524ae51 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/getgrouplist.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/getgrouplist.cpp
@@ -1,9 +1,9 @@
// RUN: %clangxx -O0 -g %s -o %t && %run %env_tool_opts=verbosity=2 %t
-#include <stdlib.h>
+#include <grp.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
-#include <grp.h>
int main(void) {
gid_t *groups;
|
13141eb
to
8cd22f3
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reland #107941 taking into account that
res
can have non-zero kDtvOffset on some platforms.
Reverts #108112