Commit 47210f48 authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Always call zx_vmo_replace_as_executable() in OS::Allocate()

OS::Allocate() previously was calling zx_vmo_replace_as_executable()
when executable access is requested. This breaks the case when the
OS::SetPermission() is called to mark that memory as executable later.
Updated it to call zx_vmo_replace_as_executable() for all VMOs.

This solution is not ideal, but it's consistent with other platforms,
so it's acceptable short-term.

Bug: v8:8899, chromium:934582
Change-Id: Ifeb818c93d8b9c80e73a057f5e6f3ca5a7b1c23f
Reviewed-on: https://chromium-review.googlesource.com/c/1483613Reviewed-by: 's avatarWez <wez@chromium.org>
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59880}
parent 8337a29b
......@@ -54,13 +54,17 @@ void* OS::Allocate(void* address, size_t size, size_t alignment,
static const char kVirtualMemoryName[] = "v8-virtualmem";
zx_object_set_property(vmo, ZX_PROP_NAME, kVirtualMemoryName,
strlen(kVirtualMemoryName));
// Always call zx_vmo_replace_as_executable() in case the memory will need
// to be marked as executable in the future.
// TOOD(https://crbug.com/v8/8899): Only call this when we know that the
// region will need to be marked as executable in the future.
if (zx_vmo_replace_as_executable(vmo, ZX_HANDLE_INVALID, &vmo) != ZX_OK) {
return nullptr;
}
uintptr_t reservation;
uint32_t prot = GetProtectionFromMemoryPermission(access);
if ((prot & ZX_VM_PERM_EXECUTE) != 0) {
if (zx_vmo_replace_as_executable(vmo, ZX_HANDLE_INVALID, &vmo) != ZX_OK) {
return nullptr;
}
}
zx_status_t status = zx_vmar_map(zx_vmar_root_self(), prot, 0, vmo, 0,
request_size, &reservation);
// Either the vmo is now referenced by the vmar, or we failed and are bailing,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment