Skip to content
DoS Write-up Advanced

Exploiting null-dereferences in the Linux kernel

A null-dereference in the Linux kernel's smaps_rollup handling causes an oops that leaks an mm_users reference count. By repeatedly triggering the oops, an attacker can overflow the 32-bit refcount to zero and then cause a use-after-free, potentially leading to memory corruption.

googleprojectzero.blogspot.com

Published on googleprojectzero.blogspot.com

For a fair amount of time, null-deref bugs were a highly exploitable kernel bug class. Back when the kernel was able to access userland memory without restriction, and userland programs were still able to map the zero page, there were many easy techniques for exploiting null-deref bugs.

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 the kernel's oops recovery path fails to release reference counts and locks held at the time of the null-dereference, and the mm_users refcount uses an overflow-unsafe atomic_t.

Impact

An attacker could overflow the mm_users refcount to zero and then trigger a use-after-free, potentially leading to memory corruption; however, the exploit requires many hours to days of triggering oopses, and the author did not complete a full proof-of-concept.

What the attacker needed

Ability to create processes with CLONE_VM; ability to use ptrace; ability to read /proc/[pid]/smaps_rollup; long execution time (days)

How it was found

  1. Process A forks process B.
  2. Process B issues PTRACE_TRACEME so it enters tracing stop on segfault.
  3. Process B clones with CLONE_VM | CLONE_PTRACE to create process C.
  4. Process B unmaps its entire virtual memory, also unmapping C's memory.
  5. Process A forks children D and E that open and read the smaps_rollup files of B and C, causing oopses and leaking mm_users refcounts.
  6. Process A repeats step 5 about 2^32 times to overflow the refcount.

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.

A null-dereference is when a program tries to use a pointer that points to nothing (null), causing a crash. In the Linux kernel, such a crash (an oops) doesn't stop the whole system but leaves some resources, like reference counts, permanently held. This report shows that by crashing the same operation many times, an attacker can make a reference count wrap around to zero, tricking the kernel into freeing memory that is still in use, which can lead to further exploitation.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.