Skip to content
Memory corruption Disclosed report

Heap-use-after-free in mozilla::ResetDir

Abhishek Arya Follow

Originally disclosed on Mozilla

Critical View original
  • Fixed in 8 days
  • Paid in 8 days
  • Disclosed after 8 days

Created attachment 698504 Testcase

==330== ERROR: AddressSanitizer: heap-use-after-free on address 0x7f7d826e11ac at pc 0x7f7da62fdb33 bp 0x7fff9927a4b0 sp 0x7fff9927a4a8 READ of size 4 at 0x7f7d826e11ac thread T0 #0 0x7f7da62fdb32 in nsINode::GetBoolFlag(nsINode::BooleanFlag) const src/content/base/public/nsINode.h:1343 #1 0x7f7da819c62e in nsINode::HasTextNodeDirectionalityMap() const src/../../../dist/include/nsINode.h:1426 #2 0x7f7da819ae17 in mozilla::nsTextNodeDirectionalityMap::RemoveElementFromMap(nsINode*, mozilla::dom::Element*) src/content/base/src/DirectionalityUtils.cpp:535 #3 0x7f7da81a237f in mozilla::ResetDir(mozilla::dom::Element*) src/content/base/src/DirectionalityUtils.cpp:927 #4 0x7f7da87be537 in mozilla::dom::Element::UnbindFromTree(bool, bool) src/content/base/src/Element.cpp:1359 #5 0x7f7da974deac in nsGenericHTMLElement::UnbindFromTree(bool, bool) src/content/html/content/src/nsGenericHTMLElement.cpp:657 #6 0x7f7da87be865 in mozilla::dom::Element::UnbindFromTree(bool, bool) src/content/base/src/Element.cpp:1372 #7 0x7f7da974deac in nsGenericHTMLElement::UnbindFromTree(bool, bool) src/content/html/content/src/nsGenericHTMLElement.cpp:657 #8 0x7f7daa12af7e in nsHTMLSharedElement::UnbindFromTree(bool, bool) src/content/html/content/src/nsHTMLSharedElement.cpp:438 #9 0x7f7da87be865 in mozilla::dom::Element::UnbindFromTree(bool, bool) src/content/base/src/Element.cpp:1372 #10 0x7f7da974deac in nsGenericHTMLElement::UnbindFromTree(bool, bool) src/content/html/content/src/nsGenericHTMLElement.cpp:657 #11 0x7f7daa12af7e in nsHTMLSharedElement::UnbindFromTree(bool, bool) src/content/html/content/src/nsHTMLSharedElement.cpp:438 #12 0x7f7da8896ba3 in nsINode::doRemoveChildAt(unsigned int, bool, nsIContent*, nsAttrAndChildArray&) src/content/base/src/nsINode.cpp:1386 #13 0x7f7da858e122 in nsDocument::RemoveChildAt(unsigned int, bool) src/content/base/src/nsDocument.cpp:3455 #14 0x7f7da887d5e3 in nsINode::RemoveChild(nsINode&, mozilla::ErrorResult&) src/content/base/src/nsINode.cpp:459 #15 0x7f7db33fcf83 in mozilla::dom::NodeBinding::removeChild(JSContext*, JS::Handle<JSObject*>, nsINode*, unsigned int, JS::Value*) src/objdir-ff-asan-sym/dom/bindings/NodeBinding.cpp:712 #16 0x7f7db33c8376 in mozilla::dom::NodeBinding::genericMethod(JSContext*, unsigned int, JS::Value*) src/objdir-ff-asan-sym/dom/bindings/NodeBinding.cpp:1390 #17 0x7f7dbc03bec5 in js::CallJSNative(JSContext*, int ()(JSContext, unsigned int, JS::Value*), JS::CallArgs const&) src/js/src/jscntxtinlines.h:373 #18 0x7f7dbc03bec5 in js::InvokeKernel(JSContext*, JS::CallArgs, js::MaybeConstruct) src/js/src/jsinterp.cpp:391 #19 0x7f7dbbfec986 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:2368 #20 0x7f7dbbf4cdcb in js::RunScript(JSContext*, JS::Handle<JSScript*>, js::StackFrame*) src/js/src/jsinterp.cpp:348 #21 0x7f7dbc0496e5 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) src/js/src/jsinterp.cpp:537 #22 0x7f7dbc04b285 in js::Execute(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value*) src/js/src/jsinterp.cpp:576 #23 0x7f7dbb7a712e in JS::Evaluate(JSContext*, JS::Handle<JSObject*>, JS::CompileOptions, unsigned short const*, unsigned long, JS::Value*) src/js/src/jsapi.cpp:5624 #24 0x7f7daaeae420 in nsJSContext::EvaluateString(nsAString_internal const&, JSObject*, nsIPrincipal*, nsIPrincipal*, char const*, unsigned int, JSVersion, nsAString_internal*, bool*) src/dom/base/nsJSEnvironment.cpp:1525 #25 0x7f7dab084f29 in nsGlobalWindow::RunTimeoutHandler(nsTimeout*, nsIScriptContext*) src/dom/base/nsGlobalWindow.cpp:9755 #26 0x7f7dab0396ef in nsGlobalWindow::RunTimeout(nsTimeout*) src/dom/base/nsGlobalWindow.cpp:10007 #27 0x7f7dab083029 in nsGlobalWindow::TimerCallback(nsITimer*, void*) src/dom/base/nsGlobalWindow.cpp:10276 #28 0x7f7db454a74b in nsTimerImpl::Fire() src/xpcom/threads/nsTimerImpl.cpp:482 #29 0x7f7db454bbd4 in nsTimerEvent::Run() src/xpcom/threads/nsTimerImpl.cpp:565 #30 0x7f7db450df6f in nsThread::ProcessNextEvent(bool, bool*) src/xpcom/threads/nsThread.cpp:627 #31 0x7f7db41827b5 in NS_ProcessNextEvent_P(nsIThread*, bool) src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:237 #32 0x7f7db16b7593 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) src/ipc/glue/MessagePump.cpp:117 #33 0x7f7db47ff8e2 in MessageLoop::RunInternal() src/ipc/chromium/src/base/message_loop.cc:215 #34 0x7f7db47ff719 in MessageLoop::RunHandler() src/ipc/chromium/src/base/message_loop.cc:208 #35 0x7f7db47ff5ee in MessageLoop::Run() src/ipc/chromium/src/base/message_loop.cc:182 #36 0x7f7db0aa1c07 in nsBaseAppShell::Run() src/widget/xpwidgets/nsBaseAppShell.cpp:163 #37 0x7f7daf5b8715 in nsAppStartup::Run() src/toolkit/components/startup/nsAppStartup.cpp:288 #38 0x7f7da4800874 in XREMain::XRE_mainRun() src/toolkit/xre/nsAppRunner.cpp:3823 #39 0x7f7da480645a in XREMain::XRE_main(int, char**, nsXREAppData const*) src/toolkit/xre/nsAppRunner.cpp:3890 #40 0x7f7da4809230 in XRE_main src/toolkit/xre/nsAppRunner.cpp:4093 #41 0x41db83 in do_main(int, char**, nsIFile*) src/browser/app/nsBrowserApp.cpp:195 #42 0x41ae86 in main src/browser/app/nsBrowserApp.cpp:388 #43 0x7f7dc640e76c in 0x7f7d826e11ac is located 44 bytes inside of 120-byte region [0x7f7d826e1180,0x7f7d826e11f8) freed by thread T0 here: #0 0x40fb32 in __interceptor_free #1 0x7f7dc742b4b9 in moz_free src/memory/mozalloc/mozalloc.cpp:48 #2 0x7f7da8af6010 in operator delete(void*) src/../../../dist/include/mozilla/mozalloc.h:224 #3 0x7f7da8af6010 in nsTextNode::~nsTextNode() src/content/base/src/nsTextNode.cpp:117 #4 0x7f7da89bf417 in nsNodeUtils::LastRelease(nsINode*) src/content/base/src/nsNodeUtils.cpp:258 #5 0x7f7da88390f0 in nsGenericDOMDataNode::Release() src/content/base/src/nsGenericDOMDataNode.cpp:117 #6 0x7f7da8af650a in nsTextNode::Release() src/content/base/src/nsTextNode.cpp:121 #7 0x7f7da47ca32f in nsCOMPtr_base::~nsCOMPtr_base() src/objdir-ff-asan-sym/media/webrtc/signaling/signaling_ecc/../../../../dist/include/nsCOMPtr.h:410 #8 0x7f7da65b29ac in nsCOMPtr<nsIContent>::~nsCOMPtr() src/../../dist/include/nsCOMPtr.h:449 #9 0x7f7da65b2679 in nsCOMPtr<nsIContent>::~nsCOMPtr() src/../../dist/include/nsCOMPtr.h:449 #10 0x7f7da8c8558d in mozilla::dom::FragmentOrElement::RemoveChildAt(unsigned int, bool) src/content/base/src/FragmentOrElement.cpp:896 #11 0x7f7da87dfae1 in mozilla::dom::Element::SetInnerHTML(nsAString_internal const&, mozilla::ErrorResult&) src/content/base/src/Element.cpp:3373 #12 0x7f7db2c4d724 in mozilla::dom::ElementBinding::set_innerHTML(JSContext*, JS::Handle<JSObject*>, mozilla::dom::Element*, JS::Value*) src/objdir-ff-asan-sym/dom/bindings/ElementBinding.cpp:1689 #13 0x7f7db2c36178 in mozilla::dom::ElementBinding::genericSetter(JSContext*, unsigned int, JS::Value*) src/objdir-ff-asan-sym/dom/bindings/ElementBinding.cpp:2031 #14 0x7f7dbc03bec5 in js::CallJSNative(JSContext*, int ()(JSContext, unsigned int, JS::Value*), JS::CallArgs const&) src/js/src/jscntxtinlines.h:373 #15 0x7f7dbc03bec5 in js::InvokeKernel(JSContext*, JS::CallArgs, js::MaybeConstruct) src/js/src/jsinterp.cpp:391 #16 0x7f7dbb8ecfdf in js::Invoke(JSContext*, js::InvokeArgsGuard&, js::MaybeConstruct) src/js/src/jsinterp.h:112 #17 0x7f7dbc041c69 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value*, JS::Value*) src/js/src/jsinterp.cpp:439 #18 0x7f7dbc0480e5 in js::InvokeGetterOrSetter(JSContext*, JSObject*, JS::Value const&, unsigned int, JS::Value*, JS::Value*) src/js/src/jsinterp.cpp:512 #19 0x7f7dbc2e0e61 in js::Shape::set(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, bool, JS::MutableHandleJS::Value) src/js/src/jsscopeinlines.h:315 #20 0x7f7dbc3184eb in js::baseops::SetPropertyHelper(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<long>, unsigned int, JS::MutableHandleJS::Value, int) src/js/src/jsobj.cpp:3686 #21 0x7f7dbc07c6d1 in js::SetPropertyOperation(JSContext*, unsigned char*, JS::HandleJS::Value, JS::HandleJS::Value) src/js/src/jsinterpinlines.h:365 #22 0x7f7dbbfdbda5 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:2278 #23 0x7f7dbbf4cdcb in js::RunScript(JSContext*, JS::Handle<JSScript*>, js::StackFrame*) src/js/src/jsinterp.cpp:348 #24 0x7f7dbc03c809 in js::InvokeKernel(JSContext*, JS::CallArgs, js::MaybeConstruct) src/js/src/jsinterp.cpp:406 #25 0x7f7dbb8ecfdf in js::Invoke(JSContext*, js::InvokeArgsGuard&, js::MaybeConstruct) src/js/src/jsinterp.h:112 #26 0x7f7dbc041c69 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value*, JS::Value*) src/js/src/jsinterp.cpp:439 #27 0x7f7dbb7b40f2 in JS_CallFunctionValue(JSContext*, JSObject*, JS::Value, unsigned int, JS::Value*, JS::Value*) src/js/src/jsapi.cpp:5805 #28 0x7f7dae623bc5 in nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS*, unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) src/js/xpconnect/src/XPCWrappedJSClass.cpp:1432 #29 0x7f7dae5c4a10 in nsXPCWrappedJS::CallMethod(unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) src/js/xpconnect/src/XPCWrappedJS.cpp:581 #30 0x7f7db463d47f in PrepareAndDispatch src/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp:122 #31 0x7f7db463a166 in SharedStub previously allocated by thread T0 here: #0 0x40fc12 in __interceptor_malloc #1 0x7f7dc742b604 in moz_xmalloc src/memory/mozalloc/mozalloc.cpp:54 #2 0x7f7da8af5830 in operator new(unsigned long) src/../../../dist/include/mozilla/mozalloc.h:200 #3 0x7f7da8af5830 in NS_NewTextNode(nsIContent**, nsNodeInfoManager*) src/content/base/src/nsTextNode.cpp:106 #4 0x7f7dac43b3fe in nsHtml5TreeOperation::AppendText(unsigned short const*, unsigned int, nsIContent*, nsHtml5TreeOpExecutor*) src/parser/html/nsHtml5TreeOperation.cpp:164 #5 0x7f7dac446687 in nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor*, nsIContent**) src/parser/html/nsHtml5TreeOperation.cpp:457 #6 0x7f7dac4647e6 in nsHtml5TreeOpExecutor::RunFlushLoop() src/parser/html/nsHtml5TreeOpExecutor.cpp:559 #7 0x7f7dac4a27fd in nsHtml5ExecutorFlusher::Run() src/parser/html/nsHtml5StreamParser.cpp:127 #8 0x7f7db450df6f in nsThread::ProcessNextEvent(bool, bool*) src/xpcom/threads/nsThread.cpp:627 #9 0x7f7db41827b5 in NS_ProcessNextEvent_P(nsIThread*, bool) src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:237 #10 0x7f7db16b6f2c in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) src/ipc/glue/MessagePump.cpp:82 #11 0x7f7db47ff8e2 in MessageLoop::RunInternal() src/ipc/chromium/src/base/message_loop.cc:215 #12 0x7f7db47ff719 in MessageLoop::RunHandler() src/ipc/chromium/src/base/message_loop.cc:208 #13 0x7f7db47ff5ee in MessageLoop::Run() src/ipc/chromium/src/base/message_loop.cc:182 #14 0x7f7db0aa1c07 in nsBaseAppShell::Run() src/widget/xpwidgets/nsBaseAppShell.cpp:163 #15 0x7f7daf5b8715 in nsAppStartup::Run() src/toolkit/components/startup/nsAppStartup.cpp:288 #16 0x7f7da4800874 in XREMain::XRE_mainRun() src/toolkit/xre/nsAppRunner.cpp:3823 #17 0x7f7da480645a in XREMain::XRE_main(int, char**, nsXREAppData const*) src/toolkit/xre/nsAppRunner.cpp:3890 #18 0x7f7da4809230 in XRE_main src/toolkit/xre/nsAppRunner.cpp:4093 #19 0x41db83 in do_main(int, char**, nsIFile*) src/browser/app/nsBrowserApp.cpp:195 #20 0x41ae86 in main src/browser/app/nsBrowserApp.cpp:388 #21 0x7f7dc640e76c in Shadow bytes around the buggy address: 0x1fefb04dc1e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x1fefb04dc1f0: 00 00 00 00 fb fb fb fb fb fb fb fb fb fb fb fb 0x1fefb04dc200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x1fefb04dc210: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x1fefb04dc220: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa =>0x1fefb04dc230: fd fd fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd 0x1fefb04dc240: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x1fefb04dc250: 00 00 00 00 00 00 00 00 fb fb fb fb fb fb fb fb 0x1fefb04dc260: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 0x1fefb04dc270: 00 00 00 00 fb fb fb fb fb fb fb fb fb fb fb fb 0x1fefb04dc280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa 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 Heap righ redzone: fb Freed Heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack partial redzone: f4 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 ASan internal: fe Stats: 251M malloced (272M for red zones) by 406313 calls Stats: 47M realloced by 24583 calls Stats: 225M freed by 284938 calls Stats: 92M really freed by 191457 calls Stats: 468M (468M-0M) mmaped; 117 maps, 0 unmaps mmaps by size class: 8:294894; 9:32764; 10:8190; 11:14329; 12:2048; 13:1536; 14:1280; 15:384; 16:1152; 17:1312; 18:48; 19:40; 20:24; mallocs by size class: 8:338531; 9:32611; 10:9288; 11:16543; 12:2557; 13:1783; 14:1633; 15:412; 16:1462; 17:1362; 18:69; 19:40; 20:22; frees by size class: 8:233296; 9:23435; 10:5898; 11:14508; 12:1651; 13:1557; 14:1458; 15:291; 16:1384; 17:1345; 18:58; 19:38; 20:19; rfrees by size class: 8:168160; 9:8362; 10:2268; 11:9313; 12:660; 13:596; 14:575; 15:156; 16:970; 17:366; 18:26; 19:4; 20:1; Stats: malloc large: 1493 small slow: 2385 Stats: StackDepot: 0 ids; 0M mapped ==330== ABORTING

The original report as published on Mozilla's Bugzilla, by Abhishek Arya. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A critical-severity memory corruption bug in Layout: Text and Fonts. Mozilla made it public on 14 January 2013.

About Memory corruption

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Abhishek Arya

View all

130 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.