[compiler-rt] [scudo] Move the chunk update into functions (PR #83493)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 15:52:19 PDT 2024


================
@@ -1162,31 +1219,23 @@ class Allocator {
       Header->State = Chunk::State::Available;
     else
       Header->State = Chunk::State::Quarantined;
-    Header->OriginOrWasZeroed = useMemoryTagging<Config>(Options) &&
-                                Header->ClassId &&
-                                !TSDRegistry.getDisableMemInit();
-    Chunk::storeHeader(Cookie, Ptr, Header);
 
-    if (UNLIKELY(useMemoryTagging<Config>(Options))) {
-      u8 PrevTag = extractTag(reinterpret_cast<uptr>(TaggedPtr));
-      storeDeallocationStackMaybe(Options, Ptr, PrevTag, Size);
-      if (Header->ClassId) {
-        if (!TSDRegistry.getDisableMemInit()) {
-          uptr TaggedBegin, TaggedEnd;
-          const uptr OddEvenMask = computeOddEvenMaskForPointerMaybe(
-              Options, reinterpret_cast<uptr>(getBlockBegin(Ptr, Header)),
-              Header->ClassId);
-          // Exclude the previous tag so that immediate use after free is
-          // detected 100% of the time.
-          setRandomTag(Ptr, Size, OddEvenMask | (1UL << PrevTag), &TaggedBegin,
-                       &TaggedEnd);
-        }
-      }
+    void *BlockBegin;
----------------
ChiaHungDuan wrote:

Sorry I was blocked by other stuff recently.

 This is a little bit more than simply move the code structure. If we want to do that, I may suggest doing this in a follow up so that we can catch up if there's any logic mismatch in this CL and do further clean up later.

https://github.com/llvm/llvm-project/pull/83493


More information about the llvm-commits mailing list