Skip to content
Memory corruption Advisory Advanced CVE-2022-46395

GHSL-2022-127: Free Memory Access in Arm Mali - CVE-2022-46395

The Arm Mali GPU driver allows user-space memory imported into a GPU memory region to be freed while still mapped, because a GPU soft job can race with an unmap ioctl. An attacker could read and write freed memory, potentially gaining kernel code execution.

m-y-mo Follow

Originally disclosed on GitHub Security Lab

x8664 VM built with Mali driver version r40p0 and Pixel 6 with Patch level: November 2022 Android 13.

m-y-mo, on GitHub Security Lab

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 report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The unmap ioctl is not protected by the same lock as the GPU soft job that maps and writes to the user-supplied address, so the backing page can be freed between the map and the write.

What the attacker needed

Ability to submit GPU jobs; ability to call Mali ioctls; race timing

The fix

The issue was fixed in Mali driver version r42 and in the May 2023 Android security bulletin.

How it was found

  1. Import a user buffer without the share-both flag so pages are not pinned at creation.
  2. Submit a GPU soft job with external resources to pin the pages.
  3. Use the sticky resource map ioctl to increase the mapping usage count.
  4. Let the soft job complete, which decreases the count instead of dropping references.
  5. Use the sticky resource unmap ioctl to free the backing pages.
  6. Race a GPU soft job that writes to the freed address with the unmap ioctl.

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 report has not been written yet. The Original tab links to the source.

When a program gives memory to the GPU, the driver normally keeps that memory alive until the GPU is done. Here, a timing trick lets the memory be freed while the GPU still has a pointer to it, so the GPU writes into memory that may now belong to something else. This is called a use-after-free bug and can let an attacker take over the system.

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 m-y-mo

View all

64 more disclosed reports, best first.

More from GitHub Security Lab

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.