# CVE-2026-31519: btrfs: set BTRFS\_ROOT\_ORPHAN\_CLEANUP during subvol create

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.17% (percentile 4, 2026-11-28)
- **CWE:** CWE-476
- **Published:** 2026-04-22T13:54:34.860Z
- **Modified:** 2026-11-11T23:10:00.263Z

## Who should check

- Anyone running Linux \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< d43da8de0ed376abafbad8a245a1835e8f66cb0f; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< c57276ced3c3207f42182dfa2f0d8e860357e111; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< a41a9b8d19a98b45591528c6e54d31cc66271d1e; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< 2ec578e6452138ab76f6c9a9c18711fcd197649f; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< 696683f214495db3cdacab9a713efaaced8660f8; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< 5131fa077f9bb386a1b901bf5b247041f0ec8f80; c4ba0bd9db5e8fd2664be0fd4ec01335fe3268eb; \>= 2.6.32.19, \< 2.6.33
- Anyone running Linux 2.6.33

## Description

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

btrfs: set BTRFS\_ROOT\_ORPHAN\_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
btrfs\_orphan\_cleanup(), with the stack leading back up to
btrfs\_lookup().

btrfs\_lookup
btrfs\_lookup\_dentry
btrfs\_orphan\_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
  btrfs\_orphan\_cleanup() call that sets BTRFS\_ROOT\_ORPHAN\_CLEANUP much
  later.
- after btrfs\_orphan\_cleanup() fails, btrfs\_lookup\_dentry() returns -ENOENT,
  which results in a negative dentry for the subvolume via
  d\_splice\_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.,
btrfs\_lookup()
  btrfs\_lookup\_dentry()
    if (!sb\_rdonly(inode-\>vfs\_inode)-\>vfs\_inode)
    btrfs\_orphan\_cleanup(sub\_root)
      test\_and\_set\_bit(BTRFS\_ROOT\_ORPHAN\_CLEANUP)
      btrfs\_search\_slot() // finds orphan item for inode N
      ...
      prints "could not do orphan cleanup -2"
  if (inode == ERR\_PTR(-ENOENT))
    inode = NULL;
  return d\_splice\_alias(NULL, dentry) // NEGATIVE DENTRY for valid subvolume

btrfs\_orphan\_cleanup() does test\_and\_set\_bit(BTRFS\_ROOT\_ORPHAN\_CLEANUP)
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
btrfs\_orphan\_cleanup() and set the bit.

The final important observation is that create\_subvol() calls
d\_instantiate\_new() but does not set BTRFS\_ROOT\_ORPHAN\_CLEANUP, so if
the dentry cache gets dropped, the next lookup into the subvolume will
make a real call into btrfs\_orphan\_cleanup() 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-\>d\_lockref.count via dget in
d\_alloc(), released in \_\_dentry\_kill()) 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 \_\_dentry\_kill() decrements i\_count but does
not trigger eviction (i\_count \> 0). The child dentry is freed and the
subvol dentry's d\_lockref.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 BTRFS\_ROOT\_ORPHAN\_CLEANUP set

btrfs\_mksubvol()
  lookup\_one\_len()
    \_\_lookup\_slow()
      d\_alloc\_parallel()
        \_\_d\_alloc() // d\_lockref.count = 1
  create\_subvol(dentry)
    // doesn't touch the bit..
    d\_instantiate\_new(dentry, inode) // dentry in cache with d\_lockref.c
---truncated---

## Affected and fixed versions

- Linux: \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< d43da8de0ed376abafbad8a245a1835e8f66cb0f; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< c57276ced3c3207f42182dfa2f0d8e860357e111; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< a41a9b8d19a98b45591528c6e54d31cc66271d1e; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< 2ec578e6452138ab76f6c9a9c18711fcd197649f; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< 696683f214495db3cdacab9a713efaaced8660f8; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< 5131fa077f9bb386a1b901bf5b247041f0ec8f80; c4ba0bd9db5e8fd2664be0fd4ec01335fe3268eb; \>= 2.6.32.19, \< 2.6.33 (cvelist)
- Linux: 2.6.33 (cvelist)

## Mitigation

- Upgrade Linux to 2.6.33 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2026-31519. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-31519.md
Affected: Linux >= c71bf099abddf3e0fdc27f251ba76fca1461d49a, < d43da8de0ed376abafbad8a245a1835e8f66cb0f; >= c71bf099abddf3e0fdc27f251ba76fca1461d49a, < c57276ced3c3207f42182dfa2f0d8e860357e111; >= c71bf099abddf3e0fdc27f251ba76fca1461d49a, < a41a9b8d19a98b45591528c6e54d31cc66271d1e; >= c71bf099abddf3e0fdc27f2…
Fixed in: Linux 2ec578e6452138ab76f6c9a9c18711fcd197649f, Linux 696683f214495db3cdacab9a713efaaced8660f8, Linux 5131fa077f9bb386a1b901bf5b247041f0ec8f80, Linux 2.6.33

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2026-31519 being exploited?

There is no confirmed exploitation: CVE-2026-31519 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.17% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2026-31519?

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2026-31519?

Linux \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< d43da8de0ed376abafbad8a245a1835e8f66cb0f; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< c57276ced3c3207f42182dfa2f0d8e860357e111; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< a41a9b8d19a98b45591528c6e54d31cc66271d1e; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< 2ec578e6452138ab76f6c9a9c18711fcd197649f; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< 696683f214495db3cdacab9a713efaaced8660f8; \>= c71bf099abddf3e0fdc27f251ba76fca1461d49a, \< 5131fa077f9bb386a1b901bf5b247041f0ec8f80; c4ba0bd9db5e8fd2664be0fd4ec01335fe3268eb; \>= 2.6.32.19, \< 2.6.33; Linux 2.6.33.

### Is there a fix for CVE-2026-31519?

Yes. Fixed in Linux 2ec578e6452138ab76f6c9a9c18711fcd197649f, Linux 696683f214495db3cdacab9a713efaaced8660f8, Linux 5131fa077f9bb386a1b901bf5b247041f0ec8f80, Linux 2.6.33. Upgrade Linux to 2.6.33 or later.

### How do I check if I'm affected by CVE-2026-31519?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/d43da8de0ed376abafbad8a245a1835e8f66cb0f>
- patch: <https://git.kernel.org/stable/c/c57276ced3c3207f42182dfa2f0d8e860357e111>
- patch: <https://git.kernel.org/stable/c/a41a9b8d19a98b45591528c6e54d31cc66271d1e>
- patch: <https://git.kernel.org/stable/c/2ec578e6452138ab76f6c9a9c18711fcd197649f>
- patch: <https://git.kernel.org/stable/c/696683f214495db3cdacab9a713efaaced8660f8>
- patch: <https://git.kernel.org/stable/c/5131fa077f9bb386a1b901bf5b247041f0ec8f80>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2026-31519>

HTML: <https://flawdb.com/CVE-2026-31519> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-31519>
