Race condition in 9p File System
A race condition in the Linux kernel's 9p file system allowed a use-after-free: one thread could look up a fid through a dentry while another thread unlinked it, because the dentry's d_fsdata was not accessed under d_lock. An attacker able to trigger the race could cause a kernel panic.
r00tkitsmm.github.io
Published on r00tkitsmm.github.io
During our recent fuzzing efforts on various subsystems of the Linux kernel, we encountered a kernel panic. Interestingly, the kernel panic that exposed the vulnerability was not directly related to the input seed generated by our fuzzer.
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
The dentry's d_fsdata fid list was accessed without holding d_lock, so an explicit release in v9fs_remove could free fids while another thread was still looking them up.
Impact
Triggering the race caused a kernel panic, a denial of service on the affected system.
What the attacker needed
Ability to mount or use a 9p file system; concurrent file operations to win the race
The fix
The fix moves the hlist out of the dentry under lock and unreferences its fids once they are no longer accessible.
How it was found
- Build the kernel and run it via virtio.
- Inside the shell, run the provided proof-of-concept code.
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 race condition is when two parts of a program act at the same time and interfere with each other. Here one part of the kernel was reading a file-system record while another part was deleting it, so the reader ended up using memory that had already been freed. That kind of mistake, called use-after-free, can crash the whole machine.
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.