Closed Bug 1301343 Opened 8 years ago Closed 8 years ago

Investigate tracing of data belong to helper threads

Categories

(Core :: JavaScript: GC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox49 --- wontfix
firefox-esr45 50+ fixed
firefox50 --- fixed
firefox51 --- fixed
firefox52 + fixed

People

(Reporter: jonco, Assigned: jandem)

References

(Blocks 1 open bug)

Details

(Keywords: sec-critical, Whiteboard: [post-critsmash-triage][adv-main50+][adv-esr45.5+])

Crash Data

Attachments

(2 files, 1 obsolete file)

As noted in bug 1292590, off thread ion compilations hold GC pointers and the current design (cancel compilation when we start sweeping) may be insufficient.
Ideas from Jan on IRC:

we could maintain a linked list of GC pointers stored in MIR instructions. If we only add to the list in IonBuilder (main thread), it should be safe for the GC to trace that list if the builder is off-thread

There are also TI things to look at, and we may duplicate MIR instructions off-thread, that wouldn't work well with moving GC
Hiding this just to be sure.

I think an IonGCPointer<T> class makes sense. We would use that at least for the script pointer stored in CompileInfo. This class could maintain a linked list stored in TempAllocator. (We used to have something like that at some point, but then we removed it.)

A lot of pointers in MIR instructions come directly from one of the scripts (atoms in particular). Maybe we could use a special type for these and not add them to the list, but that optimization might not be worth it.
Group: javascript-core-security
Flags: needinfo?(jdemooij)
Blocks: 1297062
Blocks: 1295039
Keywords: sec-audit
A linked list doesn't work or a number of reasons: MConstant uses a union, other MIR instructions use a (resizable) Vector, etc.

There's actually a much nicer and more efficient design I want to work out today.
Attached patch Patch (obsolete) — Splinter Review
I tried a few different designs today. I think this one is the most simple.

This patch:

(1) Ensures we also trace IonBuilders that are currently being compiled or are in the lazy link list.

(2) Adds a separate pass to append scripts and all GC pointers stored in MIR instructions to an MRootList class. IonBuilder::trace then traces these pointers.

I verified this fixes the fuzz tests in bug 1295039 comment 5 and bug 1297062.
Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Flags: needinfo?(jdemooij)
Attachment #8789831 - Flags: review?(nicolas.b.pierron)
Attachment #8789831 - Flags: review?(jcoppeard)
Comment on attachment 8789831 [details] [diff] [review]
Patch

Review of attachment 8789831 [details] [diff] [review]:
-----------------------------------------------------------------

This looks really nice.  Thanks for fixing this!
Attachment #8789831 - Flags: review?(jcoppeard) → review+
Comment on attachment 8789831 [details] [diff] [review]
Patch

Review of attachment 8789831 [details] [diff] [review]:
-----------------------------------------------------------------

nit: MLoadTypedArrayElementStatic::appendRoots  and  MNewNamedLambdaObject::appendRoots  are missing.
Attachment #8789831 - Flags: review?(nicolas.b.pierron) → review+
Attached patch Updated patchSplinter Review
Updated patch. Good eye, Nicolas! :)
Attachment #8794191 - Flags: review+
Attachment #8789831 - Attachment is obsolete: true
Comment on attachment 8794191 [details] [diff] [review]
Updated patch

[Security approval request comment]
> How easily could an exploit be constructed based on the patch?
Not easily... Maybe with some effort.

> Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
No.

> Which older supported branches are affected by this flaw?
All.

> If not all supported branches, which bug introduced the flaw?
Something exposed this recently. I think we should just land this everywhere to be safe.

> Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
Shouldn't be too hard to backport.

> How likely is this patch to cause regressions; how much testing does it need?
Need to keep an eye on benchmark performance on AWFY, but other than that it should be pretty safe.
Attachment #8794191 - Flags: sec-approval?
Bug 1292590 should land everywhere first.
Makes sense to track this for 52.
Comment on attachment 8794191 [details] [diff] [review]
Updated patch

As a sec-audit issue, this doesn't need to have sec-approval to go in. We should just check this into trunk with any other necessary bugs.
Attachment #8794191 - Flags: sec-approval?
(In reply to Al Billings [:abillings] from comment #13)
> As a sec-audit issue, this doesn't need to have sec-approval to go in. We
> should just check this into trunk with any other necessary bugs.

Sorry, I missed that this was sec-audit. It's actually sec-high/sec-crit because it fixes actual crashes (bug 1295039, bug 1298135, and others).
Keywords: sec-auditsec-critical
Comment on attachment 8794191 [details] [diff] [review]
Updated patch

See comment 10.
Attachment #8794191 - Flags: sec-approval?
sec-approval+ for trunk. Please nominate Aurora and Beta patches to go in once this is fixed. 

My one question is whether we should really take this on ESR45 since that is an awful big patch.
Attachment #8794191 - Flags: sec-approval? → sec-approval+
https://hg.mozilla.org/integration/mozilla-inbound/rev/f5d61890ecb53a10133d41f6a09f2d36d988cd92

(In reply to Al Billings [:abillings] from comment #16)
> My one question is whether we should really take this on ESR45 since that is
> an awful big patch.

It is a big patch but most of it is safe/mechanical. There's a small part that we should definitely land on ESR45, the other changes we could probably do without as they're more audit-ish. First, let's see if this affects performance on AWFY..
https://hg.mozilla.org/mozilla-central/rev/f5d61890ecb5
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
Group: javascript-core-security → core-security-release
Comment on attachment 8794191 [details] [diff] [review]
Updated patch

Approval Request Comment
[Feature/regressing bug #]: Older bug.
[User impact if declined]: Crashes, security bugs.
[Describe test coverage new/current, TreeHerder]: Fixes some fuzz tests.
[Risks and why]: On m-c for a while. Large patch but most of it is very mechanical and safe.
[String/UUID change made/needed]: None.
Attachment #8794191 - Flags: approval-mozilla-esr45?
Attachment #8794191 - Flags: approval-mozilla-beta?
Attachment #8794191 - Flags: approval-mozilla-aurora?
Comment on attachment 8794191 [details] [diff] [review]
Updated patch

Sec-crit, Aurora51+, Beta50+, ESR45+
Attachment #8794191 - Flags: approval-mozilla-esr45?
Attachment #8794191 - Flags: approval-mozilla-esr45+
Attachment #8794191 - Flags: approval-mozilla-beta?
Attachment #8794191 - Flags: approval-mozilla-beta+
Attachment #8794191 - Flags: approval-mozilla-aurora?
Attachment #8794191 - Flags: approval-mozilla-aurora+
https://hg.mozilla.org/releases/mozilla-aurora/rev/edbfbd7da7d0

Needs rebasing for Beta (and presumably ESR45).
Flags: needinfo?(jdemooij)
Crash Signature: [@ js::GCMarker::eagerlyMarkChildren][@ JSString::isPermanentAtom]
Attached patch Patch for ESR45Splinter Review
Rebasing this for ESR45 is very painful. Here's a much smaller patch that doesn't trace the pointers stored in individual MIR instructions. It still ensures we trace all scripts and all builders, and should fix the issues the fuzzers found.
Flags: needinfo?(jdemooij)
Attachment #8798064 - Flags: review?(jcoppeard)
Comment on attachment 8798064 [details] [diff] [review]
Patch for ESR45

Review of attachment 8798064 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM.
Attachment #8798064 - Flags: review?(jcoppeard) → review+
No longer depends on: 1313869
Flags: qe-verify-
Whiteboard: [post-critsmash-triage]
Whiteboard: [post-critsmash-triage] → [post-critsmash-triage][adv-main50+][adv-esr45.5+]
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: