[compiler-rt] [scudo] Avoid accessing inaccessible pages in unmap() in secondary (PR #102367)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 14:18:26 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: None (ChiaHungDuan)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/102367.diff
1 Files Affected:
- (modified) compiler-rt/lib/scudo/standalone/secondary.h (+5-1)
``````````diff
diff --git a/compiler-rt/lib/scudo/standalone/secondary.h b/compiler-rt/lib/scudo/standalone/secondary.h
index a9a7c2c8ea8618..27d11dce646dc3 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->MapMap` 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);
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/102367
More information about the llvm-commits
mailing list