GHSL-2023-005: GPU memory accessed after it's freed
A missing patch in the Pixel 6 branch of the Arm Mali GPU driver allows a use-after-free in JIT memory, where GPU memory can be accessed after it is freed. An attacker could exploit this to gain root and execute arbitrary kernel code from an untrusted app.
Pixel 6 Device fingerprint: google/oriole/oriole:13/TQ1A.230105.002/9325679:user/release-keys Patch level: January 2023 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
Likely a missing check in the function kbase_mem_commit that prevents shrinking of regions with the KBASE_REG_NO_USER_FREE flag, leading to inconsistent region sizes and unmapped pages that cause mappings to be skipped during teardown.
What the attacker needed
Untrusted app on Pixel 6 or Pixel 6 Pro; Android 13 with January 2023 patch level
The fix
The missing patch from the r40 version of the Arm Mali driver, which adds a check for KBASE_REG_NO_USER_FREE in kbase_mem_commit, should be applied; the issue was fixed silently in the March update of Pixel 6.
How it was found
- Allocate JIT memory using kbase_jit_allocate, which finds a region in the jit_pool_head free list.
- Enter kbase_jit_grow, which releases the kctx->reg_lock.
- While the lock is released, another thread calls kbase_mem_commit to shrink the region to size zero.
- New pages are allocated at the start of the region, but GPU mappings are created in the middle, leaving the start unmapped.
- Free the corrupted region, causing kbase_mmu_teardown_pages to skip unmapping some pages due to an invalid page table entry.
- Access the freed memory via the GPU to gain root.
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.
This is a bug in the software that controls the graphics chip (GPU) on some Android phones. When the phone frees up memory, a mistake means the GPU can still read that memory after it has been freed, which can let an attacker take control of the phone.
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.