Skip to content

Commit e9c9fde

Browse files
authored
[scudo] Avoid accessing inaccessible pages in unmap() in secondary (#102367)
1 parent 89c8d68 commit e9c9fde

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler-rt/lib/scudo/standalone/secondary.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,11 @@ void MapAllocator<Config>::deallocate(const Options &Options, void *Ptr)
823823
Cache.store(Options, H->CommitBase, H->CommitSize,
824824
reinterpret_cast<uptr>(H + 1), H->MemMap);
825825
} else {
826-
unmap(H->MemMap);
826+
// Note that the `H->MemMap` is stored on the pages managed by itself. Take
827+
// over the ownership before unmap() so that any operation along with
828+
// unmap() won't touch inaccessible pages.
829+
MemMapT MemMap = H->MemMap;
830+
unmap(MemMap);
827831
}
828832
}
829833

0 commit comments

Comments
 (0)