The quantum state of Linux kernel garbage collection CVE-2021-0920 (Part I)
A race condition in the Linux kernel's SCM_RIGHTS garbage collection lets a local attacker obtain a use-after-free on a socket buffer, which in the wild was chained with browser exploits to root Samsung devices. The flaw was known since 2016 but only patched in 2021.
Published on googleprojectzero.blogspot.com
This is part one of a two-part guest blog post, where first we'll look at the root cause of the CVE-2021-0920 vulnerability. In the second post, we'll dive into the in-the-wild 0-day exploitation of the vulnerability and post-compromise modules.
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 MSG_PEEK receive path increments file reference counts without synchronising with an in-progress garbage collection, so the collector's inflight bookkeeping becomes inconsistent and it purges a live socket buffer.
Impact
Winning the race gives a use-after-free that the in-the-wild sample turned into arbitrary read/write and, combined with browser exploits, root on Samsung devices; other Android devices were also vulnerable but no samples were found against them.
What the attacker needed
Local code execution on the device; ability to send and receive Unix socket messages; win a timing race
The fix
The issue was fixed in the November 2021 Android Security Bulletin and Samsung's December 2021 update.
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.
When one program passes an open file to another over a Unix socket, the kernel keeps a count of who still holds it so it can clean up safely. A race means two kernel activities run at the same time and interfere, and a use-after-free means memory is freed while something still points at it, so an attacker can reuse it. Here the cleanup routine could wrongly free a socket buffer that was still in use.
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.