[compiler-rt] 1abcf58 - [lsan][Fuchsia] Fix bounds checking for thread_local allocator cache when scanning TLS regions

Leonard Chan via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 13:50:45 PDT 2023


Author: Leonard Chan
Date: 2023-08-30T20:49:21Z
New Revision: 1abcf584023e400e33ed66ab9042f75990adbf4c

URL: https://github.com/llvm/llvm-project/commit/1abcf584023e400e33ed66ab9042f75990adbf4c
DIFF: https://github.com/llvm/llvm-project/commit/1abcf584023e400e33ed66ab9042f75990adbf4c.diff

LOG: [lsan][Fuchsia] Fix bounds checking for thread_local allocator cache when scanning TLS regions

When scanning over TLS regions, we attempt to check if one of the regions is
one of the thread_local allocator caches which would be located in one of the
TLS blocks pointer to by the DTV. This is to prevent marking a pointer that was
allocated by the primary allocator (from a thread_local cache) as reachable. The
check is a simple bounds check to see if the allocator cache is within the
bounds of one of the TLS block we're iterating over, but it looks like the check
for the end of the cache is slightly incorrect.

Differential Revision: https://reviews.llvm.org/D156015

Added: 
    

Modified: 
    compiler-rt/lib/lsan/lsan_common_fuchsia.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp b/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp
index bcad1c205fc7aa..0aee77ebd53497 100644
--- a/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp
+++ b/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp
@@ -119,7 +119,7 @@ void LockStuffAndStopTheWorld(StopTheWorldCallback callback,
     auto i = __sanitizer::InternalLowerBound(params->allocator_caches, begin);
     if (i < params->allocator_caches.size() &&
         params->allocator_caches[i] >= begin &&
-        end - params->allocator_caches[i] <= sizeof(AllocatorCache)) {
+        end - params->allocator_caches[i] >= sizeof(AllocatorCache)) {
       // Split the range in two and omit the allocator cache within.
       ScanRangeForPointers(begin, params->allocator_caches[i],
                            &params->argument->frontier, "TLS", kReachable);


        


More information about the llvm-commits mailing list