reject growable SharedArrayBuffer without hooks#1523
Open
jdcaperon wants to merge 1 commit into
Open
Conversation
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.
This PR is AI assisted and human reviewed to the limits of the human, feel free to close and I can re-raise as an issue.
In
quickjs.c,js_array_buffer_constructor3()allowed growableSharedArrayBufferconstruction without SAB allocator hooks.Context
Growable
SharedArrayBufferconstruction could succeed on runtimes created withJS_NewRuntime()when the embedder had not installed SharedArrayBuffer allocator hooks.In that configuration, construction allocated only the initial
byteLength, whileSharedArrayBuffer.prototype.grow()later assumed the backing store coveredmaxByteLengthand only updated the logical byte length.That mismatch could let typed array and DataView access reach beyond the native allocation after growth.
Intent
Fail closed during JS-created growable
SharedArrayBufferconstruction whensab_allocis unavailable.Fixed-length
SharedArrayBufferconstruction remains allowed without hooks. Runtimes that install SAB allocator hooks can still construct and grow SABs backed by the upfrontmaxByteLengthallocation.The C API regression coverage checks the default-runtime rejection path, preserves fixed-length SAB behavior, and verifies hooked-runtime growth exposes zero-filled bytes beyond the initial length.