Skip to content
Race condition Write-up Advanced

Exploiting NVMAP to Escape the Chrome Sandbox – CVE-2014-5332

A race condition in the NVMAP driver allows a user to free a handle while it is still referenced, leading to a use-after-free. An attacker can exploit this to clear a single bit in kernel memory and modify the setuid syscall to gain root privileges.

googleprojectzero.blogspot.com

Published on googleprojectzero.blogspot.com

[This guest post continues Project Zero’s practice of promoting excellence in security research on the Project Zero blog]

The author, on googleprojectzero.blogspot.com

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 write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a race condition in the NVMAP_IOC_CREATE ioctl where a file descriptor can be duplicated before sys_close, leaving a handle with only one reference that can be freed while still in use.

Impact

An attacker could escalate privileges to root on affected Android devices, but the exploit requires winning multiple races and may take many attempts.

What the attacker needed

Access to /dev/nvmap; ability to run code in Chrome renderer; win multiple race conditions

The fix

The vulnerability was fixed by Nvidia in an upstream patch.

How it was found

  1. Trigger the race in NVMAP_IOC_CREATE by providing a read-only userspace address to force copy_to_user to fail, and dup the returned fd before sys_close.
  2. Use the dup'ed fd to free the handle asynchronously by calling close().
  3. Call the NVMAP_IOC_RESERVE ioctl with a large number of handles, where the first handle is the dup'ed fd, to create a time window.
  4. During the loop in the ioctl, free the handle from another thread, creating a stale pointer.
  5. Heap groom by allocating a seccomp-bpf filter to reallocate over the freed handle and control the pgalloc.pages pointer.
  6. Use the bit-clear primitive to modify the setuid syscall's uxtb instruction to sub, making the capability check return non-zero, then call setuid(0).

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 write-up has not been written yet. The Original tab links to the source.

The NVMAP driver manages graphics memory. A flaw lets a program free a memory object while the kernel still uses it, so the attacker can replace it with controlled data. By carefully clearing one bit in the kernel's code, the attacker can make a permission check always pass and become root.

What is Race condition?

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.