src: support V8 sandbox memory cage in allocators#62237
Open
codebytere wants to merge 1 commit intonodejs:mainfrom
Open
src: support V8 sandbox memory cage in allocators#62237codebytere wants to merge 1 commit intonodejs:mainfrom
codebytere wants to merge 1 commit intonodejs:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #62237 +/- ##
==========================================
- Coverage 89.67% 89.66% -0.02%
==========================================
Files 676 676
Lines 206469 206503 +34
Branches 39537 39543 +6
==========================================
+ Hits 185157 185161 +4
- Misses 13448 13457 +9
- Partials 7864 7885 +21
🚀 New features to boost your workflow:
|
When V8_ENABLE_SANDBOX is enabled, all ArrayBuffer backing stores must be allocated within the V8 memory cage — external pointers cannot be directly wrapped and must be copied into V8-managed memory instead. This commit refactors allocators in node_buffer.cc, node_serdes.cc, and node_trace_events.cc to route allocations through ArrayBuffer::Allocator::NewDefaultAllocator() when the sandbox is enabled, ensuring memory lands inside the cage. In node_serdes.cc, ValueSerializer::Delegate is also extended with ReallocateBufferMemory/FreeBufferMemory overrides so the serializer's internal buffer is cage-allocated from the start.
04bfcd6 to
78e9555
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
V8_ENABLE_SANDBOXis enabled, all ArrayBuffer backing stores must be allocated within the V8 memory cage — external pointers cannot be directly wrapped and must be copied into V8-managed memory instead. This commit refactors allocators innode_buffer.cc,node_serdes.cc, andnode_trace_events.ccto route allocations throughArrayBuffer::Allocator::NewDefaultAllocator()when the sandbox is enabled, ensuring memory lands inside the cage. Innode_serdes.cc,ValueSerializer::Delegateis also extended withReallocateBufferMemory/FreeBufferMemoryoverrides so the serializer's internal buffer is cage-allocated from the start.Tested by making the following change:
and running with
./configure --ninja --experimental-enable-pointer-compressionThis allows Electron to reduce/remove a patch.