Deep Dive into RCU Race Condition: Analysis of TCP-AO UAF (CVE-2024–27394)
The TCP-AO connection setup code iterated a key list with an RCU list macro while not inside an RCU read-side critical section, so a key could be freed by the RCU callback during iteration. An attacker could then read a freed key, causing a use-after-free in the kernel.
blog.theori.io
Published on blog.theori.io
Vulnerability Research
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 list iteration in tcp_ao_connect_init() uses hlist_for_each_entry_rcu without holding rcu_read_lock(), so call_rcu() can free a key before the loop reaches its next node.
Impact
A local attacker could trigger a use-after-free in the kernel, which may lead to memory corruption or a crash; the text does not demonstrate privilege escalation.
What the attacker needed
Local access to create TCP sockets; ability to call setsockopt and connect; timing the Reschedule IPI correctly
The fix
The code should hold an RCU read-side critical section around the list iteration so the key cannot be freed mid-walk; the text says the vulnerability was patched.
How it was found
- Allocate ao_info and at least two keys on a TCP socket with the TCP_AO_ADD_KEY setsockopt command.
- Pin the process to a CPU and call connect(), which reaches tcp_ao_connect_init() and runs call_rcu().
- Have another process call sched_setaffinity to send a Reschedule IPI to that CPU, preempting the connect() right after call_rcu() returns.
- Let the RCU grace period end so the registered callback frees the key.
- Resume the preempted process, which walks the list and reads the freed key, causing a 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 write-up has not been written yet. The Original tab links to the source.
The kernel keeps a list of authentication keys for a network connection. A cleanup routine can delete and free a key while another part of the kernel is still walking the list, so it later reads memory that has already been released. Reading freed memory can crash the machine or, in skilled hands, be turned into code execution.
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.