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

GHSL-2022-054: Use-after-free (UAF) in the Arm Mali Kernel driver - CVE-2022-38181

A use-after-free in the Arm Mali GPU kernel driver allowed a local attacker to free a memory region while a reference to it remained, potentially leading to kernel code execution and rooting of a Pixel 6.

m-y-mo Follow

Originally disclosed on GitHub Security Lab

Tested on Pixel 6 Device fingerprint: google/oriole/oriole:12/SQ3A.220705.003/8671607:user/release-keys

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 driver did not remove the reference in jit_alloc when the region was freed via the shrinker, leaving a dangling pointer.

Impact

The use-after-free could allow an attacker to execute arbitrary kernel code and root a Pixel 6, though the Android security team initially could not disable SELinux with the exploit.

What the attacker needed

Local access to a vulnerable device; ability to run a malicious app

The fix

The issue was fixed in Arm driver version r40p0 and later appeared fixed in Pixel phones in the January update.

How it was found

  1. Create a kbase_va_region using kbase_jit_allocate and move it to the evict_list by adding the KBASE_REG_DONT_NEED flag via the KBASE_IOCTL_MEM_FLAGS_CHANGE ioctl.
  2. Trigger a direct reclaim to free the region, leaving a dangling pointer in jit_alloc.
  3. Use kbase_jit_free to access the freed pointer and trigger the use-after-free.

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.

A use-after-free happens when a program frees a piece of memory but still keeps a pointer to it. If an attacker can make the program use that stale pointer, they can control what happens next, often leading to running their own code with high privileges. Here, a graphics driver kept a reference to a memory region after freeing it, so a malicious app could exploit this to take over the phone's kernel.

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.