CVE-2026-99429: ocfs2: pin refcount trees before dropping the lookup lock
In the Linux kernel, the following vulnerability has been resolved:
ocfs2: pin refcount trees before dropping the lookup lock
A refcount tree returned to ocfs2lockrefcounttree() must stay alive until that caller releases its operation reference. However, ocfs2getrefcounttree() returns the cached pointer after dropping osblock, and the caller only takes its kref afterwards. The registry reference does not protect this gap from concurrent removal.
This can happen when another node frees a refcount root and reuses its block with a different generation while this mount retains the old cached tree. Two local operations on different inodes sharing the new root, such as data CoW and an external xattr update, can then look up the same stale tree. Their inode locks are independent, and both the REFCOUNT DLM lock and rfsem are acquired after the first operation reference.
The following ordering is possible, with no other operation references:
Data CoW Xattr update -------- ------------ Look up the old tree under osblock, then drop osblock Look up the same tree and take a kref Acquire the tree locks and read the new on-disk generation Erase the old tree under osblock Unlock and drop the operation kref Drop the registry kref, freeing tree Take a kref through the freed tree pointer
The final krefget() accesses freed rfgetcnt storage, and subsequent accesses in ocfs2lockrefcounttree() also use the freed allocation.
Take the operation reference in ocfs2getrefcounttree() before releasing osblock, including when an insertion loses to another lookup. Removal must acquire the same lock, so it cannot drop the registry reference before the lookup has pinned the tree. Keep the existing unlock and error path puts. The two callers that already hold the refcount tree lock keep their borrowed lookup behavior and do not acquire an extra reference.
KASAN report as below:
BUG: KASAN: slab-use-after-free in ocfs2lockrefcounttree+0x94a/0x9b0 Read of size 4 at addr ffff888117212820 by task python3/497
[Kernel and hardware identification omitted.]
Call Trace: <TASK> dumpstacklvl+0x93/0xd0 printreport+0xce/0x630 ? ocfs2lockrefcounttree+0x94a/0x9b0 ? srsoaliasreturnthunk+0x5/0xfbef5 ? virtaddrvalid+0x20e/0x420 ? ocfs2lockrefcounttree+0x94a/0x9b0 kasanreport+0xe0/0x110 ? ocfs2lockrefcounttree+0x94a/0x9b0 ocfs2lockrefcounttree+0x94a/0x9b0 ? pfxocfs2lockrefcounttree+0x10/0x10 ? srsoaliasreturnthunk+0x5/0xfbef5 ? ocfs2refcountcow+0x3b6/0xd90 ? srsoaliasreturnthunk+0x5/0xfbef5 ? kmalloccachenoprof+0x28d/0x610 ? ocfs2refcountcow+0x3b6/0xd90 ocfs2refcountcow+0x410/0xd90 ? pfxocfs2refcountcow+0x10/0x10 ? pfxmightresched+0x10/0x10 ? downwrite+0x11a/0x1f0 ? pfxdownwrite+0x10/0x10 ? ocfs2inodeunlock+0x1a9/0x260 ? pfxocfs2inodeunlock+0x10/0x10 ? ocfs2filewriteiter+0x1413/0x1d30 ocfs2filewriteiter+0x157b/0x1d30 ? pfxocfs2filewriteiter+0x10/0x10 ? lockacquire+0x190/0x300 ? x64syspwrite64+0x1b7/0x220 ? pfxmightresched+0x10/0x10 ? srsoaliasreturnthunk+0x5/0xfbef5 ? securityfilepermission+0x26/0x80 ? srsoaliasreturnthunk+0x5/0xfbef5 ? lockisheldtype+0x8f/0x100 vfswrite+0x639/0x1010 ? pfxocfs2filewriteiter+0x10/0x10 ? lockvmaunderrcu+0x154/0x4a0 ? pfxvfswrite+0x10/0x10 ? lockrelease+0x121/0x290 ? srsoaliasreturnthunk+0x5/0xfbef5 x64syspwrite64+0x1b7/0x220 ? pfxx64syspwrite64+0x10/0x10 ? irqentryexit+0xbe/0x820 ---truncated---
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.117 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.61 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.2