[sandbox] Enable the sandbox by default in V8 builds

This change makes the default configuration of standalone V8 builds
(again) reflect the default configuration of V8 in Chromium builds.

Bug: v8:10391
Change-Id: Ia98492a283772ebfde43f0edbfdff05319ac4352
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3913345
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Samuel Groß <saelo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83390}
This commit is contained in:
Samuel Groß 2022-09-22 13:26:10 +00:00 committed by V8 LUCI CQ
parent a89e10fd33
commit a8c27fcc9f
3 changed files with 16 additions and 9 deletions

View File

@ -521,9 +521,8 @@ if (v8_enable_sandbox == "") {
# once that is enabled everywhere by default.
# TODO(chromium:1325784) the sandbox is not currently supported in Chromium
# on Fuchsia.
v8_enable_sandbox =
build_with_chromium && v8_enable_pointer_compression_shared_cage &&
v8_enable_external_code_space && target_os != "fuchsia"
v8_enable_sandbox = v8_enable_pointer_compression_shared_cage &&
v8_enable_external_code_space && target_os != "fuchsia"
}
# Enable all available sandbox features if sandbox future is enabled.

View File

@ -8128,12 +8128,12 @@ std::unique_ptr<v8::BackingStore> v8::ArrayBuffer::NewBackingStore(
void* deleter_data) {
CHECK_LE(byte_length, i::JSArrayBuffer::kMaxByteLength);
#ifdef V8_ENABLE_SANDBOX
Utils::ApiCheck(
!data || i::GetProcessWideSandbox()->Contains(data),
"v8_ArrayBuffer_NewBackingStore",
"When the V8 Sandbox is enabled, ArrayBuffer backing stores must be "
"allocated inside the sandbox address space. Please use an appropriate "
"ArrayBuffer::Allocator to allocate these buffers.");
Utils::ApiCheck(!data || i::GetProcessWideSandbox()->Contains(data),
"v8_ArrayBuffer_NewBackingStore",
"When the V8 Sandbox is enabled, ArrayBuffer backing stores "
"must be allocated inside the sandbox address space. Please "
"use an appropriate ArrayBuffer::Allocator to allocate these "
"buffers, or disable the sandbox.");
#endif // V8_ENABLE_SANDBOX
std::unique_ptr<i::BackingStoreBase> backing_store =

View File

@ -280,6 +280,14 @@ std::unique_ptr<BackingStore> BackingStore::Allocate(
counters->array_buffer_new_size_failures()->AddSample(mb_length);
return {};
}
#ifdef V8_ENABLE_SANDBOX
// Check to catch use of a non-sandbox-compatible ArrayBufferAllocator.
CHECK_WITH_MSG(GetProcessWideSandbox()->Contains(buffer_start),
"When the V8 Sandbox is enabled, ArrayBuffer backing stores "
"must be allocated inside the sandbox address space. Please "
"use an appropriate ArrayBuffer::Allocator to allocate "
"these buffers, or disable the sandbox.");
#endif
}
auto result = new BackingStore(buffer_start, // start