Closed Bug 1709227 Opened 3 years ago Closed 3 years ago

global-buffer-overflow in [@ mozilla::XULStore::GetService] on launch

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox88 --- wontfix
firefox89 --- wontfix
firefox90 --- fixed

People

(Reporter: tsmith, Assigned: nika)

Details

(Keywords: crash, csectype-bounds)

Attachments

(1 file)

ASan-debug builds fail to launch. Seems to only affect ASan-debug builds, ASan-opt builds seem to be ok. Found with m-c 20210503-c97286566c45.

==110657==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f8bfacefbd0 at pc 0x7f8bd97396dc bp 0x7ffeb4a08bb0 sp 0x7ffeb4a08ba8
READ of size 8 at 0x7f8bfacefbd0 thread T0
    #0 0x7f8bd97396db in NS_LogCOMPtrAddRef /builds/worker/checkouts/gecko/xpcom/base/nsTraceRefcnt.cpp:1068:18
    #1 0x7f8beaae4a4c in nsGetterAddRefs<nsIXULStore>::~nsGetterAddRefs() /builds/worker/workspace/obj-build/dist/include/nsCOMPtr.h:1317:5
    #2 0x7f8beaae4a4c in mozilla::XULStore::GetService() /builds/worker/checkouts/gecko/toolkit/components/xulstore/XULStore.cpp:60:5
    #3 0x7f8bd98a84e6 in mozilla::xpcom::CreateInstanceImpl(mozilla::xpcom::ModuleID, nsISupports*, nsID const&, void**) /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:9974:34
    #4 0x7f8bd989e86d in mozilla::xpcom::StaticModule::CreateInstance(nsISupports*, nsID const&, void**) const /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:12154:10
    #5 0x7f8bd990c444 in (anonymous namespace)::EntryWrapper::CreateInstance(nsISupports*, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManager.cpp:177:46
    #6 0x7f8bd990c444 in nsComponentManagerImpl::GetServiceLocked(mozilla::Maybe<mozilla::MonitorAutoLock>&, (anonymous namespace)::EntryWrapper&, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManager.cpp:1276:17
    #7 0x7f8bd990f037 in nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManager.cpp:1465:10
    #8 0x7f8bd9917df1 in CallGetService(char const*, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManagerUtils.cpp:61:43
    #9 0x7f8bdc49f5e4 in xpc::CIGSHelper(JSContext*, unsigned int, JS::Value*, bool) /builds/worker/checkouts/gecko/js/xpconnect/src/XPCJSID.cpp:585:10
    #10 0x7f8bdc49e6cd in xpc::CID_GetService(JSContext*, unsigned int, JS::Value*) /builds/worker/checkouts/gecko/js/xpconnect/src/XPCJSID.cpp:610:10
    #11 0x7f8beaf37e72 in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:437:13
    #12 0x7f8beaf36404 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:522:12
    #13 0x7f8beaf3aae0 in InternalCall(JSContext*, js::AnyInvokeArgs const&, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:582:10
    #14 0x7f8beaf16919 in js::CallFromStack(JSContext*, JS::CallArgs const&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:586:10
    #15 0x7f8beaf16919 in Interpret(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:3248:16
    #16 0x7f8beaef4e02 in js::RunScript(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:406:13
    #17 0x7f8beaf3f3c7 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, JS::Handle<JS::Value>, js::AbstractFramePtr, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:776:13
    #18 0x7f8beb06b501 in ExecuteInExtensibleLexicalEnvironment(JSContext*, JS::Handle<JSScript*>, JS::Handle<js::ExtensibleLexicalEnvironmentObject*>) /builds/worker/checkouts/gecko/js/src/builtin/Eval.cpp:409:10
    #19 0x7f8beb06cf32 in JS::ExecuteInJSMEnvironment(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, JS::Handle<JS::StackGCVector<JSObject*, js::TempAllocPolicy> >) /builds/worker/checkouts/gecko/js/src/builtin/Eval.cpp:519:10
    #20 0x7f8beb06c5c7 in JS::ExecuteInJSMEnvironment(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>) /builds/worker/checkouts/gecko/js/src/builtin/Eval.cpp:472:10
    #21 0x7f8bdc34fe6c in mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo&, nsIFile*, JS::MutableHandle<JSObject*>, JS::MutableHandle<JSScript*>, char**, bool, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/xpconnect/loader/mozJSComponentLoader.cpp:867:19
    #22 0x7f8bdc362078 in mozJSComponentLoader::Import(JSContext*, nsTSubstring<char> const&, JS::MutableHandle<JSObject*>, JS::MutableHandle<JSObject*>, bool) /builds/worker/checkouts/gecko/js/xpconnect/loader/mozJSComponentLoader.cpp:1275:12
    #23 0x7f8bd98d04a5 in mozilla::xpcom::ConstructJSMComponent(nsTSubstring<char> const&, char const*, nsISupports**) /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:1846:3
    #24 0x7f8bd98bed99 in mozilla::xpcom::CreateInstanceImpl(mozilla::xpcom::ModuleID, nsISupports*, nsID const&, void**) /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:9775:7
    #25 0x7f8bd989e86d in mozilla::xpcom::StaticModule::CreateInstance(nsISupports*, nsID const&, void**) const /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:12154:10
    #26 0x7f8bd990c444 in (anonymous namespace)::EntryWrapper::CreateInstance(nsISupports*, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManager.cpp:177:46
    #27 0x7f8bd990c444 in nsComponentManagerImpl::GetServiceLocked(mozilla::Maybe<mozilla::MonitorAutoLock>&, (anonymous namespace)::EntryWrapper&, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManager.cpp:1276:17
    #28 0x7f8bd990dc73 in nsComponentManagerImpl::GetService(mozilla::xpcom::ModuleID, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManager.cpp:1366:10
    #29 0x7f8bd98cf84d in mozilla::xpcom::GetServiceHelper::operator()(nsID const&, void**) const /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:12273:50
    #30 0x7f8bd96bf5c6 in nsCOMPtr_base::assign_from_helper(nsCOMPtr_helper const&, nsID const&) /builds/worker/checkouts/gecko/xpcom/base/nsCOMPtr.cpp:109:7
    #31 0x7f8bdc48bc7b in nsCOMPtr<nsISupports>::nsCOMPtr(nsCOMPtr_helper const&) /builds/worker/workspace/obj-build/dist/include/nsCOMPtr.h:999:5
    #32 0x7f8bdc48bc7b in xpc::GetServiceImpl(JSContext*, mozilla::xpcom::JSServiceEntry const&, JS::MutableHandle<JSObject*>, mozilla::ErrorResult&) /builds/worker/checkouts/gecko/js/xpconnect/src/JSServices.cpp:83:32
    #33 0x7f8bdc48bc7b in xpc::GetService(JSContext*, mozilla::xpcom::JSServiceEntry const&, mozilla::ErrorResult&) /builds/worker/checkouts/gecko/js/xpconnect/src/JSServices.cpp:130:8
    #34 0x7f8bdc48bc7b in xpc::Services_Resolve(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::PropertyKey>, bool*) /builds/worker/checkouts/gecko/js/xpconnect/src/JSServices.cpp:153:25
    #35 0x7f8beb8ad167 in js::CallResolveOp(JSContext*, JS::Handle<js::NativeObject*>, JS::Handle<JS::PropertyKey>, js::PropertyResult*) /builds/worker/checkouts/gecko/js/src/vm/NativeObject-inl.h:660:8
    #36 0x7f8beb8ad167 in bool js::NativeLookupOwnPropertyInline<(js::AllowGC)1, (js::LookupResolveMode)1>(JSContext*, js::MaybeRooted<js::NativeObject*, (js::AllowGC)1>::HandleType, js::MaybeRooted<JS::PropertyKey, (js::AllowGC)1>::HandleType, js::PropertyResult*) /builds/worker/checkouts/gecko/js/src/vm/NativeObject-inl.h:776:14
    #37 0x7f8beb8bd3dc in bool NativeGetPropertyInline<(js::AllowGC)1>(JSContext*, js::MaybeRooted<js::NativeObject*, (js::AllowGC)1>::HandleType, js::MaybeRooted<JS::Value, (js::AllowGC)1>::HandleType, js::MaybeRooted<JS::PropertyKey, (js::AllowGC)1>::HandleType, IsNameLookup, js::MaybeRooted<JS::Value, (js::AllowGC)1>::MutableHandleType) /builds/worker/checkouts/gecko/js/src/vm/NativeObject.cpp:2291:10
    #38 0x7f8beb8bd04e in js::NativeGetProperty(JSContext*, JS::Handle<js::NativeObject*>, JS::Handle<JS::Value>, JS::Handle<JS::PropertyKey>, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/NativeObject.cpp:2339:10
    #39 0x7f8beaf4a284 in js::GetProperty(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::Handle<JS::PropertyKey>, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/ObjectOperations-inl.h:116:10
    #40 0x7f8beaf4a284 in js::GetProperty(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, js::PropertyName*, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/ObjectOperations-inl.h:123:10
    #41 0x7f8beaf481d3 in js::GetProperty(JSContext*, JS::Handle<JS::Value>, JS::Handle<js::PropertyName*>, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:4579:10
    #42 0x7f8beaf14f27 in GetPropertyOperation(JSContext*, js::InterpreterFrame*, JS::Handle<JSScript*>, unsigned char*, JS::MutableHandle<JS::Value>, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:219:10
    #43 0x7f8beaf14f27 in Interpret(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:2939:12
    #44 0x7f8beaef4e02 in js::RunScript(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:406:13
    #45 0x7f8beaf3f3c7 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, JS::Handle<JS::Value>, js::AbstractFramePtr, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:776:13
    #46 0x7f8beb06b501 in ExecuteInExtensibleLexicalEnvironment(JSContext*, JS::Handle<JSScript*>, JS::Handle<js::ExtensibleLexicalEnvironmentObject*>) /builds/worker/checkouts/gecko/js/src/builtin/Eval.cpp:409:10
    #47 0x7f8beb06cf32 in JS::ExecuteInJSMEnvironment(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>, JS::Handle<JS::StackGCVector<JSObject*, js::TempAllocPolicy> >) /builds/worker/checkouts/gecko/js/src/builtin/Eval.cpp:519:10
    #48 0x7f8beb06c5c7 in JS::ExecuteInJSMEnvironment(JSContext*, JS::Handle<JSScript*>, JS::Handle<JSObject*>) /builds/worker/checkouts/gecko/js/src/builtin/Eval.cpp:472:10
    #49 0x7f8bdc34fe6c in mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo&, nsIFile*, JS::MutableHandle<JSObject*>, JS::MutableHandle<JSScript*>, char**, bool, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/xpconnect/loader/mozJSComponentLoader.cpp:867:19
    #50 0x7f8bdc362078 in mozJSComponentLoader::Import(JSContext*, nsTSubstring<char> const&, JS::MutableHandle<JSObject*>, JS::MutableHandle<JSObject*>, bool) /builds/worker/checkouts/gecko/js/xpconnect/loader/mozJSComponentLoader.cpp:1275:12
    #51 0x7f8bd98d04a5 in mozilla::xpcom::ConstructJSMComponent(nsTSubstring<char> const&, char const*, nsISupports**) /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:1846:3
    #52 0x7f8bd98c0174 in mozilla::xpcom::CreateInstanceImpl(mozilla::xpcom::ModuleID, nsISupports*, nsID const&, void**) /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:8951:7
    #53 0x7f8bd989e86d in mozilla::xpcom::StaticModule::CreateInstance(nsISupports*, nsID const&, void**) const /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:12154:10
    #54 0x7f8bd990c444 in (anonymous namespace)::EntryWrapper::CreateInstance(nsISupports*, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManager.cpp:177:46
    #55 0x7f8bd990c444 in nsComponentManagerImpl::GetServiceLocked(mozilla::Maybe<mozilla::MonitorAutoLock>&, (anonymous namespace)::EntryWrapper&, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManager.cpp:1276:17
    #56 0x7f8bd990f037 in nsComponentManagerImpl::GetServiceByContractID(char const*, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManager.cpp:1465:10
    #57 0x7f8bd9918632 in CallGetService(char const*, nsID const&, void**) /builds/worker/checkouts/gecko/xpcom/components/nsComponentManagerUtils.cpp:61:43
    #58 0x7f8bd9918632 in nsGetServiceByContractIDWithError::operator()(nsID const&, void**) const /builds/worker/checkouts/gecko/xpcom/components/nsComponentManagerUtils.cpp:253:21
    #59 0x7f8bd96bf17f in nsCOMPtr_base::assign_from_gs_contractid_with_error(nsGetServiceByContractIDWithError const&, nsID const&) /builds/worker/checkouts/gecko/xpcom/base/nsCOMPtr.cpp:91:7
    #60 0x7f8beabee502 in nsCOMPtr<nsISupports>::operator=(nsGetServiceByContractIDWithError const&) /builds/worker/workspace/obj-build/dist/include/nsCOMPtr.h:1065:5
    #61 0x7f8beabee502 in nsAppStartupNotifier::NotifyObservers(char const*) /builds/worker/checkouts/gecko/toolkit/xre/nsAppStartupNotifier.cpp:46:23
    #62 0x7f8beabd238f in XREMain::XRE_mainRun() /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:5111:5
    #63 0x7f8beabd8d5b in XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:5565:8
    #64 0x7f8beabdade1 in XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:5624:21
    #65 0x7f8beabfeec0 in mozilla::BootstrapImpl::XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/Bootstrap.cpp:45:12
    #66 0x556721747814 in do_main(int, char**, char**) /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:224:22
    #67 0x556721747814 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:351:16
    #68 0x7f8c04adc0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #69 0x556721698192 in _start (/home/user/workspace/browsers/m-c-20210503214210-asan-debug/firefox+0x67192)

0x7f8bfacefbd0 is located 16 bytes to the left of global variable 'alloc151' defined in 'xulstore.8gq7w3bq-cgu.0' (0x7f8bfacefbe0) of size 88
0x7f8bfacefbd0 is located 16 bytes to the right of global variable 'vtable.G' defined in 'xulstore.8gq7w3bq-cgu.0' (0x7f8bfacefba0) of size 32
SUMMARY: AddressSanitizer: global-buffer-overflow /builds/worker/checkouts/gecko/xpcom/base/nsTraceRefcnt.cpp:1068:18 in NS_LogCOMPtrAddRef
Shadow bytes around the buggy address:
  0x0ff1ff595f20: f9 f9 f9 f9 00 00 f9 f9 f9 f9 f9 f9 00 00 f9 f9
  0x0ff1ff595f30: f9 f9 f9 f9 00 00 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0ff1ff595f40: f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9 00 00 00 00
  0x0ff1ff595f50: f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9 00 00 00 00
  0x0ff1ff595f60: f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9 00 00 00 00
=>0x0ff1ff595f70: f9 f9 f9 f9 00 00 00 00 f9 f9[f9]f9 00 00 00 00
  0x0ff1ff595f80: 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 00 00 00 00
  0x0ff1ff595f90: 00 00 f9 f9 f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9
  0x0ff1ff595fa0: 00 00 00 00 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00
  0x0ff1ff595fb0: 00 00 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 f9 f9
  0x0ff1ff595fc0: f9 f9 f9 f9 00 00 00 f9 f9 f9 f9 f9 00 00 00 f9
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
==110657==ABORTING

Looks like we're trying to <dynamic_cast> an object that's be implemented in Rust? Doesn't sound good, but this is debug code so we don't need to keep it hidden.

Group: core-security
Component: Startup and Profile System → XPCOM
Product: Toolkit → Core

In the Itanium C++ ABI VTables contain extra fields before the virtual function
pointer list for RTTI information, and these fields are not eliminated even
when RTTI is disabled using -fno-rtti. The two relevant fields for rust-xpcom's
vtables are the "offset to top" field, which contains the displacement to the
top of the object from the corresponding vtable pointer as a ptrdiff_t
(isize), and the "typeinfo pointer" field which points to the typeinfo object
and is null when building with -fno-rtti. The VTable pointer points after these
fields to the beginning of the virtual function pointer list.

While these extra fields would generally not be accessed in -fno-rtti
situations, gcc and clang still support dynamic_cast<void*> even when
-fno-rtti is passed, meaning that the "offset to top" field should be present.

Although I was unable to find documentation for the C++ ABI used on Darwin, it
appears to behave the same as the Itanium C++ ABI when it comes to VTable
layout.

In order to include these fields in the manual vtables built by the rust-xpcom
macros, a &'static VTableExtra<VTableType> is used instead of directly using
the vtable type, and the vtable reference stored in the struct is offset into
the allocation.

As the only platform I know of to not include these extra fields is Windows,
they are generated on all non-Windows platforms.

Assignee: nobody → nika
Status: NEW → ASSIGNED
Pushed by nlayzell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/39a07206999d
Include offset information in rust-xpcom vtables, r=mccr8
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: