Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8debb4e

Browse files
mdempskycommit-bot@chromium.org
authored andcommitted
[fuchsia] Add zx_vmo_replace_as_executable calls
In the future, newly created VMOs on Fuchsia will not be mappable as executable by default. In preparation for that, start using zx_vmo_replace_as_executable to mark Fuchsia's VMOs as executable as needed. SEC-42 TEST=CQ Change-Id: I9df86bbb33b02042260727d64e74b7146eb1d1a6 Reviewed-on: https://dart-review.googlesource.com/76304 Reviewed-by: Zach Anderson <[email protected]> Commit-Queue: Zach Anderson <[email protected]>
1 parent d34337a commit 8debb4e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

runtime/vm/virtual_memory_fuchsia.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ VirtualMemory* VirtualMemory::Allocate(intptr_t size,
5757
zx_object_set_property(vmo, ZX_PROP_NAME, name, strlen(name));
5858
}
5959

60+
if (is_executable) {
61+
// Add ZX_PERM_EXECUTE permission to VMO, so it can be mapped
62+
// into memory as executable.
63+
status = zx_vmo_replace_as_executable(vmo, ZX_HANDLE_INVALID, &vmo);
64+
if (status != ZX_OK) {
65+
LOG_ERR("zx_vmo_replace_as_executable() failed: %s\n",
66+
zx_status_get_string(status));
67+
return NULL;
68+
}
69+
}
70+
6071
const uint32_t flags = ZX_VM_PERM_READ | ZX_VM_PERM_WRITE |
6172
(is_executable ? ZX_VM_PERM_EXECUTE : 0);
6273
uword address;
@@ -94,6 +105,17 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size,
94105
zx_object_set_property(vmo, ZX_PROP_NAME, name, strlen(name));
95106
}
96107

108+
if (is_executable) {
109+
// Add ZX_PERM_EXECUTE permission to VMO, so it can be mapped
110+
// into memory as executable.
111+
status = zx_vmo_replace_as_executable(vmo, ZX_HANDLE_INVALID, &vmo);
112+
if (status != ZX_OK) {
113+
LOG_ERR("zx_vmo_replace_as_executable() failed: %s\n",
114+
zx_status_get_string(status));
115+
return NULL;
116+
}
117+
}
118+
97119
const zx_vm_option_t options = ZX_VM_PERM_READ | ZX_VM_PERM_WRITE |
98120
(is_executable ? ZX_VM_PERM_EXECUTE : 0);
99121
uword base;

0 commit comments

Comments
 (0)