The curious case of CVE-2020-14381
A use-after-free in the Linux kernel's futex code allowed an attacker to free a mountpoint while a futex still referenced its inode, leading to a dangling super_block pointer. An attacker with local access could exploit this to execute arbitrary code in the kernel and escalate privileges.
blog.frizn.fr
Published on blog.frizn.fr
Kernel Linux > The curious case of CVE-2020-14381
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
Impact
An attacker with local access could exploit this use-after-free to execute arbitrary code in the kernel and escalate privileges, though the exploit requires bypassing SMEP and SMAP or having an infoleak.
What the attacker needed
Local access to the system; unprivileged user namespaces enabled; ability to unmount a mountpoint; bypass SMEP or have a KASLR leak
The fix
The bug was fixed by ensuring the futex key holds a reference to the mountpoint, preventing the super_block from being freed while the inode is still in use.
How it was found
- Create a file-backed mapping and use it as the address for a futex.
- Unmount the mountpoint, which frees the super_block but not the inode.
- Wait for the RCU grace period so the super_block memory is actually freed.
- Spray heap allocations to overwrite the freed super_block with controlled data.
- Point the super_operations pointer to a controlled buffer and set drop_inode to a stack pivot gadget.
- Trigger the futex destruction to call the corrupted function pointer and execute a ROP chain.
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 futex system call lets programs wait for a value to change. When the memory it watches belongs to a file on a mounted disk, the kernel kept a reference to the file's inode but not to the mountpoint. If the mountpoint was removed, the inode could later be used after its related structures were freed, which is a use-after-free bug. An attacker could then take control of the freed memory and run their own code in the kernel.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.