[JSPI] Potential stale WasmArrayData pointer on suspended JSPI stack across minor GC in optimizing wasm tier
Categories
(Core :: JavaScript: WebAssembly, defect)
Tracking
()
People
(Reporter: gaddofpwn, Unassigned)
References
Details
(Keywords: reporter-external, unsupported-config, Whiteboard: [client-bounty-form])
Attachments
(1 file)
|
1.23 KB,
text/javascript
|
Details |
The issue appears to be that suspended wasm stacks are traced during GC, but their WasmArrayData/WasmStructData stack slots are not updated by the moving-GC patch-up path. As a result, after resuming from a suspended stack, wasm code can continue using stale data pointers.
On my local Linux x86_64 build, this reproduces as a corrupted array read in optimized wasm code after a suspend/resume cycle that triggers minor GC. The final result becomes a poisoned-looking value instead of the expected integer sum.
Environment
- Platform: Linux x86_64
- Reproduced with SpiderMonkey shell at:
/home/user/firefox/obj-x86_64-pc-linux-gnu/dist/bin/js
Configuration
This currently reproduces with: - pref: javascript.options.wasm_js_promise_integration=true
- shell arg: --wasm-compiler=optimizing
Steps to Reproduce
obj-x86_64-pc-linux-gnu/dist/bin/js
--setpref=wasm_js_promise_integration=true
--wasm-compiler=optimizing
scratch/jspi-suspended-array-standalone.js
Updated•7 months ago
|
Actual Security Impact
This looks like a stale pointer / use-after-move condition on suspended wasm stacks in the optimizing tier. The immediate symptom is
an incorrect read from wasm GC array storage after resume. I have not developed a full exploit, but the bug appears to violate memory
safety and seems potentially exploitable.
Root Cause Analysis
The relevant paths appear to be:
- Active wasm activations get moving-GC stack-slot patch-up via UpdateJitActivationsForMinorGC / UpdateJitActivationsForCompactingGC
and Instance::updateFrameForMovingGC. - Suspended JSPI stacks are traced separately via TraceSuspendableStack during GC.
- That trace path calls Instance::traceFrame, which traces AnyRef values but does not patch WasmArrayDataPointer / StructDataPointer
stack-map entries. - Optimizing wasm safepoints explicitly record ArrayDataPointer / StructDataPointer in stack maps.
- The wasm optimizer also assumes array data pointers are rewritten by GC across calls.
In other words, suspended stacks seem to go through “trace” but not “moving-GC pointer rewrite”, which leaves stale wasm data
pointers live across suspend/resume.
Updated•7 months ago
|
Comment 2•7 months ago
|
||
Thanks for the report! This is a duplicate of bug 2008358.
Updated•7 months ago
|
Updated•2 months ago
|
Description
•