CVE-2022-29582 - An io_uring vulnerability
A use-after-free in the Linux kernel's io_uring subsystem arises when an IORING_OP_TIMEOUT request is linked with its own IORING_OP_LINK_TIMEOUT and both complete concurrently, leaving a dangling reference to the freed link timeout. The authors exploited this to execute their own code in kernel mode and gain root in the root namespace inside a hardened nsjail environment.
This post covers an interesting vulnerability we (Jayden and David) found in the iouring subsystem of the Linux kernel.
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 in io_uring's linked timeout handling: when a timeout request's refcount is decremented before the link timeout's timer callback checks it, the link timeout is not removed from the link list and can be freed while a reference to it remains.
Impact
An attacker could exploit the use-after-free to run their own code in kernel mode and obtain root privileges in the root namespace, without needing unprivileged user namespaces.
What the attacker needed
Local access to a vulnerable kernel; ability to use io_uring; no unprivileged user namespaces needed
How it was found
- Submit an IORING_OP_TIMEOUT request with the IOSQE_IO_LINK flag set, linked to its own IORING_OP_LINK_TIMEOUT.
- Cause the timeout to complete through flushing by having another request post a completion event, decrementing its refcount.
- Race this against the link timeout's timer firing so the callback sees a zero refcount and skips removing the link.
- Let the deferred destruction workers run out of order so the link timeout is freed before the timeout request.
- Reallocate the freed memory with controlled objects to leak and overwrite kernel data.
- Use the resulting control to execute code in kernel mode and gain root.
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 has a feature called io_uring that lets programs queue up input/output work to be done in the background. A timing mistake meant that, in a rare race between two timeout operations, the kernel kept a pointer to memory it had already freed. The researchers turned that stale pointer into a way to run their own code with the highest privileges.
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.