[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 15:41:39 PDT 2024
https://github.com/ChiaHungDuan updated https://github.com/llvm/llvm-project/pull/102367
>From 2c55b860d4395a7b39ccb892a61a9bd117ef3a1b Mon Sep 17 00:00:00 2001
From: Chia-hung Duan <chiahungduan at google.com>
Date: Wed, 7 Aug 2024 21:14:39 +0000
Subject: [PATCH] [scudo] Avoid accessing inaccessible pages in unmap() in
secondary
---
compiler-rt/lib/scudo/standalone/secondary.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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