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.
x8664 VM built with Mali driver version r40p0 and Pixel 6 with Patch level: November 2022 Android 13.
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
- Import a user buffer without the share-both flag so pages are not pinned at creation.
- Submit a GPU soft job with external resources to pin the pages.
- Use the sticky resource map ioctl to increase the mapping usage count.
- Let the soft job complete, which decreases the count instead of dropping references.
- Use the sticky resource unmap ioctl to free the backing pages.
- 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.