Closed Bug 2034837 Opened 6 months ago Closed 6 months ago

Ion-inline WeakMapGetObject skips MarkSymbolForWeakMapReadBarrier

Categories

(Core :: JavaScript Engine: JIT, defect, P1)

defect

Tracking

()

RESOLVED FIXED
152 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox150 + fixed
firefox151 + fixed
firefox152 + fixed

People

(Reporter: jandem, Assigned: iain)

References

(Blocks 1 open bug, Regression)

Details

(6 keywords, Whiteboard: [pp1][adv-main150.0.2+r])

Attachments

(4 external files)

In bug 2029295 we added a MarkSymbolForWeakMapReadBarrier call for values returned by WeakMap.prototype.get, but the same issue also affects the Ion code for Weakmap.prototype.get(object):

// More reliable with --no-threads.

// Object key, Symbol value. Ion-inline WeakMapGetObject skips MarkSymbolForWeakMapReadBarrier.
// After GC, the value Symbol is gray in the zone atom bitmap.
// Pass the Ion-returned Symbol to a native (Object.is) to trigger cx->check -> checkAtom crash.
function f(k) {
  return wm.get(k);
}
with ({}) {} // Don't Ion-compile.
let key = {};
let val = Symbol();
let wm = new WeakMap();
wm.set(key, val);
grayRoot()[0] = key;
key = val = undefined;
gc();
let r = grayRoot()[0];
for (let i = 0; i < 2000; i++) { // warm into Ion
  f({});
}
let sym = f(r);                        // Ion path: returns gray Symbol
Object.is(sym, sym);                   // native call → cx->check(args[0])
[3587998] Hit MOZ_CRASH(*** Atom is marked gray for zone 7404d880c000 at argument 0) at js/src/vm/JSContext-inl.h:111

Claude flagged this difference between the C++ code and the JIT code in an audit looking for these types of issues.

Attached file (secure) —

I left a comment in ExposeGCThingToActiveJS, but didn't consider that valueReadBarrier could have code added to it. There's a comment there now.

We have to pass in the Zone because we can't read it off a symbol that lives in the atom zone.

Assignee: nobody → iireland
Status: NEW → ASSIGNED

:iain, since this bug is a regression, could you fill (if possible) the regressed_by field?
For more information, please visit BugBot documentation.

Flags: needinfo?(iireland)

This bug has been marked as a regression. Setting status flag for Nightly to affected.

Blocks: sm-security
Severity: -- → S2
Priority: -- → P1
Flags: needinfo?(iireland)

Comment on attachment 9573640 [details]
(secure)

Security Approval Request

  • How easily could an exploit be constructed based on the patch?: Similar difficulty to bug 2029295, where we said "very difficult".
  • Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: Yes
  • Which branches (beta, release, and/or ESR) are affected by this flaw, and do the release status flags reflect this affected/unaffected state correctly?: Beta + release. Yes.
  • If not all supported branches, which bug introduced the flaw?: Bug 2000328
  • Do you have backports for the affected branches?: No
  • If not, how different, hard to create, and risky will they be?: The patch should apply cleanly.
  • How likely is this patch to cause regressions; how much testing does it need?: Unlikely (for the same reasons as bug 2029295)
  • Is the patch ready to land after security approval is given?: Yes
  • Is Android affected?: Yes
Attachment #9573640 - Flags: sec-approval?

Comment on attachment 9573640 [details]
(secure)

sec-approval+ to land now and request uplifts.

Attachment #9573640 - Flags: sec-approval? → sec-approval+
Attached file (secure) —

I left a comment in ExposeGCThingToActiveJS, but didn't consider that valueReadBarrier could have code added to it. There's a comment there now.

We have to pass in the Zone because we can't read it off a symbol that lives in the atom zone.

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

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

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Possible crash / security vulnerability.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: yes
  • Steps to reproduce for manual QE testing: None
  • Risk associated with taking this patch: low
  • Explanation of risk level: This is a simple fix.
  • String changes made/needed?: None
  • Is Android affected?: yes
Flags: qe-verify+

firefox-release Uplift Approval Request

  • User impact if declined/Reason for urgency: Possible crash / security vulnerability.
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: yes
  • Steps to reproduce for manual QE testing: None
  • Risk associated with taking this patch: low
  • Explanation of risk level: This is a simple fix.
  • String changes made/needed?: None
  • Is Android affected?: yes
Attachment #9575090 - Flags: approval-mozilla-release?
Attached file (secure) —

I left a comment in ExposeGCThingToActiveJS, but didn't consider that valueReadBarrier could have code added to it. There's a comment there now.

We have to pass in the Zone because we can't read it off a symbol that lives in the atom zone.

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

Whiteboard: [pp1]
Group: javascript-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch

We noticed that the "qe-verify+" label was added on this bug. Can this issue be verified manually? If so, could you please provide specific steps for manual verification?

Flags: needinfo?(iireland)
Attachment #9575089 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

(In reply to Brindusa Tot, DTE from comment #13)

We noticed that the "qe-verify+" label was added on this bug. Can this issue be verified manually? If so, could you please provide specific steps for manual verification?

Sorry, that was a misclick. Unsetting it.

Flags: qe-verify+
Flags: needinfo?(iireland)
Regressions: 2036256

:iain should we wait to uplift bug 2036256 as well?

Flags: needinfo?(iireland)

Yes, that's probably best.

Flags: needinfo?(iireland)

I've queued bug 2036256 for landing. My beta uplift request failed because this patch hasn't been uplifted yet. It should apply cleanly on top of this patch. Please include that patch when you uplift this one. I filled in the uplift request form manually on Bugzilla.

Flags: needinfo?(dsmith)

:iain it shouldnt have failed for beta because this patch is already in beta. For release, i can apply it once i land this, but i worry that the beta one itself needs a rebased patch for bug 2036256.

Flags: needinfo?(dsmith) → needinfo?(iireland)

Hmm. That surprises me. The patch is very local, and nothing else should have touched this code. Please let me know if anything goes wrong with the uplift.

Flags: needinfo?(iireland)
Attachment #9575090 - Flags: approval-mozilla-release? → approval-mozilla-release+
Whiteboard: [pp1] → [pp1][adv-main150.0.2+r]
QA Whiteboard: [sec] [uplift] [qa-triage-done-c152/b151]
Group: core-security-release
Attachment #9574684 - Attachment description: (secure) → Bug 2034837: Add testcase r=jandem
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: