
PoC skeleton for CVE-2021-28664, a Mali kbase GPU driver use-after-free, demonstrating a kernel arbitrary physical memory read/write primitive on ARM64 Android.
Mali kbase GPU driver UAF (CVE-2021-28664) → kernel arbitrary physical memory read/write primitive PoC skeleton. Targets generic ARM64 Android platforms, independent of any specific vendor or device model.
Research scope stops at "kernel arbitrary physical memory read/write primitive": how to turn a GPU driver use-after-free into a stable, controllable, safely-failing kernel memory read/write capability.
This repository does not provide any attack. It contains no finished exploit, no directly runnable code, no device-specific offsets/serial numbers/firmware; any use of any content for attack purposes is prohibited (see below).
| Link | Prerequisite |
|---|---|
| Vulnerability itself | Mali kbase driver version falls within the CVE-2021-28664 affected range (r-series before the upstream fix); independent of kernel version, depends only on the driver |
| GPU resources | /dev/mali reachable by the target application; MEM_ALLOC supports SAME_VA large buffers; MEM_ALIAS behavior matches the vulnerability description |
| Pipe reuse | Linux ≥ 4.5 (pipe_buf_operations introduced), verified to hold on 4.9 ~ 4.14; F_SETPIPE_SZ can shrink the pipe to a single page |
| KASLR leak | Kernel has CONFIG_RANDOMIZE_BASE enabled (arm64 ≥ 4.6); anon_pipe_buf_ops exists in the public symbol table |
| Physical address model | arm64 + vmemmap layout; sizeof(struct page), page table format must be measured empirically, cannot be assumed |
pipe_buffer structure/copy_page_to_iter validation (from 5.x onward
must be re-verified against the corresponding source; the chain structure can be referenced but details are not universal);/dev/mali access (SELinux/vendor policy restrictions).TODO(DEVICE); adaptation is the user's own
reverse-engineering work, and the repository does not do it for you.CVE-2021-28664: The MEM_ALIAS path of the Mali kbase driver lacks a check on GPU_WR permission,
allowing an attacker to alias already-freed GPU memory pages into their own GPU address space,
forming "persistent GPU-side visibility/writability of freed physical pages" — a use-after-free
spanning the GPU/kernel boundary.
The exploitation value is not in the GPU memory itself, but in the following:
WRITE_VALUE jobs to perform targeted overwrites on alias-visible pages.victim GPU buffer + MMU page table dump → build physical address map
→ trigger buffer release to create pressure → spray pipes (F_SETPIPE_SZ shrink)
→ pipe_buffer array lands in the freed region (cross-cache UAF reuse)
→ alias view scans ops pointer → leak anon_pipe_buf_ops → KASLR slide
→ GPU overwrites pipe_buffer's page / offset / len
→ via legitimate pipe read/write paths
⇒ arbitrary physical page read (forged page pointer)
⇒ arbitrary physical page write (pipe merge write path)
⇒ use known-content pages as a self-verifying oracle to ensure reads/writes don't land in holes/unmapped regions
That's as far as it goes.
page_to_virt implementation,
no-map reserved regions simply don't exist in the linear mapping (reading them causes a panic).docs/
01-exploit-chain.md From UAF to read/write primitive: principles and implementation points of each stage
02-physical-address-model.md Physical address model, safety gates, m ambiguity, known pitfalls
exploit/
cve-2021-28664-poc.c PoC template: complete flow skeleton of the read/write primitive (no device values)
scripts/
README.md Design description of experiment automation tools (loops/verification/recovery)
exploit/cve-2021-28664-poc.c is the PoC skeleton template for the read/write primitive:
TODO(DEVICE), with no directly usable values;It is used to understand how the entire chain is organized, and cannot be directly compiled into a tool effective against any device.
fs/pipe.c / include/linux/pipe_fs_i.h (public source)Documentation/arch/arm64/memory.rst (public documentation)