Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Unified Diff: src/base/platform/platform-posix.cc

Issue 2396433008: [wasm] Add guard regions to end of WebAssembly.Memory buffers (Closed)
Patch Set: Merging with master Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/base/platform/platform-linux.cc ('k') | src/base/platform/platform-win32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/platform/platform-posix.cc
diff --git a/src/base/platform/platform-posix.cc b/src/base/platform/platform-posix.cc
index 3f4165de536c1f2047fc40dc248fd2158413598f..fd47931b6b0cfae2ea96c8efdb32727c2cdf373c 100644
--- a/src/base/platform/platform-posix.cc
+++ b/src/base/platform/platform-posix.cc
@@ -99,6 +99,20 @@ intptr_t OS::CommitPageSize() {
return page_size;
}
+void* OS::AllocateGuarded(const size_t requested) {
+ size_t allocated = 0;
+ const bool is_executable = false;
+ void* mbase = OS::Allocate(requested, &allocated, is_executable);
+ if (allocated != requested) {
+ OS::Free(mbase, allocated);
+ return nullptr;
+ }
+ if (mbase == nullptr) {
+ return nullptr;
+ }
+ OS::Guard(mbase, requested);
+ return mbase;
+}
void OS::Free(void* address, const size_t size) {
// TODO(1240712): munmap has a return value which is ignored here.
@@ -129,6 +143,15 @@ void OS::Guard(void* address, const size_t size) {
#endif
}
+// Make a region of memory readable and writable.
+void OS::Unprotect(void* address, const size_t size) {
+#if V8_OS_CYGWIN
+ DWORD oldprotect;
+ VirtualProtect(address, size, PAGE_READWRITE, &oldprotect);
+#else
+ mprotect(address, size, PROT_READ | PROT_WRITE);
+#endif
+}
static LazyInstance<RandomNumberGenerator>::type
platform_random_number_generator = LAZY_INSTANCE_INITIALIZER;
« no previous file with comments | « src/base/platform/platform-linux.cc ('k') | src/base/platform/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698