Revert "[platform] Remove {PageAllocator::kReadWriteExecute}."
This reverts commit bf19e60cc5
.
Reason for revert: Two issues discovered with W^X in V8's 6.5 branch (see v8:7272 and chromium:793428). Still need a way to disable the feature.
Original change's description:
> [platform] Remove {PageAllocator::kReadWriteExecute}.
>
> Now that write-protection of code memory is enabled everywhere and V8 is
> fully W^X compliant, we can remove the permission mode in question.
>
> R=hpayer@chromium.org
> BUG=v8:6792
>
> Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
> Change-Id: I80fe95ac6bb0e2d1ad6d993154ce45d492d941be
> Reviewed-on: https://chromium-review.googlesource.com/866855
> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
> Reviewed-by: Hannes Payer <hpayer@chromium.org>
> Reviewed-by: Bill Budge <bbudge@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#50770}
TBR=bbudge@chromium.org,mstarzinger@chromium.org,hpayer@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:6792
Change-Id: If4a205497ac83084a4092560363affb13b391462
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/883461
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50834}
This commit is contained in:
parent
92d8e450ec
commit
db7bdf4829
@ -200,11 +200,13 @@ class PageAllocator {
|
||||
virtual void* GetRandomMmapAddr() = 0;
|
||||
|
||||
/**
|
||||
* Memory permissions. Note that V8 is W^X compliant.
|
||||
* Memory permissions.
|
||||
*/
|
||||
enum Permission {
|
||||
kNoAccess,
|
||||
kReadWrite,
|
||||
// TODO(hpayer): Remove this flag. Memory should never be rwx.
|
||||
kReadWriteExecute,
|
||||
kReadExecute
|
||||
};
|
||||
|
||||
|
@ -17,6 +17,8 @@ STATIC_ASSERT_ENUM(PageAllocator::kNoAccess,
|
||||
base::OS::MemoryPermission::kNoAccess);
|
||||
STATIC_ASSERT_ENUM(PageAllocator::kReadWrite,
|
||||
base::OS::MemoryPermission::kReadWrite);
|
||||
STATIC_ASSERT_ENUM(PageAllocator::kReadWriteExecute,
|
||||
base::OS::MemoryPermission::kReadWriteExecute);
|
||||
STATIC_ASSERT_ENUM(PageAllocator::kReadExecute,
|
||||
base::OS::MemoryPermission::kReadExecute);
|
||||
|
||||
|
@ -36,6 +36,8 @@ DWORD GetProtectionFromMemoryPermission(OS::MemoryPermission access) {
|
||||
return PAGE_NOACCESS;
|
||||
case OS::MemoryPermission::kReadWrite:
|
||||
return PAGE_READWRITE;
|
||||
case OS::MemoryPermission::kReadWriteExecute:
|
||||
return PAGE_EXECUTE_READWRITE;
|
||||
case OS::MemoryPermission::kReadExecute:
|
||||
return PAGE_EXECUTE_READ;
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ uint32_t GetProtectionFromMemoryPermission(OS::MemoryPermission access) {
|
||||
return 0; // no permissions
|
||||
case OS::MemoryPermission::kReadWrite:
|
||||
return ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE;
|
||||
case OS::MemoryPermission::kReadWriteExecute:
|
||||
return ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE |
|
||||
ZX_VM_FLAG_PERM_EXECUTE;
|
||||
case OS::MemoryPermission::kReadExecute:
|
||||
return ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_EXECUTE;
|
||||
}
|
||||
|
@ -109,6 +109,8 @@ int GetProtectionFromMemoryPermission(OS::MemoryPermission access) {
|
||||
return PROT_NONE;
|
||||
case OS::MemoryPermission::kReadWrite:
|
||||
return PROT_READ | PROT_WRITE;
|
||||
case OS::MemoryPermission::kReadWriteExecute:
|
||||
return PROT_READ | PROT_WRITE | PROT_EXEC;
|
||||
case OS::MemoryPermission::kReadExecute:
|
||||
return PROT_READ | PROT_EXEC;
|
||||
}
|
||||
|
@ -747,6 +747,8 @@ DWORD GetProtectionFromMemoryPermission(OS::MemoryPermission access) {
|
||||
return PAGE_NOACCESS;
|
||||
case OS::MemoryPermission::kReadWrite:
|
||||
return PAGE_READWRITE;
|
||||
case OS::MemoryPermission::kReadWriteExecute:
|
||||
return PAGE_EXECUTE_READWRITE;
|
||||
case OS::MemoryPermission::kReadExecute:
|
||||
return PAGE_EXECUTE_READ;
|
||||
}
|
||||
|
@ -156,12 +156,12 @@ class V8_BASE_EXPORT OS {
|
||||
static PRINTF_FORMAT(1, 0) void VPrintError(const char* format, va_list args);
|
||||
|
||||
// Memory permissions. These should be kept in sync with the ones in
|
||||
// v8::PageAllocator. Note that there is on purpose no combination of
|
||||
// the "write" and "execute" permission, because V8 is W^X compliant.
|
||||
// Avoid introducing such a combination as embedders might rely on it.
|
||||
// v8::PageAllocator.
|
||||
enum class MemoryPermission {
|
||||
kNoAccess,
|
||||
kReadWrite,
|
||||
// TODO(hpayer): Remove this flag. Memory should never be rwx.
|
||||
kReadWriteExecute,
|
||||
kReadExecute
|
||||
};
|
||||
|
||||
|
@ -573,8 +573,8 @@ static inline uint8_t* AllocateAssemblerBuffer(
|
||||
size_t requested = v8::internal::AssemblerBase::kMinimalBufferSize) {
|
||||
size_t page_size = v8::internal::AllocatePageSize();
|
||||
size_t alloc_size = RoundUp(requested, page_size);
|
||||
void* result = v8::internal::AllocatePages(nullptr, alloc_size, page_size,
|
||||
v8::PageAllocator::kReadWrite);
|
||||
void* result = v8::internal::AllocatePages(
|
||||
nullptr, alloc_size, page_size, v8::PageAllocator::kReadWriteExecute);
|
||||
CHECK(result);
|
||||
*allocated = alloc_size;
|
||||
return static_cast<uint8_t*>(result);
|
||||
|
@ -111,7 +111,7 @@ sigjmp_buf MemoryAllocationPermissionsTest::continuation_;
|
||||
TEST_F(MemoryAllocationPermissionsTest, DoTest) {
|
||||
TestPermissions(PageAllocator::Permission::kNoAccess, false, false);
|
||||
TestPermissions(PageAllocator::Permission::kReadWrite, true, true);
|
||||
TestPermissions(PageAllocator::Permission::kReadExecute, true, false);
|
||||
TestPermissions(PageAllocator::Permission::kReadWriteExecute, true, true);
|
||||
}
|
||||
#endif // V8_OS_POSIX
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user