CVE-2026-31519

Source
https://cve.org/CVERecord?id=CVE-2026-31519
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2026-31519.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2026-31519
Downstream
Published
2026-04-22T13:54:34.860Z
Modified
2026-05-18T05:59:50.247303512Z
Summary
btrfs: set BTRFS_ROOT_ORPHAN_CLEANUP during subvol create
Details

In the Linux kernel, the following vulnerability has been resolved:

btrfs: set BTRFSROOTORPHAN_CLEANUP during subvol create

We have recently observed a number of subvolumes with broken dentries. ls-ing the parent dir looks like:

drwxrwxrwt 1 root root 16 Jan 23 16:49 . drwxr-xr-x 1 root root 24 Jan 23 16:48 .. d????????? ? ? ? ? ? broken_subvol

and similarly stat-ing the file fails.

In this state, deleting the subvol fails with ENOENT, but attempting to create a new file or subvol over it errors out with EEXIST and even aborts the fs. Which leaves us a bit stuck.

dmesg contains a single notable error message reading: "could not do orphan cleanup -2"

2 is ENOENT and the error comes from the failure handling path of btrfsorphancleanup(), with the stack leading back up to btrfs_lookup().

btrfslookup btrfslookupdentry btrfsorphan_cleanup // prints that message and returns -ENOENT

After some detailed inspection of the internal state, it became clear that: - there are no orphan items for the subvol - the subvol is otherwise healthy looking, it is not half-deleted or anything, there is no drop progress, etc. - the subvol was created a while ago and does the meaningful first btrfsorphancleanup() call that sets BTRFSROOTORPHANCLEANUP much later. - after btrfsorphancleanup() fails, btrfslookupdentry() returns -ENOENT, which results in a negative dentry for the subvolume via dsplice_alias(NULL, dentry), leading to the observed behavior. The bug can be mitigated by dropping the dentry cache, at which point we can successfully delete the subvolume if we want.

i.e., btrfslookup() btrfslookupdentry() if (!sbrdonly(inode->vfsinode)->vfsinode) btrfsorphancleanup(subroot) testandsetbit(BTRFSROOTORPHANCLEANUP) btrfssearchslot() // finds orphan item for inode N ... prints "could not do orphan cleanup -2" if (inode == ERRPTR(-ENOENT)) inode = NULL; return dsplicealias(NULL, dentry) // NEGATIVE DENTRY for valid subvolume

btrfsorphancleanup() does testandsetbit(BTRFSROOTORPHANCLEANUP) on the root when it runs, so it cannot run more than once on a given root, so something else must run concurrently. However, the obvious routes to deleting an orphan when nlinks goes to 0 should not be able to run without first doing a lookup into the subvolume, which should run btrfsorphancleanup() and set the bit.

The final important observation is that createsubvol() calls dinstantiatenew() but does not set BTRFSROOTORPHANCLEANUP, so if the dentry cache gets dropped, the next lookup into the subvolume will make a real call into btrfsorphancleanup() for the first time. This opens up the possibility of concurrently deleting the inode/orphan items but most typical evict() paths will be holding a reference on the parent dentry (child dentry holds parent->dlockref.count via dget in dalloc(), released in _dentrykill()) and prevent the parent from being removed from the dentry cache.

The one exception is delayed iputs. Ordered extent creation calls igrab() on the inode. If the file is unlinked and closed while those refs are held, iput() in __dentrykill() decrements icount but does not trigger eviction (icount > 0). The child dentry is freed and the subvol dentry's dlockref.count drops to 0, making it evictable while the inode is still alive.

Since there are two races (the race between writeback and unlink and the race between lookup and delayed iputs), and there are too many moving parts, the following three diagrams show the complete picture. (Only the second and third are races)

Phase 1: Create Subvol in dentry cache without BTRFSROOTORPHAN_CLEANUP set

btrfsmksubvol() lookupone_len() __lookupslow() dalloc_parallel() __dalloc() // dlockref.count = 1 createsubvol(dentry) // doesn't touch the bit.. dinstantiatenew(dentry, inode) // dentry in cache with dlockref.c ---truncated---

Database specific
{
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/31xxx/CVE-2026-31519.json",
    "cna_assigner": "Linux"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
c71bf099abddf3e0fdc27f251ba76fca1461d49a
Fixed
d43da8de0ed376abafbad8a245a1835e8f66cb0f
Fixed
c57276ced3c3207f42182dfa2f0d8e860357e111
Fixed
a41a9b8d19a98b45591528c6e54d31cc66271d1e
Fixed
2ec578e6452138ab76f6c9a9c18711fcd197649f
Fixed
696683f214495db3cdacab9a713efaaced8660f8
Fixed
5131fa077f9bb386a1b901bf5b247041f0ec8f80
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
0 Unknown introduced commit / All previous commits are affected
Last affected
c4ba0bd9db5e8fd2664be0fd4ec01335fe3268eb

Affected versions

v2.*
v2.6.12-rc2
v2.6.12-rc3
v2.6.12-rc4
v2.6.13
v2.6.13-rc1
v2.6.13-rc2
v2.6.13-rc3
v2.6.13-rc4
v2.6.13-rc5
v2.6.13-rc6
v2.6.13-rc7
v2.6.14-rc1
v2.6.14-rc2
v2.6.14-rc3
v2.6.15-rc1
v2.6.15-rc2
v2.6.15-rc4
v2.6.15-rc5
v2.6.15-rc7
v2.6.16
v2.6.16-rc1
v2.6.16-rc2
v2.6.16-rc3
v2.6.16-rc4
v2.6.16-rc5
v2.6.16-rc6
v2.6.17
v2.6.17-rc1
v2.6.17-rc2
v2.6.17-rc3
v2.6.17-rc4
v2.6.17-rc5
v2.6.17-rc6
v2.6.18
v2.6.18-rc1
v2.6.18-rc2
v2.6.18-rc3
v2.6.18-rc5
v2.6.18-rc6
v2.6.19-rc1
v2.6.19-rc2
v2.6.20-rc1
v2.6.20-rc2
v2.6.20-rc3
v2.6.20-rc4
v2.6.20-rc5
v2.6.20-rc6
v2.6.20-rc7
v2.6.21
v2.6.21-rc1
v2.6.21-rc2
v2.6.21-rc3
v2.6.21-rc4
v2.6.21-rc5
v2.6.21-rc6
v2.6.21-rc7
v2.6.22
v2.6.22-rc1
v2.6.22-rc2
v2.6.22-rc3
v2.6.22-rc4
v2.6.22-rc5
v2.6.22-rc6
v2.6.22-rc7
v2.6.23
v2.6.23-rc1
v2.6.23-rc2
v2.6.23-rc3
v2.6.23-rc4
v2.6.23-rc5
v2.6.23-rc6
v2.6.23-rc7
v2.6.23-rc8
v2.6.23-rc9
v2.6.24
v2.6.24-rc1
v2.6.24-rc2
v2.6.24-rc3
v2.6.24-rc4
v2.6.24-rc5
v2.6.24-rc6
v2.6.24-rc7
v2.6.24-rc8
v2.6.25
v2.6.25-rc1
v2.6.25-rc2
v2.6.25-rc3
v2.6.25-rc4
v2.6.25-rc5
v2.6.25-rc6
v2.6.25-rc7
v2.6.25-rc8
v2.6.25-rc9
v2.6.26
v2.6.26-rc1
v2.6.26-rc2
v2.6.26-rc3
v2.6.26-rc4
v2.6.26-rc5
v2.6.26-rc6
v2.6.26-rc7
v2.6.26-rc8
v2.6.26-rc9
v2.6.27
v2.6.27-rc1
v2.6.27-rc2
v2.6.27-rc3
v2.6.27-rc4
v2.6.27-rc5
v2.6.27-rc6
v2.6.27-rc7
v2.6.27-rc8
v2.6.27-rc9
v2.6.28
v2.6.28-rc1
v2.6.28-rc2
v2.6.28-rc3
v2.6.28-rc4
v2.6.28-rc5
v2.6.28-rc6
v2.6.28-rc7
v2.6.28-rc8
v2.6.28-rc9
v2.6.29
v2.6.29-rc1
v2.6.29-rc2
v2.6.29-rc3
v2.6.29-rc4
v2.6.29-rc5
v2.6.29-rc6
v2.6.29-rc7
v2.6.29-rc8
v2.6.30
v2.6.30-rc1
v2.6.30-rc2
v2.6.30-rc3
v2.6.30-rc4
v2.6.30-rc5
v2.6.30-rc6
v2.6.30-rc7
v2.6.30-rc8
v2.6.31
v2.6.31-rc1
v2.6.31-rc2
v2.6.31-rc3
v2.6.31-rc4
v2.6.31-rc5
v2.6.31-rc6
v2.6.31-rc7
v2.6.31-rc8
v2.6.31-rc9
v2.6.32
v2.6.32-rc1
v2.6.32-rc2
v2.6.32-rc3
v2.6.32-rc4
v2.6.32-rc5
v2.6.32-rc6
v2.6.32-rc7
v2.6.32-rc8
v2.6.32.1
v2.6.32.10
v2.6.32.11
v2.6.32.12
v2.6.32.13
v2.6.32.14
v2.6.32.15
v2.6.32.16
v2.6.32.17
v2.6.32.18
v2.6.32.2
v2.6.32.3
v2.6.32.4
v2.6.32.5
v2.6.32.6
v2.6.32.7
v2.6.32.8
v2.6.32.9

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2026-31519.json"

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
2.6.33
Fixed
6.1.168
Type
ECOSYSTEM
Events
Introduced
6.2.0
Fixed
6.6.131
Type
ECOSYSTEM
Events
Introduced
6.7.0
Fixed
6.12.80
Type
ECOSYSTEM
Events
Introduced
6.13.0
Fixed
6.18.21
Type
ECOSYSTEM
Events
Introduced
6.19.0
Fixed
6.19.11

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2026-31519.json"