Change information
Commit message:
[builtins] Fix external-string UAF in StringSubstring on GC transition
SubString's external path hands AllocAndCopyStringCharacters a raw
pointer into the external resource, then allocates the result; a GC
during that allocation can internalize the source in place. 692245fd4b3
added a post-allocation re-check for sequential sources but skipped
external ones as unable to transition, an assumption dc19ad0e517 then
broke by internalizing one-byte-content external two-byte strings to a
non-external copy, which frees the resource and dangles the pointer.
Reading the freed memory trips the two-byte-to-one-byte CSA_DCHECK on
x64 (a heap-use-after-free on arm, garbage in release). Thread the
tagged source through and bail to the runtime if it is no longer
external after the allocation.
Fixed: 537813778
Change-Id: Id9be7b36627ad10935b13d110e2db68976e5437c
Cr-Commit-Position: refs/heads/main@{#108862}
Files:
- M src/builtins/builtins-string-gen.cc
- M src/builtins/builtins-string-gen.h
- M test/mjsunit/mjsunit.status
- A test/mjsunit/regress/regress-537813778.js
Change size: M
Delta: 4 files changed, 48 insertions(+), 17 deletions(-)
Branch: refs/heads/main
Submit Requirements:
Code-Review: +1 by Olivier Flückiger