[compiler-rt] [scudo] Support no-preserve-all-regions mode (PR #85149)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 27 14:43:24 PDT 2024
================
@@ -601,6 +593,35 @@ template <typename Config> class SizeClassAllocator64 {
return BlockSize > PageSize;
}
+ void initRegion(RegionInfo *Region, uptr ClassId, MemMapT MemMap,
+ bool EnableRandomOffset) REQUIRES(Region->MMLock) {
+ DCHECK(!Region->MemMapInfo.MemMap.isAllocated());
+ DCHECK(MemMap.isAllocated());
+
+ const uptr PageSize = getPageSizeCached();
+ const uptr RegionBase = MemMap.getBase();
+
+ Region->MemMapInfo.MemMap = MemMap;
+
+ u32 Seed;
+ const u64 Time = getMonotonicTimeFast();
+ if (!getRandom(reinterpret_cast<void *>(&Seed), sizeof(Seed)))
+ Seed = static_cast<u32>(Time ^ (RegionBase >> 12));
+
+ Region->RegionBeg = RegionBase;
+ if (EnableRandomOffset)
+ Region->RegionBeg += (getRandomModN(&Seed, 16) + 1) * PageSize;
----------------
ChiaHungDuan wrote:
I forgot to store the Seed to RandState which is used at block shuffling.
Fixed.
https://github.com/llvm/llvm-project/pull/85149
More information about the llvm-commits
mailing list