Closed Bug 2037986 Opened 6 months ago Closed 6 months ago

ThreadSanitizer: heap-use-after-free [@ mozilla::net::ConnectionAttemptPool::RemoveConnectionAttempt]

Categories

(Core :: Networking: HTTP, defect, P1)

defect

Tracking

()

RESOLVED FIXED
152 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr140 --- unaffected
firefox150 --- wontfix
firefox151 + fixed
firefox152 + fixed

People

(Reporter: tsmith, Assigned: kershaw)

References

(Blocks 1 open bug, Regression)

Details

(4 keywords, Whiteboard: [necko-triaged][necko-priority-queue][adv-main151+r])

Attachments

(1 file, 2 external files)

Found with m-c 20260506-249aec08cc0d (--enable-thread-sanitizer)

This was found by visiting a live website with a TSan build.

STR:

  • Launch browser and visit site

This issue was triggered by visiting http://www.macworld.com/. I have not been able to reproduce the issue.

WARNING: ThreadSanitizer: heap-use-after-free (pid=64924)
  Read of size 1 at 0x7244003928b7 by thread T9:
    #0 HasConnected /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/ConnectionAttempt.h:59:32 (libxul.so+0x44bee66) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #1 mozilla::net::ConnectionAttemptPool::RemoveConnectionAttempt(mozilla::net::ConnectionAttempt*, bool) /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/ConnectionAttemptPool.cpp:89:16 (libxul.so+0x44bee66)
    #2 mozilla::net::ConnectionAttemptPool::TimeoutTick() /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/ConnectionAttemptPool.cpp:187:7 (libxul.so+0x44bf5fa) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #3 mozilla::net::ConnectionEntry::TimeoutTick() /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/ConnectionEntry.cpp:814:27 (libxul.so+0x44c5787) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #4 mozilla::net::nsHttpConnectionMgr::TimeoutTick() /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/nsHttpConnectionMgr.cpp:3560:37 (libxul.so+0x46a3f48) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #5 mozilla::net::nsHttpConnectionMgr::Observe(nsISupports*, char const*, char16_t const*) /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/nsHttpConnectionMgr.cpp:331:7 (libxul.so+0x46a3c4e) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #6 non-virtual thunk to mozilla::net::nsHttpConnectionMgr::Observe(nsISupports*, char const*, char16_t const*) /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/nsHttpConnectionMgr.cpp (libxul.so+0x46a44b9) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    ...

  Previous write of size 8 at 0x7244003928b0 by thread T9:
    #0 free /builds/worker/fetches/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:741:3 (firefox-bin+0xc46fa) (BuildId: 1a48a677e2f2c9115ca2a65e1deb3fa743dda044)
    #1 operator delete /builds/worker/workspace/obj-build/dist/include/mozilla/cxxalloc.h:64:10 (libxul.so+0x44ce79d) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #2 mozilla::net::DnsAndConnectSocket::~DnsAndConnectSocket() /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/DnsAndConnectSocket.cpp:95:45 (libxul.so+0x44ce79d)
    #3 mozilla::net::HappyEyeballsConnectionAttempt::Release() /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/ConnectionAttempt.cpp:11:1 (libxul.so+0x44be8e3) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #4 Release /builds/worker/workspace/obj-build/dist/include/mozilla/RefPtr.h:47:40 (libxul.so+0x3dc79dd) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #5 ~nsCOMPtr /builds/worker/checkouts/gecko/xpcom/base/nsCOMPtr.h:342:7 (libxul.so+0x3dc79dd)
    #6 Destruct /builds/worker/workspace/obj-build/dist/include/nsTArray.h:568:45 (libxul.so+0x3dc79dd)
    #7 DestructRange /builds/worker/workspace/obj-build/dist/include/nsTArray.h:2327:7 (libxul.so+0x3dc79dd)
    #8 RemoveElementsAtUnsafe /builds/worker/workspace/obj-build/dist/include/nsTArray.h:2416:3 (libxul.so+0x3dc79dd)
    #9 bool nsTArray_Impl<RefPtr<mozilla::a11y::LocalAccessible>, nsTArrayInfallibleAllocator>::RemoveElement<mozilla::a11y::LocalAccessible*, nsDefaultComparator<RefPtr<mozilla::a11y::LocalAccessible>, mozilla::a11y::LocalAccessible*>>(mozilla::a11y::LocalAccessible* const&, nsDefaultComparator<RefPtr<mozilla::a11y::LocalAccessible>, mozilla::a11y::LocalAccessible*> const&) /builds/worker/workspace/obj-build/dist/include/nsTArray.h:1836:5 (libxul.so+0x3dc79dd)
    #10 RemoveElement<mozilla::net::ConnectionAttempt *> /builds/worker/workspace/obj-build/dist/include/nsTArray.h:1844:12 (libxul.so+0x44bee4d) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #11 mozilla::net::ConnectionAttemptPool::RemoveConnectionAttempt(mozilla::net::ConnectionAttempt*, bool) /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/ConnectionAttemptPool.cpp:88:17 (libxul.so+0x44bee4d)
    #12 mozilla::net::ConnectionAttemptPool::TimeoutTick() /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/ConnectionAttemptPool.cpp:187:7 (libxul.so+0x44bf5fa) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #13 mozilla::net::ConnectionEntry::TimeoutTick() /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/ConnectionEntry.cpp:814:27 (libxul.so+0x44c5787) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #14 mozilla::net::nsHttpConnectionMgr::TimeoutTick() /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/nsHttpConnectionMgr.cpp:3560:37 (libxul.so+0x46a3f48) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #15 mozilla::net::nsHttpConnectionMgr::Observe(nsISupports*, char const*, char16_t const*) /builds/worker/workspace/obj-build/netwerk/protocol/http/./../../../../../checkouts/gecko/netwerk/protocol/http/nsHttpConnectionMgr.cpp:331:7 (libxul.so+0x46a3c4e) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    ...

  Thread T9 'Socket Thread' (tid=64943, running) created by main thread at:
    #0 pthread_create /builds/worker/fetches/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1041:3 (firefox-bin+0xc5b3a) (BuildId: 1a48a677e2f2c9115ca2a65e1deb3fa743dda044)
    #1 _PR_CreateThread /builds/worker/workspace/obj-build/config/external/nspr/pr/./../../../../../../checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:428:10 (libnspr4.so+0x4261e) (BuildId: 3defe814b28a573fef9c9a3848065c73bbd82858)
    #2 PR_CreateThread /builds/worker/workspace/obj-build/config/external/nspr/pr/./../../../../../../checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:495:10 (libnspr4.so+0x37994) (BuildId: 3defe814b28a573fef9c9a3848065c73bbd82858)
    #3 nsThread::Init(nsTSubstring<char> const&) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/nsThread.cpp:623:20 (libxul.so+0x3e1a95c) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #4 nsThreadManager::NewNamedThread(nsTSubstring<char> const&, nsIThreadManager::ThreadCreationOptions, nsIThread**) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/nsThreadManager.cpp:613:22 (libxul.so+0x3e21a5a) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #5 NS_NewNamedThread(nsTSubstring<char> const&, nsIThread**, already_AddRefed<nsIRunnable>, nsIThreadManager::ThreadCreationOptions) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:186:57 (libxul.so+0x3e29e55) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #6 NS_NewNamedThread<14UL> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:85:10 (libxul.so+0x40b1935) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #7 mozilla::net::nsSocketTransportService::Init() /builds/worker/workspace/obj-build/netwerk/base/./../../../../checkouts/gecko/netwerk/base/nsSocketTransportService2.cpp:810:19 (libxul.so+0x40b1935)
    #8 mozilla::xpcom::CreateInstanceImpl(mozilla::xpcom::ModuleID, nsID const&, void**) /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:12601:7 (libxul.so+0x3dcf702) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #9 mozilla::xpcom::StaticModule::CreateInstance(nsID const&, void**) const /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:13858:10 (libxul.so+0x3dda73a) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #10 CreateInstance /builds/worker/workspace/obj-build/xpcom/components/./../../../../checkouts/gecko/xpcom/components/nsComponentManager.cpp:187:46 (libxul.so+0x3de617e) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #11 nsComponentManagerImpl::GetServiceLocked(mozilla::Maybe<mozilla::MonitorAutoLockBase<mozilla::Monitor>>&, (anonymous namespace)::EntryWrapper&, nsID const&, void**) /builds/worker/workspace/obj-build/xpcom/components/./../../../../checkouts/gecko/xpcom/components/nsComponentManager.cpp:984:17 (libxul.so+0x3de617e)
    #12 nsComponentManagerImpl::GetService(mozilla::xpcom::ModuleID, nsID const&, void**) /builds/worker/workspace/obj-build/xpcom/components/./../../../../checkouts/gecko/xpcom/components/nsComponentManager.cpp:1074:10 (libxul.so+0x3de6825) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    #13 mozilla::xpcom::GetServiceHelper::operator()(nsID const&, void**) const /builds/worker/workspace/obj-build/xpcom/components/StaticComponents.cpp:13986:50 (libxul.so+0x3ddb568) (BuildId: 8206c81da620ecabaea07cedb1645973d2b13ea4)
    ...
Attached file tsan-log.txt —
Assignee: nobody → kershaw
Severity: -- → S3
Priority: -- → P1
Whiteboard: [necko-triaged]
Attached file (secure) —

Comment on attachment 9584292 [details]
(secure)

Security Approval Request

  • How easily could an exploit be constructed based on the patch?: Possible crash
  • Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: No
  • Which branches (beta, release, and/or ESR) are affected by this flaw, and do the release status flags reflect this affected/unaffected state correctly?: 150
  • If not all supported branches, which bug introduced the flaw?: Bug 1953462
  • Do you have backports for the affected branches?: Yes
  • If not, how different, hard to create, and risky will they be?:
  • How likely is this patch to cause regressions; how much testing does it need?: The patch is straightforward.
  • Is the patch ready to land after security approval is given?: Yes
  • Is Android affected?: Yes
Attachment #9584292 - Flags: sec-approval?
Severity: S3 → S2
Whiteboard: [necko-triaged] → [necko-triaged][necko-priority-queue]

Doesn't seem too dangerous, so I'll mark it sec-moderate, which means it doesn't need sec-approval to land. It looks like it is checking a bool and that affects some count? I'm not sure how bad that is.

Comment on attachment 9584292 [details]
(secure)

newly labeled moderate

Attachment #9584292 - Flags: sec-approval?
Group: network-core-security → core-security-release
Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 152 Branch

:karshaw could you add a beta uplift request? Tomorrow is the last day to make 151.0 release.

Flags: needinfo?(kershaw)

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Possible crash
  • Code covered by automated testing?: yes
  • Fix verified in Nightly?: yes
  • Needs manual QE testing?: no
  • Steps to reproduce for manual QE testing: N/A
  • Risk associated with taking this patch: low
  • Explanation of risk level: The fix is straightforward.
  • String changes made/needed?: N/A
  • Is Android affected?: yes
Attachment #9585254 - Flags: approval-mozilla-beta?
Attached file (secure) —
Flags: needinfo?(kershaw)
Attachment #9585254 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [sec] [uplift] [qa-triage-done-c152/b151]
Whiteboard: [necko-triaged][necko-priority-queue] → [necko-triaged][necko-priority-queue][adv-main151+r][adv-esr115.36+r][adv-esr140.11+r]
Whiteboard: [necko-triaged][necko-priority-queue][adv-main151+r][adv-esr115.36+r][adv-esr140.11+r] → [necko-triaged][necko-priority-queue][adv-main151+r]
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: