Closed Bug 1137336 Opened 10 years ago Closed 10 years ago

fix weak map tracing hazard due to function pointer

Categories

(Core :: JavaScript: GC, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox37 --- fixed
firefox38 --- fixed
firefox39 --- fixed
firefox-esr31 --- wontfix
firefox-esr38 --- fixed
b2g-v2.2 --- fixed
b2g-master --- fixed

People

(Reporter: sfink, Assigned: sfink)

References

Details

(Keywords: sec-other, Whiteboard: [adv-main37-][post-critsmash-triage])

Attachments

(1 file, 1 obsolete file)

+++ This bug was initially created as a clone of Bug #1120655 +++ Function '_ZN2js11WeakMapBase16traceAllMappingsEPNS_13WeakMapTracerE|void js::WeakMapBase::traceAllMappings(js::WeakMapTracer*)' has unrooted 'c' of type 'class js::CompartmentsIterT<js::ZonesIter>' live across GC call js::WeakMapBase.traceMappings at js/src/jsweakmap.cpp:135 The problem here is js::TraceWeakMaps. It is called by https://dxr.mozilla.org/mozilla-central/source/xpcom/base/CycleCollectedJSRuntime.cpp#245 and another place in the same file, and it ends up calling the js::WeakMapTracer.callback function pointer. I believe this is a false positive. But determining that is not straightforward. This is called by nsCycleCollector::FixGrayBits, which in fact *does* GC, but only after calling mJSRuntime->FixWeakMappingGrayBits(). So it's not like I can just say "the cycle collector won't GC while it's figuring out the gray bits." I guess the trick would be to prove that the WeakMapTracer.callback won't GC. The easiest way to do that would be to make the API use a virtual function.
Summary: Make the analysis detect compartment iterator invalidation → fix weak map tracing hazard due to function pointer
This probably shouldn't be sec-high, as it is very likely to be a false positive. In fact, I think I may "fix" this by adding in an AutoSuppressAnalysis, which will at least crash in debug builds if I am wrong and this can GC.
Keywords: csectype-bounds
Assignee: nobody → sphink
Status: NEW → ASSIGNED
The one thing I'm not sure of is whether I should be using AutoAssertGCCallback instead.
Attachment #8570563 - Flags: review?(terrence)
Attachment #8570010 - Attachment is obsolete: true
Keywords: sec-highsec-other
Comment on attachment 8570563 [details] [diff] [review] Explicitly disallow WeakMapTracer.callback from GCing Review of attachment 8570563 [details] [diff] [review]: ----------------------------------------------------------------- Yes, this is the right solution -- disallowing GC from a GC callback seems like a no-brainer.
Attachment #8570563 - Flags: review?(terrence) → review+
Comment on attachment 8570563 [details] [diff] [review] Explicitly disallow WeakMapTracer.callback from GCing Approval Request Comment [Feature/regressing bug #]: unknown (as in, I didn't bother to dig it up) [User impact if declined]: none. But if we backport the static analysis fixes that complain about this false positive, then we will have to ignore this failure for the hazard builds. [Describe test coverage new/current, TreeHerder]: just now landed on mozilla-inbound [Risks and why]: no change to release builds. For debug builds, adds an assertion that would indicate a serious problem (but is not expected to ever hit.) [String/UUID change made/needed]: none
Attachment #8570563 - Flags: approval-mozilla-beta?
Attachment #8570563 - Flags: approval-mozilla-aurora?
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
Attachment #8570563 - Flags: approval-mozilla-beta?
Attachment #8570563 - Flags: approval-mozilla-beta+
Attachment #8570563 - Flags: approval-mozilla-aurora?
Attachment #8570563 - Flags: approval-mozilla-aurora+
Comment on attachment 8570563 [details] [diff] [review] Explicitly disallow WeakMapTracer.callback from GCing [Approval Request Comment] If this is not a sec:{high,crit} bug, please state case for ESR consideration: it gives us the option of backporting bug 1120655, which is the updates to the analysis that mark this as a hazard (though it's believed to be a false positive) User impact if declined: none. It might make it a little less confusing about what patch landed where, but it's not a huge deal either way. Fix Landed on Version: it's been backported to 37 Risk to taking this patch (and alternatives if risky): the main risk is that the added debug assert finds out that this is a true positive, and we have to run around and fix something. That's not a problem with landing this patch, though. This patch does not change behavior in a release build. String or UUID changes made by this patch: none
Attachment #8570563 - Flags: approval-mozilla-esr31?
Whiteboard: [adv-main37-]
bkerensa needs to be able to see this for building ESR.
Lawrence wanted me to check per comment 11 I was unable to see these bugs and will need my privleges adjusted but do we want to respin on these?
Flags: needinfo?(abillings)
(In reply to Liz Henry (:lizzard) from comment #11) > bkerensa needs to be able to see this for building ESR. Except this is "won't fix" for ESR31 per the flags. It is also a sec-other, which we don't take on ESR without a reason (we only take sec-high and sec-critical normally). There is no reason for anything to think we would take this on ESR31.
Flags: needinfo?(abillings)
Attachment #8570563 - Flags: approval-mozilla-esr31? → approval-mozilla-esr31-
Group: javascript-core-security
Group: core-security → core-security-release
Whiteboard: [adv-main37-] → [adv-main37-][post-critsmash-triage]
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: