Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions compiler-rt/lib/scudo/standalone/secondary.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ class MapAllocatorCache {
Entry.MemMap = MemMap;
Entry.Time = UINT64_MAX;

if (useMemoryTagging<Config>(Options)) {
bool MemoryTaggingEnabled = useMemoryTagging<Config>(Options);
if (MemoryTaggingEnabled) {
if (Interval == 0 && !SCUDO_FUCHSIA) {
// Release the memory and make it inaccessible at the same time by
// creating a new MAP_NOACCESS mapping on top of the existing mapping.
Expand Down Expand Up @@ -302,15 +303,16 @@ class MapAllocatorCache {
if (Entry.Time != 0)
Entry.Time = Time;

if (useMemoryTagging<Config>(Options) && QuarantinePos == -1U) {
if (MemoryTaggingEnabled && !useMemoryTagging<Config>(Options)) {
// If we get here then memory tagging was disabled in between when we
// read Options and when we locked Mutex. We can't insert our entry into
// the quarantine or the cache because the permissions would be wrong so
// just unmap it.
unmapCallBack(Entry.MemMap);
break;
}
if (Config::getQuarantineSize() && useMemoryTagging<Config>(Options)) {

if (Config::getQuarantineSize()) {
QuarantinePos =
(QuarantinePos + 1) % Max(Config::getQuarantineSize(), 1u);
if (!Quarantine[QuarantinePos].isValid()) {
Expand Down Expand Up @@ -513,9 +515,10 @@ class MapAllocatorCache {
Quarantine[I].invalidate();
}
}
QuarantinePos = -1U;

for (CachedBlock &Entry : LRUEntries)
Entry.MemMap.setMemoryPermission(Entry.CommitBase, Entry.CommitSize, 0);
QuarantinePos = -1U;
}

void disable() NO_THREAD_SAFETY_ANALYSIS { Mutex.lock(); }
Expand Down
Loading