Skip to content

Commit 957af73

Browse files
authored
[sanitizer] Add CHECKs to validate calculated TLS range (#107941)
1 parent d452429 commit 957af73

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
151151
// This may happen inside the DTOR of main thread, so just ignore it.
152152
tls_size = 0;
153153
}
154+
if (tls_size) {
155+
CHECK_LE(tls_beg, reinterpret_cast<uptr>(res));
156+
CHECK_LT(reinterpret_cast<uptr>(res), tls_beg + tls_size);
157+
}
154158
dtv->beg = tls_beg;
155159
dtv->size = tls_size;
156160
return dtv;

0 commit comments

Comments
 (0)