Closed Bug 1970545 Opened 1 year ago Closed 1 year ago

Assertion failure: !values_.has(def) (Discarding a definition still in the set) in js/src/jit/ValueNumbering.cpp

Categories

(Core :: JavaScript: WebAssembly, defect, P1)

defect

Tracking

()

RESOLVED FIXED
141 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr128 --- unaffected
firefox139 --- unaffected
firefox140 --- fixed
firefox141 --- fixed

People

(Reporter: sakura, Assigned: bvisness)

References

(Blocks 1 open bug, Regression)

Details

(4 keywords, Whiteboard: [client-bounty-form][leave closed until 1970713 is open])

Attachments

(1 file, 3 external files)

Attached file poc.js —

Reproduce

  1. Clone the Firefox mirror from https://github.com/mozilla/gecko-dev
  2. Run build command: mkdir fuzzbuild_OPT.OBJ && cd fuzzbuild_OPT.OBJ && ../configure --enable-address-sanitizer --disable-jemalloc --enable-debug --enable-optimize --disable-shared-js --enable-application=js --enable-gczeal && make -j64 in the js/src directory of the firefox checkout
  3. Run poc: fuzzbuild_OPT.OBJ/dist/bin/js poc.js
  • my test spidermonkey commit hash
commit bd57b566959758d0455c6e37afca00648c8e4ff0 (HEAD -> master, origin/master, origin/HEAD)
Author: Michael Froman <mfroman@mozilla.com>
Date:   Fri May 16 14:05:49 2025 -0500

    Bug 1963852 - Vendor libwebrtc from 2c8f5be692
    
    Upstream commit: https://webrtc.googlesource.com/src/+/2c8f5be6924d507ee74191b1aeadcec07f747f21
        Publish guidelines for organizational contributions to WebRTC
    
        Bug: None
        Change-Id: Ie17600e64fb5054ed3baa0f424bdd3adfa728c37
        Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/370440
        Commit-Queue: Harald Alvestrand <hta@webrtc.org>
        Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
        Cr-Commit-Position: refs/heads/main@{#44272}

Bisect

Debug Log

[1571101] Assertion failure: !values_.has(def) (Discarding a definition still in the set), at gecko-dev/js/src/jit/ValueNumbering.cpp:326
#01: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x528fcb2]
#02: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x528f34b]
#03: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x5298054]
#04: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x529873c]
#05: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x529945c]
#06: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x529cbd1]
#07: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x5c07fcc]
#08: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x63a8a87]
#09: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x6334399]
#10: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x6339d9d]
#11: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x62a7704]
#12: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x62d41dc]
#13: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x3427378]
#14: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x342708d]
#15: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x34a294b]
#16: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x34a20bb]
#17: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x34d391b]
#18: ???[/home/sakura/gecko-dev/js/src/fuzzbuild_OPT.OBJ/dist/bin/js +0x2d48e67]
#19: ???[/lib/x86_64-linux-gnu/libc.so.6 +0x94ac3]
#20: ???[/lib/x86_64-linux-gnu/libc.so.6 +0x126a40]
#21: ??? (???:???)
Flags: sec-bounty?
Group: firefox-core-security → core-security
Component: Security → JavaScript: WebAssembly
Product: Firefox → Core
Group: core-security → javascript-core-security

Bug 1968410 from that regression range looks WASM related.

See Also: → 1970563

Using the wasm ref type in a congruentTo check is not safe because the
ref type can change during optimization, specifically now that we take
the LUB when replacing nodes in GVN. Using the ref type hierarchy (if
available) is a stable check.

Assignee: nobody → bvisness
Status: NEW → ASSIGNED

This seems to be occurring because a congruentTo check on two null constants is sometimes returning false and sometimes returning true, depending on how we've changed the ref type of the node. We should no longer use wasmRefType() in congruentTo checks because of this. (I already removed the only other such case in bug 1968410.)

Pernosco with notes: https://pernos.co/debug/DDgAlZ2jUVCwhjH6eirPeQ/index.html#f{m[BGI,AQvAgQ_,t[Aw,kyU_,f{e[BGI,AQvAew_,s{aV7u8QLAA,bBQ,uBQDdSA,oBQwY3w___/

See Also: → 1970713

Thanks for taking a look. Do you think this is exploitable?

Flags: needinfo?(bvisness)
Whiteboard: [client-bounty-form] → [client-bounty-form][leave closed until 1970713 is open]
Duplicate of this bug: 1970563

From discussion with others on the team more familiar with GVN, we feel like it's likely unexploitable but hard to say for sure since it causes some incorrect behavior in the GVN pass itself. Should be fine at sec-moderate.

This and bug 1970713 will need to be uplifted if bug 1968410 is uplifted. I will confer with the team and decide how to proceed.

Flags: needinfo?(bvisness)
Keywords: regression
Regressed by: 1968410
Blocks: sm-security
Severity: -- → S3
Priority: -- → P1

Using the wasm ref type in a congruentTo check is not safe because the
ref type can change during optimization, specifically now that we take
the LUB when replacing nodes in GVN. Using the ref type hierarchy (if
available) is a stable check.

Original Revision: https://phabricator.services.mozilla.com/D252733

Attachment #9493704 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined: Incorrect codegen in some cases, which we believe to not be exploitable. Caused by the patch from bug 1968410, which has also been requested for uplift; if that one is uplifted, this one should be as well.
  • Code covered by automated testing: no
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: n/a
  • Risk associated with taking this patch: Low
  • Explanation of risk level: This reverts to previously-existing logic that had held up under testing. (A recent patch invalidated the old implementation of this logic.)
  • String changes made/needed: n/a
  • Is Android affected?: yes
Group: javascript-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Flags: in-testsuite?
Resolution: --- → FIXED
Target Milestone: --- → 141 Branch
Attachment #9493704 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [sec] [qa-triage-done-c141/b140]
Flags: qe-verify-
Flags: sec-bounty? → sec-bounty+

Bounty split with bug 1970563

Group: core-security-release

Backed out for causing SM bustages

Backout link

Push with failures

Failure log
Failure log 2

Flags: needinfo?(bvisness)
Flags: needinfo?(bvisness)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: