[compiler-rt] e9c9fde - [scudo] Avoid accessing inaccessible pages in unmap() in secondary (#102367)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 15:42:15 PDT 2024
Author: ChiaHungDuan
Date: 2024-08-07T15:42:11-07:00
New Revision: e9c9fde3b766fd2c3904523a9be5e982ce56a825
URL: https://github.com/llvm/llvm-project/commit/e9c9fde3b766fd2c3904523a9be5e982ce56a825
DIFF: https://github.com/llvm/llvm-project/commit/e9c9fde3b766fd2c3904523a9be5e982ce56a825.diff
LOG: [scudo] Avoid accessing inaccessible pages in unmap() in secondary (#102367)
Added:
Modified:
compiler-rt/lib/scudo/standalone/secondary.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h
index a9a7c2c8ea8618..51721fab52cedf 100644
--- a/compiler-rt/lib/scudo/standalone/secondary.h
+++ b/compiler-rt/lib/scudo/standalone/secondary.h
@@ -823,7 +823,11 @@ void MapAllocator<Config>::deallocate(const Options &Options, void *Ptr)
Cache.store(Options, H->CommitBase, H->CommitSize,
reinterpret_cast<uptr>(H + 1), H->MemMap);
} else {
- unmap(H->MemMap);
+ // Note that the `H->MemMap` is stored on the pages managed by itself. Take
+ // over the ownership before unmap() so that any operation along with
+ // unmap() won't touch inaccessible pages.
+ MemMapT MemMap = H->MemMap;
+ unmap(MemMap);
}
}
More information about the llvm-commits
mailing list