GHSL-2022-053: Use-after-free in alias memory of the Arm Mali gpu kernel driver - CVE-2022-20186
The Arm Mali GPU kernel driver fails to validate the multiplication of user-supplied parameters when creating an alias memory region, leading to an integer overflow. This allows a freed page to remain referenced in the GPU page table, enabling a process to access memory belonging to another process and potentially achieve arbitrary kernel code execution.
Improper validation of input data can lead to free’d memory being accessible from the GPU, which can lead to arbitrary memory access.
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 multiplication of user-controlled 'nents' and 'stride' can overflow a 64-bit integer, bypassing the size check and resulting in an alias region with too few pages.
Impact
This vulnerability can be exploited to achieve arbitrary kernel code execution from the app domain.
What the attacker needed
Ability to use GPU ioctl calls; Android device with vulnerable Mali driver
The fix
The issue was fixed by the Android security team, as confirmed in the timeline.
How it was found
- Allocate two GPU memory regions (A and B) of 3 pages each and map them.
- Allocate a third GPU memory region (C) of 3 pages and map it.
- Create an alias region with stride set to 2^63+1 and nents set to 2, aliasing regions A and B.
- The alias region overlaps with region C, overwriting its page table entry.
- Unmap region A and the alias region, freeing a page still referenced by region C's page table entry.
- Access region C via the GPU to read or write the freed page, which may be reallocated to another process.
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.
The GPU driver lets apps create 'alias' memory regions that point to other memory. When calculating how many pages the alias covers, it multiplies two numbers without checking for overflow. This can cause a page to be freed while still referenced, letting one app read or write another app's 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.