Open Bug 2073725 Opened 2 months ago Updated 2 months ago

ThreadSanitizer: data race [@ internal_getenv] vs. [@ mmap]

Categories

(Core :: Graphics, defect)

defect

Tracking

()

Tracking Status
firefox158 --- affected

People

(Reporter: tsmith, Unassigned)

References

(Blocks 1 open bug, )

Details

(Keywords: csectype-race, Whiteboard: [deduped][nosec])

Attachments

(1 file)

Attached file tsan-log.txt —

Found with m-c 20260722-81e16b8b1609 (--enable-thread-sanitizer)

This was found by visiting a live website with a TSan build. This has been reported many times but it is not consistently reproducible.

STR:

  • Launch browser and visit site

This issue was triggered by visiting http://hattonsantiques.co.uk/.

WARNING: ThreadSanitizer: data race (pid=6436)
  Read of size 1 at 0x7fff40d59248 by thread T69 (mutexes: write M0, write M1):
    #0 internal_getenv /builds/worker/workspace/obj-build/mozglue/interposers/./../../../../checkouts/gecko/mozglue/interposers/env_interposer.cpp:18:29 (firefox-bin+0x16a4e6) (BuildId: 79ebb916733c2f322aeabd67e1a58b3e12649a6a)
    #1 getenv /builds/worker/workspace/obj-build/mozglue/interposers/./../../../../checkouts/gecko/mozglue/interposers/env_interposer.cpp:37:18 (firefox-bin+0x16a4e6)
    #2 LoadVendors build/../src/EGL/libeglvendor.c:43:15 (libEGL.so.1+0xc2fd) (BuildId: 236d96c92ee2914a0e90e06e01b79dfcba0f7b41)
    #3 __eglLoadVendors build/../src/EGL/libeglvendor.c:139:5 (libEGL.so.1+0x9ff0) (BuildId: 236d96c92ee2914a0e90e06e01b79dfcba0f7b41)
    #4 eglQueryString build/../src/EGL/libegl.c:928:17 (libEGL.so.1+0x9ff0)
    #5 mozilla::gl::GLLibraryEGL::Init(nsTSubstring<char>*) /builds/worker/workspace/obj-build/gfx/gl/./../../../../checkouts/gecko/gfx/gl/GLLibraryEGL.cpp:667:3 (libxul.so+0x531ed1e) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #6 mozilla::gl::GLLibraryEGL::Get(nsTSubstring<char>*) /builds/worker/workspace/obj-build/gfx/gl/./../../../../checkouts/gecko/gfx/gl/GLLibraryEGL.cpp:508:32 (libxul.so+0x5315c37) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #7 DefaultEglDisplay /builds/worker/workspace/obj-build/gfx/gl/./../../../../checkouts/gecko/gfx/gl/GLContextEGL.h:25:20 (libxul.so+0x531d8f7) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #8 mozilla::gl::GLContextProviderEGL::CreateHeadless(mozilla::gl::GLContextCreateDesc const&, nsTSubstring<char>*) /builds/worker/workspace/obj-build/gfx/gl/./../../../../checkouts/gecko/gfx/gl/GLContextProviderEGL.cpp:1265:15 (libxul.so+0x531d8f7)
    #9 mozilla::gl::GLContextProviderLinux::CreateHeadless(mozilla::gl::GLContextCreateDesc const&, nsTSubstring<char>*) /builds/worker/checkouts/gecko/gfx/gl/GLContextProviderLinux.cpp:40:12 (libxul.so+0x52eedf4) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    ...

  Previous write of size 8 at 0x7fff40d59248 by main thread:
    #0 mmap /builds/worker/fetches/llvm-project/compiler-rt/lib/tsan/rtl/../../sanitizer_common/sanitizer_common_interceptors.inc:7680:3 (firefox-bin+0x100bfb) (BuildId: 79ebb916733c2f322aeabd67e1a58b3e12649a6a)
    #1 _hb_blob_try_mmap /builds/worker/workspace/obj-build/gfx/harfbuzz/src/./../../../../../checkouts/gecko/gfx/harfbuzz/src/hb-blob.cc:647:29 (libxul.so+0x56306b6) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #2 hb_blob_create_from_file_or_fail /builds/worker/workspace/obj-build/gfx/harfbuzz/src/./../../../../../checkouts/gecko/gfx/harfbuzz/src/hb-blob.cc:794:25 (libxul.so+0x56306b6)
    #3 hb_face_create_from_file_or_fail /builds/worker/workspace/obj-build/gfx/harfbuzz/src/./../../../../../checkouts/gecko/gfx/harfbuzz/src/hb-face.cc:321:21 (libxul.so+0x56391ae) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #4 gfxFontconfigFontEntry::GetHBFace() /builds/worker/checkouts/gecko/gfx/thebes/gfxFcPlatformFontList.cpp:489:14 (libxul.so+0x59f5d09) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #5 gfxFontconfigFontEntry::GetFontTableInternal(unsigned int) /builds/worker/checkouts/gecko/gfx/thebes/gfxFcPlatformFontList.cpp:684:41 (libxul.so+0x59f6c3a) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #6 gfxFontEntry::GetFontTable(unsigned int) /builds/worker/workspace/obj-build/gfx/thebes/./../../../../checkouts/gecko/gfx/thebes/gfxFontEntry.cpp:480:10 (libxul.so+0x5a69335) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #7 AutoTable /builds/worker/checkouts/gecko/gfx/thebes/gfxFontEntry.h:393:27 (libxul.so+0x59f60a4) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #8 gfxFontconfigFontEntry::ReadCMAP(FontInfoData*) /builds/worker/checkouts/gecko/gfx/thebes/gfxFcPlatformFontList.cpp:552:15 (libxul.so+0x59f60a4)
    #9 gfxPlatformFontList::InitializeFamily(mozilla::fontlist::Family*, bool) /builds/worker/workspace/obj-build/gfx/thebes/./../../../../checkouts/gecko/gfx/thebes/gfxPlatformFontList.cpp:1996:19 (libxul.so+0x5abb653) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #10 LoadCmapsRunnable::Run() /builds/worker/workspace/obj-build/gfx/thebes/./../../../../checkouts/gecko/gfx/thebes/gfxPlatformFontList.cpp:1621:18 (libxul.so+0x5ae5b4c) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    ...

  Location is global '??' at 0x7fff40d4b000 (libEGL.so.1+0xe248)

  Mutex M0 (0x720c000f33f0) created at:
    #0 pthread_mutex_init /builds/worker/fetches/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1398:3 (firefox-bin+0xc96ac) (BuildId: 79ebb916733c2f322aeabd67e1a58b3e12649a6a)
    #1 mozilla::detail::MutexImpl::MutexImpl() /builds/worker/checkouts/gecko/mozglue/misc/Mutex_posix.cpp:74:7 (firefox-bin+0x1b8132) (BuildId: 79ebb916733c2f322aeabd67e1a58b3e12649a6a)
    #2 OffTheBooksMutex /builds/worker/workspace/obj-build/dist/include/mozilla/Mutex.h:45:12 (libxul.so+0x5315a45) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #3 Mutex /builds/worker/workspace/obj-build/dist/include/mozilla/StaticMutex.h:60:35 (libxul.so+0x5315a45)
    #4 Lock /builds/worker/workspace/obj-build/dist/include/mozilla/StaticMutex.h:30:42 (libxul.so+0x5315a45)
    #5 BaseAutoLock /builds/worker/workspace/obj-build/dist/include/mozilla/Mutex.h:159:11 (libxul.so+0x5315a45)
    #6 mozilla::gl::GLLibraryEGL::Get(nsTSubstring<char>*) /builds/worker/workspace/obj-build/gfx/gl/./../../../../checkouts/gecko/gfx/gl/GLLibraryEGL.cpp:505:23 (libxul.so+0x5315a45)
    #7 DefaultEglDisplay /builds/worker/workspace/obj-build/gfx/gl/./../../../../checkouts/gecko/gfx/gl/GLContextEGL.h:25:20 (libxul.so+0x531d8f7) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #8 mozilla::gl::GLContextProviderEGL::CreateHeadless(mozilla::gl::GLContextCreateDesc const&, nsTSubstring<char>*) /builds/worker/workspace/obj-build/gfx/gl/./../../../../checkouts/gecko/gfx/gl/GLContextProviderEGL.cpp:1265:15 (libxul.so+0x531d8f7)
    #9 mozilla::gl::GLContextProviderLinux::CreateHeadless(mozilla::gl::GLContextCreateDesc const&, nsTSubstring<char>*) /builds/worker/checkouts/gecko/gfx/gl/GLContextProviderLinux.cpp:40:12 (libxul.so+0x52eedf4) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #10 operator() /builds/worker/workspace/obj-build/dom/canvas/./../../../../checkouts/gecko/dom/canvas/WebGLContext.cpp:390:38 (libxul.so+0x79ab581) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #11 operator() /builds/worker/workspace/obj-build/dom/canvas/./../../../../checkouts/gecko/dom/canvas/WebGLContext.cpp:403:11 (libxul.so+0x79ab581)
    #12 mozilla::WebGLContext::CreateAndInitGL(bool, std::vector<mozilla::WebGLContext::FailureReason, std::allocator<mozilla::WebGLContext::FailureReason>>*) /builds/worker/workspace/obj-build/dom/canvas/./../../../../checkouts/gecko/dom/canvas/WebGLContext.cpp:397:22 (libxul.so+0x79ab581)
    ...

  Mutex M1 (0x555556aa2488) created at:
    #0 pthread_mutex_lock /builds/worker/fetches/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1424:3 (firefox-bin+0xc99c7) (BuildId: 79ebb916733c2f322aeabd67e1a58b3e12649a6a)
    #1 getenv /builds/worker/workspace/obj-build/mozglue/interposers/./../../../../checkouts/gecko/mozglue/interposers/env_interposer.cpp:36:3 (firefox-bin+0x16a4c3) (BuildId: 79ebb916733c2f322aeabd67e1a58b3e12649a6a)
    #2 LogTest /builds/worker/workspace/obj-build/mozglue/baseprofiler/./../../../../checkouts/gecko/mozglue/baseprofiler/core/platform.cpp:127:31 (firefox-bin+0x186730) (BuildId: 79ebb916733c2f322aeabd67e1a58b3e12649a6a)
    #3 mozilla::baseprofiler::profiler_init(void*) /builds/worker/workspace/obj-build/mozglue/baseprofiler/./../../../../checkouts/gecko/mozglue/baseprofiler/core/platform.cpp:2394:3 (firefox-bin+0x186730)
    #4 AutoProfilerInit /builds/worker/workspace/obj-build/dist/include/mozilla/BaseProfiler.h:377:33 (firefox-bin+0x14c659) (BuildId: 79ebb916733c2f322aeabd67e1a58b3e12649a6a)
    #5 main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:393:3 (firefox-bin+0x14c659)

  Thread T69 'CanvasRenderer' (tid=6539, running) created by main thread at:
    #0 pthread_create /builds/worker/fetches/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1078:3 (firefox-bin+0xc7d2a) (BuildId: 79ebb916733c2f322aeabd67e1a58b3e12649a6a)
    #1 _PR_CreateThread /builds/worker/workspace/obj-build/config/external/nspr/pr/./../../../../../../checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:440:14 (libnspr4.so+0x43ba1) (BuildId: 8d221630a9af393627ad99706af33c3b515ea02b)
    #2 PR_CreateThread /builds/worker/workspace/obj-build/config/external/nspr/pr/./../../../../../../checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:508:12 (libnspr4.so+0x38e34) (BuildId: 8d221630a9af393627ad99706af33c3b515ea02b)
    #3 nsThread::Init(nsTSubstring<char> const&) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/nsThread.cpp:686:20 (libxul.so+0x4b4b4f2) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #4 nsThreadManager::NewNamedThread(nsTSubstring<char> const&, nsIThreadManager::ThreadCreationOptions, nsIThread**) /builds/worker/workspace/obj-build/xpcom/threads/./../../../../checkouts/gecko/xpcom/threads/nsThreadManager.cpp:618:22 (libxul.so+0x4b54072) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #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:185:57 (libxul.so+0x4b5b86e) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #6 NS_NewNamedThread<15UL> /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.h:73:10 (libxul.so+0x5b07229) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #7 mozilla::gfx::CanvasRenderThread::Start() /builds/worker/workspace/obj-build/gfx/ipc/./../../../../checkouts/gecko/gfx/ipc/CanvasRenderThread.cpp:80:17 (libxul.so+0x5b07229)
    #8 gfxPlatform::InitLayersIPC() /builds/worker/checkouts/gecko/gfx/thebes/gfxPlatform.cpp:1360:7 (libxul.so+0x5a18b8f) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #9 gfxPlatform::Init() /builds/worker/checkouts/gecko/gfx/thebes/gfxPlatform.cpp:994:3 (libxul.so+0x5a14e7f) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    #10 GetPlatform /builds/worker/workspace/obj-build/dist/include/gfxPlatform.h:187:7 (libxul.so+0xa3fc641) (BuildId: d213370ffead8c16a1453976f5909a4de661a802)
    ...

SUMMARY: ThreadSanitizer: data race /builds/worker/workspace/obj-build/mozglue/interposers/./../../../../checkouts/gecko/mozglue/interposers/env_interposer.cpp:18:29 in internal_getenv

This rating has been determined by our automated bug rating tool (currently under development). No validation or verification has been performed.

Rating: no-sec
Confidence: 60% env_interposer and harfbuzz sources were read directly, but libglvnd/libEGL is not indexed and the TSan stale-shadow mechanism is inferred rather than proven.

Explanation: TSan report during WebGL/canvas graphics initialization. The flagged read at env_interposer.cpp:18:29 is aName[0], the first byte of the name string that the system libEGL (libglvnd LoadVendors) passes to Firefox's interposed getenv; TSan attributes the address to a read-only string constant inside libEGL.so.1. The reported previous write is an mmap of a font file by harfbuzz on the main thread. These operations share no live mutable object: getenv is serialized under gEnvLock and only reads environ/read-only strings, while the mmap maps a font file to a kernel-chosen address. The address collision is a stale-shadow/address-reuse artifact (an earlier font mapping was unmapped and the region later underlies libEGL's mapping). No environment memory is written, no memory corruption, no info leak, and not even a crash occurs. Attack vector is a web page triggering GL initialization; it is reachable during normal browsing but produces no security-relevant outcome and grants an attacker no capability. This is a benign TSan artifact, not an exploitable memory-safety defect.

Severity: -- → S2

Automatic triage (under development): deduplication

This duplicate check has been performed by our automated bug triage tool (currently under development). No validation or verification has been performed.

Bugs considered:

  • bug 1746546 — similar symptoms but a different root cause
  • bug 1505139 — similar symptoms but a different root cause
  • bug 1852596 — similar symptoms but a different root cause

Confidence: 80%

Whiteboard: [deduped] → [deduped][nosec]

Automatic triage (under development): sec-rating

This rating has been determined by our automated bug rating tool (currently under development). No validation or verification has been performed.

Confidence: 75%

Group: gfx-core-security
Severity: S2 → S4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: