Skip to content
Memory corruption Write-up Advanced

Corrupting memory without memory corruption

An integer overflow in the Arm Mali GPU kernel driver's memory alias code let a malicious app create an alias region smaller than its backing pages, so GPU page table entries were written past the region's end and overwrote a neighbouring region's mapping. This allowed the attacker to keep accessing a freed page and, by steering it into the global memory pool, reuse it as a GPU page table directory to map arbitrary physical pages and gain kernel code execution and root.

Man Yue Mo Follow

Published on github.blog

Man Yue Mo·@m-y-mo

Man Yue Mo, on github.blog

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the size calculation for an alias region multiplied the number of entries by the stride without checking for integer overflow, so the region was sized smaller than the pages later inserted into the GPU page table.

Impact

The bug could be exploited to map arbitrary physical pages with read and write access, giving arbitrary kernel code execution and root on a Pixel 6.

What the attacker needed

Malicious or compromised app; Arm Mali GPU device; ability to call GPU driver ioctls

The fix

The vulnerability was fixed in the June 2022 Pixel security update.

How it was found

  1. Allocate and map three three-page regions to the GPU.
  2. Create and map an alias region with a huge stride and two entries so the size overflows to two pages.
  3. Observe that the alias mapping overwrites the start of the third region with a page owned by the first region.
  4. Unmap both regions so the shared page is freed and recycled to the memory pool.
  5. Fill the per-context pool so the freed page spills into the global pool used for page table directories.
  6. Access the stale GPU address to modify the reused page table directory and map arbitrary physical pages.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A phone's graphics chip (GPU) needs the operating system kernel to hand it chunks of memory, and the kernel driver keeps a map of which memory belongs where. A mistake in the arithmetic that sizes one of these memory-sharing requests meant the driver wrote map entries beyond the area it had reserved, so it silently changed a neighbouring area's map. Because the map is what the GPU trusts, an attacker could then point the GPU at memory it should never see, including kernel memory.

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.

More by Man Yue Mo

View all

3 more disclosed reports, best first.

More from Google

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.