Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing coverage: Resizable / GrowableSharedArrayBuffers: parameter conversion resizes the underlying buffer #3246

Open
marjakh opened this issue Oct 6, 2021 · 1 comment

Comments

@marjakh
Copy link
Contributor

marjakh commented Oct 6, 2021

In most TypedArray.prototype funcs, it's possible that the underlying ArrayBuffer gets resized when we're converting the parameters.

E.g., for TypedArray.prototype.fill:

  1. Let O be the this value.
  2. Perform ? ValidateTypedArray(O).
  3. Let len be O.[[ArrayLength]]. <<< Reading length here
  4. If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value).
  5. Otherwise, set value to ? ToNumber(value).
  6. Let relativeStart be ? ToIntegerOrInfinity(start). <<<< This might resize the buffer

Further, some TypedArray.prototype funcs take a callback as a parameter and that callback might resize the AB.

v8 has tests for these cases here:
https://source.chromium.org/chromium/chromium/src/ /main:v8/test/mjsunit/typedarray-resizablearraybuffer.js;l=1?ss=chromium

(Search for "ParameterConversionResizes" and "GrowMidIteration" / "ShrinkMidIteration".)

Getting this right is security critical, so would be great to have test262 tests.

cc @jugglinmike

@marjakh
Copy link
Contributor Author

marjakh commented Jan 24, 2022

This also applies to things like SpeciesCreate resizing the buffer (in TypedArray.prototype functions which use it), or the "array-like" getter resizing the buffer in SetTypedArrayFromArrayLike.

Also cc @sarahghp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant