Heap-use-after-free in nsDocument::AdoptNode
Originally disclosed on Mozilla
- Fixed in 25 days
- Paid in 7 months
- Disclosed after 25 days
This bug reproduces quite frequently in my fuzzing, however there is not reliable reproduction or minimized testcase. The ASAN free and alloc stacks might be helpful in fixing the bug. I will update bug if i get a reliable repro.
20120613124512 http://hg.mozilla.org/mozilla-central/rev/00244ceddd42
================================================================= ==26295== ERROR: AddressSanitizer heap-use-after-free on address 0x7fe9741ba190 at pc 0x7fe983d5d952 bp 0x7fffbf205490 sp 0x7fffbf205488 READ of size 8 at 0x7fe9741ba190 thread T0 #0 0x7fe983d5d952 in nsTArray_base<nsTArrayDefaultAllocator>::Length() const firefox/src/../../../dist/include/nsTArray.h:192 #1 0x7fe984677dd2 in AdoptNodeIntoOwnerDoc(nsINode*, nsINode*) firefox/src/content/base/src/nsGenericElement.cpp:3743 #2 0x7fe984679178 in nsINode::ReplaceOrInsertBefore(bool, nsINode*, nsINode*) firefox/src/content/base/src/nsGenericElement.cpp:4346 #3 0x7fe984667ddc in nsINode::ReplaceOrInsertBefore(bool, nsIDOMNode*, nsIDOMNode*, nsIDOMNode**) firefox/src/content/base/src/nsGenericElement.cpp:518 #4 0x7fe984d5525d in DeleteElementTxn::UndoTransaction() firefox/src/editor/libeditor/base/DeleteElementTxn.cpp:159 #5 0x7fe9855391fc in nsTransactionItem::UndoTransaction(nsTransactionManager*) firefox/src/editor/txmgr/src/nsTransactionItem.cpp:198 0x7fe9741ba190 is located 272 bytes inside of 1376-byte region [0x7fe9741ba080,0x7fe9741ba5e0) freed by thread T0 here: #0 0x4244e2 in free #1 0x7fe9846a1beb in nsNodeUtils::LastRelease(nsINode*) firefox/src/content/base/src/nsNodeUtils.cpp:252 #2 0x7fe984610d22 in nsDocument::Release() firefox/src/content/base/src/nsDocument.cpp:1679 #3 0x7fe98469c8af in nsNodeInfo::Release() firefox/src/content/base/src/nsNodeInfo.cpp:185 #4 0x7fe984643c7a in nsNodeUtils::CloneAndAdopt(nsINode*, bool, bool, nsNodeInfoManager*, JSContext*, JSObject*, nsCOMArray<nsINode>&, nsIDOMNode**) firefox/src/../../../../dist/include/nsNodeUtils.h:272 #5 0x7fe984628b5a in nsNodeUtils::Adopt(nsINode*, nsNodeInfoManager*, JSContext*, JSObject*, nsCOMArray<nsINode>&) firefox/src/content/base/src/nsNodeUtils.h:172 #6 0x7fe984677dd2 in AdoptNodeIntoOwnerDoc(nsINode*, nsINode*) firefox/src/content/base/src/nsGenericElement.cpp:3743 #7 0x7fe984679178 in nsINode::ReplaceOrInsertBefore(bool, nsINode*, nsINode*) firefox/src/content/base/src/nsGenericElement.cpp:4346 #8 0x7fe984667ddc in nsINode::ReplaceOrInsertBefore(bool, nsIDOMNode*, nsIDOMNode*, nsIDOMNode**) firefox/src/content/base/src/nsGenericElement.cpp:518 #9 0x7fe984d5525d in DeleteElementTxn::UndoTransaction() firefox/src/editor/libeditor/base/DeleteElementTxn.cpp:159 #10 0x7fe9855391fc in nsTransactionItem::UndoTransaction(nsTransactionManager*) firefox/src/editor/txmgr/src/nsTransactionItem.cpp:198 previously allocated by thread T0 here: #0 0x4245a2 in malloc #1 0x7fe989dfe410 in moz_xmalloc firefox/src/memory/mozalloc/mozalloc.cpp:54 #2 0x7fe9845c9f81 in nsContentUtils::CreateDocument(nsAString_internal const&, nsAString_internal const&, nsIDOMDocumentType*, nsIURI*, nsIURI*, nsIPrincipal*, nsIScriptGlobalObject*, DocumentFlavor, nsIDOMDocument**) firefox/src/content/base/src/nsContentUtils.cpp:4226 #3 0x7fe98527552c in nsIDOMDOMImplementation_CreateDocument(JSContext*, unsigned int, JS::Value*) firefox/src/objdir-ff-asan/js/xpconnect/src/dom_quickstubs.cpp:6262 #4 0x7fe98666809f in js::InvokeKernel(JSContext*, js::CallArgs, js::MaybeConstruct) firefox/src/js/src/jscntxtinlines.h:395 #5 0x7fe98665e373 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) firefox/src/js/src/jsinterp.cpp:2435 #6 0x7fe98664b168 in js::RunScript(JSContext*, JSScript*, js::StackFrame*) firefox/src/js/src/jsinterp.cpp:267 #7 0x7fe9866693c7 in js::ExecuteKernel(JSContext*, JSScript*, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) firefox/src/js/src/jsinterp.cpp:455 #8 0x7fe986669721 in js::Execute(JSContext*, JSScript*, JSObject&, JS::Value*) firefox/src/js/src/jsinterp.cpp:492 #9 0x7fe986586744 in EvaluateUCScriptForPrincipalsCommon(JSContext*, JSObject*, JSPrincipals*, JSPrincipals*, unsigned short const*, unsigned int, char const*, unsigned int, JS::Value*, JSVersion) firefox/src/js/src/jsapi.cpp:5356 #10 0x7fe9865869e9 in JS_EvaluateUCScriptForPrincipalsVersionOrigin firefox/src/js/src/jsapi.cpp:5393 #11 0x7fe984aa30ae in nsJSContext::EvaluateString(nsAString_internal const&, JSObject*, nsIPrincipal*, nsIPrincipal*, char const*, unsigned int, JSVersion, nsAString_internal*, bool*) firefox/src/dom/base/nsJSEnvironment.cpp:1463 #12 0x7fe984afc51b in nsGlobalWindow::RunTimeoutHandler(nsTimeout*, nsIScriptContext*) firefox/src/dom/base/nsGlobalWindow.cpp:9042 #13 0x7fe984aedadc in nsGlobalWindow::RunTimeout(nsTimeout*) firefox/src/dom/base/nsGlobalWindow.cpp:9306 #14 0x7fe984afb9d8 in nsGlobalWindow::TimerCallback(nsITimer*, void*) firefox/src/dom/base/nsGlobalWindow.cpp:9580 #15 0x7fe985d542e6 in nsTimerImpl::Fire() firefox/src/xpcom/threads/nsTimerImpl.cpp:473 #16 0x7fe985d54836 in nsTimerEvent::Run() firefox/src/xpcom/threads/nsTimerImpl.cpp:559 #17 0x7fe985d4a914 in nsThread::ProcessNextEvent(bool, bool*) firefox/src/xpcom/threads/nsThread.cpp:624 #18 0x7fe985cbb8fd in NS_ProcessNextEvent_P(nsIThread*, bool) firefox/src/objdir-ff-asan/xpcom/build/nsThreadUtils.cpp:216 #19 0x7fe985acda2d in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) firefox/src/ipc/glue/MessagePump.cpp:82 #20 0x7fe985dbb43f in MessageLoop::Run() firefox/src/ipc/chromium/src/base/message_loop.cc:176 #21 0x7fe9858da96e in nsBaseAppShell::Run() firefox/src/widget/xpwidgets/nsBaseAppShell.cpp:165 #22 0x7fe983d019c3 in XREMain::XRE_main(int, char**, nsXREAppData const*) firefox/src/toolkit/xre/nsAppRunner.cpp:3858 ==26295== ABORTING Stats: 204M malloced (270M for red zones) by 709938 calls Stats: 38M realloced by 47616 calls Stats: 171M freed by 456977 calls Stats: 61M really freed by 86648 calls Stats: 476M (121916 full pages) mmaped in 119 calls mmaps by size class: 8:540639; 9:65528; 10:45045; 11:14329; 12:4096; 13:5120; 14:1792; 15:384; 16:768; 17:96; 18:176; 19:48; 20:16; mallocs by size class: 8:575429; 9:63598; 10:44465; 11:14417; 12:3815; 13:5233; 14:1576; 15:345; 16:719; 17:97; 18:183; 19:47; 20:14; frees by size class: 8:346550; 9:48317; 10:40427; 11:11219; 12:2991; 13:4933; 14:1293; 15:295; 16:651; 17:78; 18:167; 19:44; 20:12; rfrees by size class: 8:59414; 9:12639; 10:4862; 11:6621; 12:888; 13:574; 14:1048; 15:152; 16:347; 17:45; 18:25; 19:32; 20:1; Stats: malloc large: 341 small slow: 3125 Shadow byte and word: 0x1ffd2e837432: fd 0x1ffd2e837430: fd fd fd fd fd fd fd fd More shadow bytes: 0x1ffd2e837410: fd fd fd fd fd fd fd fd 0x1ffd2e837418: fd fd fd fd fd fd fd fd 0x1ffd2e837420: fd fd fd fd fd fd fd fd 0x1ffd2e837428: fd fd fd fd fd fd fd fd =>0x1ffd2e837430: fd fd fd fd fd fd fd fd 0x1ffd2e837438: fd fd fd fd fd fd fd fd 0x1ffd2e837440: fd fd fd fd fd fd fd fd 0x1ffd2e837448: fd fd fd fd fd fd fd fd 0x1ffd2e837450: fd fd fd fd fd fd fd fd
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 DOM: Core & HTML. Mozilla made it public on 10 July 2012 as CVE-2012-1954.
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.