[compiler-rt] fe30963 - [scudo] Untag BlockEnd in reallocate

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 1 13:03:13 PDT 2021


Author: Vitaly Buka
Date: 2021-07-01T13:02:58-07:00
New Revision: fe30963600ea579d4046c9a92c6e38cc2be0e9a2

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

LOG: [scudo] Untag BlockEnd in reallocate

If we get here from reallocate, BlockEnd is tagged. Then we
will storeTag(UntaggedEnd) into the header of the next chunk.

Luckily header tag is 0 so unpatched code still works.

Reviewed By: pcc

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

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/combined.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/combined.h b/compiler-rt/lib/scudo/standalone/combined.h
index e8bb8bf207be..fd5360ce0f55 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -639,7 +639,7 @@ class Allocator {
           if (ClassId) {
             resizeTaggedChunk(reinterpret_cast<uptr>(OldTaggedPtr) + OldSize,
                               reinterpret_cast<uptr>(OldTaggedPtr) + NewSize,
-                              NewSize, BlockEnd);
+                              NewSize, untagPointer(BlockEnd));
             storePrimaryAllocationStackMaybe(Options, OldPtr);
           } else {
             storeSecondaryAllocationStackMaybe(Options, OldPtr, NewSize);
@@ -1154,6 +1154,7 @@ class Allocator {
   // address tags against chunks. To allow matching in this case we store the
   // address tag in the first byte of the chunk.
   void storeEndMarker(uptr End, uptr Size, uptr BlockEnd) {
+    DCHECK_EQ(BlockEnd, untagPointer(BlockEnd));
     uptr UntaggedEnd = untagPointer(End);
     if (UntaggedEnd != BlockEnd) {
       storeTag(UntaggedEnd);


        


More information about the llvm-commits mailing list