Skip to content
Memory corruption Advisory Advanced CVE-2026-7901

Use after free in ANGLE (CVE-2026-7901)

ANGLE's Metal shader-library cache returned a reference to an entry after releasing the cache lock, so a concurrent shader-link task could trim the cache and free that entry before the caller locked it. This caused a use-after-free in the GPU process during Metal library compilation.

Syn4pse Follow

Originally disclosed on Chrome VRP

Bounty$16,000 High View original
  • Fix shipped in 37 days

Summary

ANGLE's Metal shader-library cache returns a LibraryCacheEntry & from LibraryCache::getCacheEntry while holding mCacheLock, but LibraryCache::getOrCompileShaderLibrary drops that cache lock before taking entry.lock. Once the cache was converted to an evicting HashingMRUCache, concurrent shader-link tasks could call TrimCache and destroy the referenced entry before the caller locks it, leading to the UAF in GPU process during Metal library compilation.

Details

CreateMslShaderLib compiles translated MSL through the display-global Metal library cache. LibraryCache::getOrCompileShaderLibrary obtains a reference to an entry and only then locks that entry's mutex:

C++
ASSERT(source != nullptr);
LibraryCache::LibraryCacheEntry &entry =
    getCacheEntry(LibraryKey(source, macros, disableFastMath, usesInvariance));

// Lock this cache entry while compiling the shader. This causes other threads calling this
// function to wait and not duplicate the compilation.
std::lock_guard<std::mutex> entryLockGuard(entry.lock);
if (entry.library)
{
    return entry.library;
}

entry.library = CreateShaderLibrary(metalDevice, *source, macros, disableFastMath,
                                    usesInvariance, errorOut);
return entry.library;

LibraryCache::getCacheEntry protects lookup and insertion with mCacheLock, but it returns a reference to an object stored inside the MRU container and releases the cache lock before the caller touches that reference again. The same function also trims the MRU before inserting:

C++
    // Lock while searching or adding new items to the cache.
    std::lock_guard<std::mutex> cacheLockGuard(mCacheLock);

    auto iter = mCache.Get(key);
    if (iter != mCache.end())
    {
        return iter->second;
    }

    angle::TrimCache(kMaxCachedLibraries, kGCLimit, "metal library", &mCache);

    iter = mCache.Put(std::move(key), LibraryCacheEntry());
    return iter->second;

That means the lifetime guarantee on entry ends when mCacheLock is released. A second worker can immediately re-enter getCacheEntry, hit angle::TrimCache, and erase the least-recently-used node that the first thread still references. The destructor for LibraryCacheEntry does lock entry.lock, but that only serializes destruction with in-flight compilation if the caller already has a valid pointer to the same object. Therefore it does not prevent a caller from dereferencing after the container node itself has been freed, and thus cause the UAF.

Bisection

This issue is introduced by the commit https://chromium-review.googlesource.com/c/angle/angle/+/4614362, which introduced the MRUCache, making the attacker available to free TrimCache and cause UAF.

Reproduction

Host the poc.html using python3 -m http.server 8080

Run chromium (e.g., https://storage.googleapis.com/chromium-browser-asan/mac-release-arm64/asan-mac-release-1606755.zip) with:

./Chromium.app/Contents/MacOS/Chromium http://127.0.0.1:8080/poc.html http://127.0.0.1:8080/poc.html http://127.0.0.1:8080/poc.html http://127.0.0.1:8080/poc.html

You would observe the UAF shown in asan.txt.

Suggested Fix

The minimal fix is to store cache entries with ref-counted pointer.

The original report as published on the Chromium issue tracker, by Syn4pse (@ret2happy). Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

This report concerns ANGLE, the translation layer that Chrome uses to run OpenGL ES and WebGL content on top of platform graphics APIs. On macOS that backend is Metal, and ANGLE keeps a display-global cache of compiled Metal shader libraries so that identical shader sources are not compiled twice.

The cache lives in LibraryCache (third_party/angle/src/libANGLE/renderer/metal/mtl_library_cache.mm). Shader compilation is reached through CreateMslShaderLib in ProgramExecutableMtl.mm, which compiles translated MSL through that display-global cache. The bug is a use-after-free in this cache, triggered while the GPU process compiles Metal libraries. The platform records the weakness as use after free, the severity as high, and the bounty as 16,000.00 USD. The report is an advisory disclosed on 2026-05-05, credited to Syn4pse (@ret2happy).

The report does not describe any web-facing endpoint, parameter or header. The failure happens inside the GPU process during Metal library compilation.

Setup

The report lists no accounts, roles or special tooling beyond a browser build and a local web server. The preconditions it does state are:

  1. A build of ANGLE in which the library cache has been converted to an evicting HashingMRUCache. The report's bisection attributes the introduction of the issue to the commit that introduced the MRUCache: https://chromium-review.googlesource.com/c/angle/angle/+/4614362.
  2. Concurrent shader-link tasks, so that one thread can be inside getOrCompileShaderLibrary while another re-enters getCacheEntry and trims the cache.
  3. A macOS arm64 Chromium build for reproduction. The report points at an ASan build:
Text
https://storage.googleapis.com/chromium-browser-asan/mac-release-arm64/asan-mac-release-1606755.zip

No image or video accompanies the report, so there is nothing visual to show; the evidence it cites is the ASan output in asan.txt.

Finding it

The researcher noticed an asymmetry between two functions in the cache. LibraryCache::getCacheEntry returns a LibraryCacheEntry & while holding mCacheLock, but LibraryCache::getOrCompileShaderLibrary drops that cache lock before it takes entry.lock. The reference therefore outlives the lock that made it safe.

That alone would be harmless if entries were never removed. Once the cache became an evicting HashingMRUCache, however, a concurrent shader-link task could call TrimCache and destroy the referenced entry before the original caller locked it. The result is a use-after-free in the GPU process during Metal library compilation.

Exploitation

Step 1: obtain a reference to a cache entry

LibraryCache::getOrCompileShaderLibrary obtains a reference to an entry and only then locks that entry's mutex:

C++
ASSERT(source != nullptr);
LibraryCache::LibraryCacheEntry &entry =
    getCacheEntry(LibraryKey(source, macros, disableFastMath, usesInvariance));

// Lock this cache entry while compiling the shader. This causes other threads calling this
// function to wait and not duplicate the compilation.
std::lock_guard<std::mutex> entryLockGuard(entry.lock);
if (entry.library)
{
    return entry.library;
}

entry.library = CreateShaderLibrary(metalDevice, *source, macros, disableFastMath,
                                    usesInvariance, errorOut);
return entry.library;

The call to getCacheEntry returns a reference into the cache container. The per-entry entry.lock is taken afterwards, and the comment explains its intended purpose: to make other threads calling the same function wait rather than duplicate the compilation. Nothing in this function keeps the cache container itself stable between the return of getCacheEntry and the acquisition of entry.lock.

Step 2: the lookup releases the cache lock

LibraryCache::getCacheEntry protects lookup and insertion with mCacheLock, but it returns a reference to an object stored inside the MRU container and releases the cache lock before the caller touches that reference again. The same function also trims the MRU before inserting:

C++
    // Lock while searching or adding new items to the cache.
    std::lock_guard<std::mutex> cacheLockGuard(mCacheLock);

    auto iter = mCache.Get(key);
    if (iter != mCache.end())
    {
        return iter->second;
    }

    angle::TrimCache(kMaxCachedLibraries, kGCLimit, "metal library", &mCache);

    iter = mCache.Put(std::move(key), LibraryCacheEntry());
    return iter->second;

Both return paths hand back iter->second, a reference to a node owned by the container. The std::lock_guard on mCacheLock is destroyed as the function returns, so the lifetime guarantee on entry ends at that point. The trim call inside the same critical section shows that the container does evict nodes: angle::TrimCache is invoked with kMaxCachedLibraries and kGCLimit before a new entry is inserted.

Step 3: a second worker evicts the referenced node

With the cache lock released, a second worker can immediately re-enter getCacheEntry, reach angle::TrimCache, and erase the least-recently-used node that the first thread still references. The first thread then proceeds to std::lock_guard<std::mutex> entryLockGuard(entry.lock) on memory that has been freed.

The report notes that the destructor for LibraryCacheEntry does lock entry.lock, but that this only serialises destruction with in-flight compilation if the caller already has a valid pointer to the same object. It therefore does not prevent a caller from dereferencing after the container node itself has been freed, which is the use-after-free.

Step 4: reproduce with a local page

The report's reproduction uses a page named poc.html, served locally:

Bash
python3 -m http.server 8080

Chromium is then run with the same URL passed four times:

The report states that you would observe the UAF shown in asan.txt. What the four identical arguments are intended to achieve is not explained in the report either; the only stated outcome is the ASan report of the use-after-free.

Root cause

The mistake is a lifetime mismatch between a container and the references it hands out. getCacheEntry returns a reference to a node inside HashingMRUCache and releases mCacheLock on return. The caller in getOrCompileShaderLibrary treats that reference as stable and only then takes the per-entry mutex. Because the cache evicts, via angle::TrimCache, a concurrent caller can free the node in the window between the return and the lock acquisition.

The existing defences do not cover this window. The per-entry entry.lock serialises compilation and, in the destructor, serialises destruction with in-flight compilation, but only for callers that already hold a valid pointer to the same object. It cannot protect a caller that has not yet locked and whose pointer is already dangling. The cache lock protects the lookup and insertion, but not the use of the returned reference afterwards. The report attributes the introduction of the issue to the commit that introduced the MRUCache.

Impact

The report describes a use-after-free in the GPU process during Metal library compilation, reachable through concurrent shader-link tasks. The platform classifies the issue as high severity. The report does not spell out a full exploit chain, does not claim code execution, and does not state which renderer or site conditions are required beyond the concurrency and the affected build. The practical effect it demonstrates is a use-after-free in the GPU process, evidenced by the ASan report.

Fix

The report states that the minimal fix is to store cache entries with a ref-counted pointer. That keeps the entry alive for as long as a caller holds a reference, independently of eviction from the MRU container. The report does not say whether this exact change was the one shipped; it presents it as the suggested fix.

Variants to test

  1. Other caches that return references into an evicting container. Look for functions that return T & or T * from inside a lock and whose container has a trim or eviction path. A positive result is a caller that uses the reference after the lock is released while another thread can evict.
  2. Per-entry locks taken after lookup. Search for patterns where a lookup returns an object and a per-object mutex is acquired afterwards. A positive result is a window in which the object can be destroyed before the mutex is taken.
  3. Destructors that lock the object's own mutex. As the report notes, this only helps callers that already hold a valid pointer. A positive result is a path where the container node is freed while a caller still holds a reference to it.
  4. Shader and pipeline caches on other graphics backends. The same display-global caching pattern may exist for other APIs. A positive result is a trim path reachable concurrently with compilation, producing a sanitizer report under parallel shader-link load.
  5. Stress the reproduction with more concurrent pages or workers. The report passes the same URL four times; varying the number of concurrent loads and the shader workload is a reasonable way to widen the race window. A positive result is a reproducible ASan use-after-free in the cache code.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 17 min read.

What happened, in plain words

Chrome can draw 3D graphics on web pages. To do that on a Mac, it uses a piece of software called ANGLE, which translates the drawing instructions a web page gives into instructions the Mac's graphics system (called Metal) understands. Drawing instructions are called shaders, and turning a shader into something the graphics chip can run is called compiling it. Compiling takes time, so ANGLE keeps a store of shaders it has already compiled, called a cache, and reuses them when the same shader comes up again.

This report is about a bug in that cache. When two parts of Chrome ask for shaders at the same time, one part can be handed a pointer to a cache entry, and before it uses that pointer, the other part can delete the entry to make room for something else. The first part then reads memory that has already been freed. In security terms that is called a use-after-free. It happens inside the GPU process, the separate part of Chrome that talks to the graphics hardware.

The platform records the weakness as use after free, the severity as high, and the bounty as 16,000.00 USD. The report is an advisory disclosed on 2026-05-05, credited to Syn4pse (@ret2happy).

The report does not describe any web address, form field or request header that an attacker sends. The failure happens inside the GPU process during Metal library compilation.

Context

What ANGLE and Metal are

A web page does not talk to the graphics chip directly. It asks the browser, and the browser passes the request down through layers. ANGLE is one of those layers: it takes OpenGL ES and WebGL instructions (the languages web graphics are written in) and translates them into whatever the operating system's graphics system expects. On macOS that system is Metal. Think of ANGLE as an interpreter at a meeting: the web page speaks one language, the Mac speaks another, and ANGLE translates between them.

What a shader and a shader library are

A shader is a small program that tells the graphics chip how to colour pixels or move points around. Before the chip can run a shader, the shader has to be compiled, which means turned from human-readable text into machine instructions. Compiling is slow, so browsers remember the result. A compiled shader library is that remembered result. If the same shader text appears again, the browser can skip the work and reuse the compiled version.

What a cache is

A cache is a store of things you have already worked out, kept so you do not have to work them out again. A everyday comparison: a cookbook with notes in the margin. Instead of looking up a recipe from scratch, you read your note. Caches are finite, so they need a rule for what to throw away when they are full. One common rule is least recently used (LRU): throw away the thing that has gone longest without being asked for.

What the bug is, in one sentence

The cache hands out a pointer to an entry, then lets go of the lock that kept that entry safe, and another part of the program can delete the entry before the first part uses the pointer.

Where the code lives

The cache is in LibraryCache, in the file third_party/angle/src/libANGLE/renderer/metal/mtl_library_cache.mm. Shader compilation is reached through CreateMslShaderLib in ProgramExecutableMtl.mm, which compiles translated MSL (Metal Shading Language, the text form of a Metal shader) through that display-global cache. Display-global means one cache shared by the whole display, not one per page or per tab.

What the report does not say

The report does not describe any web-facing endpoint, parameter or header. The attack surface is the shader compilation path that web content can drive through WebGL, and the failure happens inside the GPU process.

Setup

What you need before you can reproduce it

The report lists no accounts, roles or special tooling beyond a browser build and a local web server. The preconditions it does state are:

  1. A build of ANGLE in which the library cache has been converted to an evicting HashingMRUCache. Evicting means the cache throws old entries away when it is full. HashingMRUCache is the specific container type used: a hash map (a lookup table keyed by a computed number) combined with a most-recently-used eviction rule. The report's bisection, meaning the process of narrowing down which code change introduced the bug, attributes the introduction of the issue to the commit that introduced the MRUCache: https://chromium-review.googlesource.com/c/angle/angle/+/4614362.
  2. Concurrent shader-link tasks. Concurrent means happening at the same time. Shader-link tasks are the jobs that prepare shaders for use. You need at least two of them running at once, so that one thread can be inside getOrCompileShaderLibrary while another re-enters getCacheEntry and trims the cache. A thread is one line of execution inside a program; a program with several threads can do several things at once.
  3. A macOS arm64 Chromium build for reproduction. arm64 is the processor family used by recent Apple computers. The report points at an ASan build. ASan stands for AddressSanitizer, a tool built into some browser builds that watches memory and prints a detailed report when a program reads or writes memory it should not. The report gives this address:
Text
https://storage.googleapis.com/chromium-browser-asan/mac-release-arm64/asan-mac-release-1606755.zip

This is a download link for a prebuilt Chromium with AddressSanitizer switched on. You would download it, unzip it, and run the browser inside. The report points at an ASan build and states you would observe the UAF shown in asan.txt.

No image or video accompanies the report, so there is nothing visual to show; the evidence it cites is the ASan output in asan.txt.

Finding it

The observation

The researcher noticed an asymmetry between two functions in the cache. A function is a named block of code that does one job. LibraryCache::getCacheEntry returns a LibraryCacheEntry & while holding mCacheLock. The & means a reference: not a copy of the entry, but a pointer to where the entry lives in memory. mCacheLock is a mutex, a lock that only one thread can hold at a time, used to stop two threads from changing the same data at once. LibraryCache::getOrCompileShaderLibrary drops that cache lock before it takes entry.lock, a second, per-entry lock. The reference therefore outlives the lock that made it safe. Outlives here means it is still being used after the protection has gone.

Why that alone is not enough

That alone would be harmless if entries were never removed. If the cache only ever grew, the pointer would always point at something real. Once the cache became an evicting HashingMRUCache, however, a concurrent shader-link task could call TrimCache and destroy the referenced entry before the original caller locked it. TrimCache is the routine that removes old entries to make room. The result is a use-after-free in the GPU process during Metal library compilation.

Exploitation

Step 1: obtain a reference to a cache entry

LibraryCache::getOrCompileShaderLibrary obtains a reference to an entry and only then locks that entry's mutex:

C++
ASSERT(source != nullptr);
LibraryCache::LibraryCacheEntry &entry =
    getCacheEntry(LibraryKey(source, macros, disableFastMath, usesInvariance));

// Lock this cache entry while compiling the shader. This causes other threads calling this
// function to wait and not duplicate the compilation.
std::lock_guard<std::mutex> entryLockGuard(entry.lock);
if (entry.library)
{
    return entry.library;
}

entry.library = CreateShaderLibrary(metalDevice, *source, macros, disableFastMath,
                                    usesInvariance, errorOut);
return entry.library;

Line by line:

  • ASSERT(source != nullptr); is a safety check. It says: if source (the shader text) is empty, stop here. nullptr means "points at nothing".
  • LibraryCache::LibraryCacheEntry &entry = getCacheEntry(...) asks the cache for the entry matching this shader. The & means entry is a reference, a pointer to the entry stored inside the cache, not a copy. The arguments build a LibraryKey: the shader source, the macros (predefined substitutions used when compiling), whether fast maths is disabled, and whether invariance is used (a graphics setting about consistent results).
  • The comment explains the next line: the per-entry lock exists so that other threads calling the same function wait rather than compile the same shader twice.
  • std::lock_guard<std::mutex> entryLockGuard(entry.lock); takes the per-entry lock. A lock_guard is a small helper that takes a lock when it is created and releases it automatically when the function ends, so you cannot forget to unlock.
  • if (entry.library) { return entry.library; } checks whether this entry already holds a compiled library. If it does, return it straight away. This is the cache hit, the whole point of the cache.
  • entry.library = CreateShaderLibrary(...) compiles the shader and stores the result in the entry. This is the cache miss, the slow path.
  • return entry.library; hands the compiled library back to the caller.

The call to getCacheEntry returns a reference into the cache container. The per-entry entry.lock is taken afterwards, and the comment explains its intended purpose: to make other threads calling the same function wait rather than duplicate the compilation. Nothing in this function keeps the cache container itself stable between the return of getCacheEntry and the acquisition of entry.lock. In other words, between those two lines, the entry could be deleted, and the code would not notice.

Step 2: the lookup releases the cache lock

LibraryCache::getCacheEntry protects lookup and insertion with mCacheLock, but it returns a reference to an object stored inside the MRU container and releases the cache lock before the caller touches that reference again. The same function also trims the MRU before inserting:

C++
    // Lock while searching or adding new items to the cache.
    std::lock_guard<std::mutex> cacheLockGuard(mCacheLock);

    auto iter = mCache.Get(key);
    if (iter != mCache.end())
    {
        return iter->second;
    }

    angle::TrimCache(kMaxCachedLibraries, kGCLimit, "metal library", &mCache);

    iter = mCache.Put(std::move(key), LibraryCacheEntry());
    return iter->second;

Line by line:

  • The comment says the lock is held while searching or adding items to the cache.
  • std::lock_guard<std::mutex> cacheLockGuard(mCacheLock); takes the cache-wide lock. Only one thread can be inside this function's critical section at a time. A critical section is the stretch of code that must not be run by two threads at once.
  • auto iter = mCache.Get(key); looks up the key in the cache. iter is an iterator, a handle that points at a position inside the container.
  • if (iter != mCache.end()) { return iter->second; } checks whether the key was found. mCache.end() means "not found". iter->second is the value stored at that position, which is the cache entry. This is the first return path, and it hands back a reference to a node owned by the container.
  • angle::TrimCache(kMaxCachedLibraries, kGCLimit, "metal library", &mCache); removes old entries to keep the cache under its size limit. kMaxCachedLibraries is the maximum number of entries, kGCLimit is a threshold for garbage collection, and "metal library" is a label used in logging.
  • iter = mCache.Put(std::move(key), LibraryCacheEntry()); inserts a fresh, empty entry for this key. std::move transfers the key rather than copying it.
  • return iter->second; is the second return path, and it also hands back a reference to a node owned by the container.

Both return paths hand back iter->second, a reference to a node owned by the container. The std::lock_guard on mCacheLock is destroyed as the function returns, so the lifetime guarantee on entry ends at that point. The trim call inside the same critical section shows that the container does evict nodes: angle::TrimCache is invoked with kMaxCachedLibraries and kGCLimit before a new entry is inserted. So the cache is not a fixed shelf; it is a shelf that gets cleared to make room, and the clearing happens inside the same function that hands out the pointer.

Step 3: a second worker evicts the referenced node

With the cache lock released, a second worker can immediately re-enter getCacheEntry, reach angle::TrimCache, and erase the least-recently-used node that the first thread still references. The first thread then proceeds to std::lock_guard<std::mutex> entryLockGuard(entry.lock) on memory that has been freed. A worker here means another thread doing shader work.

A everyday comparison: you ask a librarian for a book, she points at a shelf and says "third from the left", then walks away. Before you reach the shelf, another librarian clears space and throws that book away. You reach the shelf and pick up a book that is no longer there. In code, "picking up a book that is no longer there" means reading memory that has been freed, which is the use-after-free.

The report notes that the destructor for LibraryCacheEntry does lock entry.lock, but that this only serialises destruction with in-flight compilation if the caller already has a valid pointer to the same object. A destructor is the code that runs when an object is destroyed. Serialises means makes them happen one after the other rather than at the same time. It therefore does not prevent a caller from dereferencing after the container node itself has been freed, which is the use-after-free. Dereferencing means following a pointer to read or write the memory it points at.

Step 4: reproduce with a local page

The report's reproduction uses a page named poc.html, served locally. A local web server is a small program on your own computer that hands out files over a network address, so the browser can load them as if they were on the internet. poc stands for proof of concept: a minimal example that shows the bug is real.

Bash
python3 -m http.server 8080

Line by line:

  • python3 runs the Python 3 interpreter, a programming language that ships with macOS.
  • -m http.server tells Python to run its built-in web server module.
  • 8080 is the port number, the numbered door on your computer that the server listens on. Ports let one computer run many network services without them colliding.

You run this in the folder that contains poc.html. The server then serves that folder at http://[redacted]:8080/. [redacted] is the loopback address, meaning "this computer".

Chromium is then run with the same URL passed four times:

Line by line:

  • ./Chromium.app/Contents/MacOS/Chromium is the path to the browser program inside the downloaded app bundle. On macOS, an application is a folder ending in .app, and the actual program lives inside it.
  • The four identical http://[redacted]:8080/poc.html arguments are four addresses for the browser to open. What the four identical arguments are intended to achieve is not explained in the report either; the only stated outcome is the ASan report of the use-after-free.

The report states that you would observe the UAF shown in asan.txt.

Root cause

The mistake is a lifetime mismatch between a container and the references it hands out. Lifetime here means how long a piece of memory is guaranteed to stay valid. getCacheEntry returns a reference to a node inside HashingMRUCache and releases mCacheLock on return. The caller in getOrCompileShaderLibrary treats that reference as stable and only then takes the per-entry mutex. Because the cache evicts, via angle::TrimCache, a concurrent caller can free the node in the window between the return and the lock acquisition. The window is the short stretch of time between two lines of code.

The existing defences do not cover this window. The per-entry entry.lock serialises compilation and, in the destructor, serialises destruction with in-flight compilation, but only for callers that already hold a valid pointer to the same object. It cannot protect a caller that has not yet locked and whose pointer is already dangling. Dangling means the pointer still exists but the memory it points at has been freed. The cache lock protects the lookup and insertion, but not the use of the returned reference afterwards. The report attributes the introduction of the issue to the commit that introduced the MRUCache.

Impact

The report describes a use-after-free in the GPU process during Metal library compilation, reachable through concurrent shader-link tasks. The platform classifies the issue as high severity. The report does not spell out a full exploit chain, does not claim code execution, and does not state which renderer or site conditions are required beyond the concurrency and the affected build. The practical effect it demonstrates is a use-after-free in the GPU process, evidenced by the ASan report. Memory corruption means memory being read or written in a way the program did not intend, which in the worst case can be turned into running an attacker's code, but the report does not claim that here.

Fix

The report states that the minimal fix is to store cache entries with a ref-counted pointer. Ref-counted means the entry keeps a count of how many parts of the program are using it, and it is only freed when that count reaches zero. That keeps the entry alive for as long as a caller holds a reference, independently of eviction from the MRU container.

Variants to test

These are ideas for finding similar bugs elsewhere. Each one is a pattern to search for, not a confirmed bug.

  1. Other caches that return references into an evicting container. Look for functions that return T & or T * from inside a lock and whose container has a trim or eviction path. A positive result is a caller that uses the reference after the lock is released while another thread can evict.
  2. Per-entry locks taken after lookup. Search for patterns where a lookup returns an object and a per-object mutex is acquired afterwards. A positive result is a window in which the object can be destroyed before the mutex is taken.
  3. Destructors that lock the object's own mutex. As the report notes, this only helps callers that already hold a valid pointer. A positive result is a path where the container node is freed while a caller still holds a reference to it.
  4. Shader and pipeline caches on other graphics backends. The same display-global caching pattern may exist for other APIs. A positive result is a trim path reachable concurrently with compilation, producing a sanitizer report under parallel shader-link load.
  5. Stress the reproduction with more concurrent pages or workers. The report passes the same URL four times; varying the number of concurrent loads and the shader workload is a reasonable way to widen the race window. A race window is the short period in which two threads can interfere. A positive result is a reproducible ASan use-after-free in the cache code.

Glossary

  • AddressSanitizer (ASan): a tool built into some browser builds that watches memory and prints a detailed report when a program reads or writes memory it should not.
  • ANGLE: the translation layer Chrome uses to run OpenGL ES and WebGL content on top of a platform's own graphics system.
  • arm64: the processor family used by recent Apple computers.
  • Bisection: narrowing down which code change introduced a bug by testing points in history.
  • Cache: a store of results already worked out, kept so the work does not have to be repeated.
  • Commit: a recorded change to a code repository.
  • Concurrent: happening at the same time.
  • Critical section: a stretch of code that must not be run by two threads at once.
  • Dangling pointer: a pointer that still exists but points at memory that has been freed.
  • Dereference: follow a pointer to read or write the memory it points at.
  • Destructor: the code that runs when an object is destroyed.
  • Display-global: shared across the whole display rather than per page or per tab.
  • Evicting: throwing old entries away when a cache is full.
  • Function: a named block of code that does one job.
  • GPU process: the separate part of Chrome that talks to the graphics hardware.
  • HashingMRUCache: a container that looks entries up by a computed key and evicts the least recently used ones.
  • Iterator: a handle that points at a position inside a container.
  • LibraryCache: the ANGLE component that stores compiled Metal shader libraries.
  • Lifetime: how long a piece of memory is guaranteed to stay valid.
  • Lock guard: a helper that takes a lock when created and releases it automatically when it goes out of scope.
  • Loopback address: the address [redacted], meaning "this computer".
  • LRU (least recently used): an eviction rule that throws away the thing that has gone longest without being asked for.
  • Memory corruption: memory being read or written in a way the program did not intend.
  • Metal: Apple's graphics system on macOS.
  • MSL (Metal Shading Language): the text form of a Metal shader.
  • Mutex: a lock that only one thread can hold at a time, used to stop two threads from changing the same data at once.
  • OpenGL ES: a graphics programming interface used on mobile and embedded devices.
  • Pointer: a value that says where in memory something lives.
  • Port: a numbered door on a computer that a network service listens on.
  • Proof of concept (poc): a minimal example that shows a bug is real.
  • Race window: the short period in which two threads can interfere with each other.
  • Reference: a pointer to where something lives, rather than a copy of it.
  • Ref-counted: keeping a count of how many parts of a program are using an object, and freeing it only when the count reaches zero.
  • Serialise: make two things happen one after the other rather than at the same time.
  • Shader: a small program that tells the graphics chip how to colour pixels or move points around.
  • Shader-link task: a job that prepares shaders for use.
  • Thread: one line of execution inside a program; a program with several threads can do several things at once.
  • TrimCache: the routine that removes old entries from a cache to make room.
  • Use-after-free: reading or writing memory that has already been freed.
  • WebGL: the browser feature that lets web pages draw 3D graphics.
  • Worker: another thread doing shader work.

More by Syn4pse

View all

1 more disclosed report, best first.

More from Google Chrome

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.