# CVE-2021-47072: btrfs: fix removed dentries still existing after log is synced

> 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.19% (percentile 5, 2026-11-26)
- **Published:** 2024-03-01T21:15:10.710Z
- **Modified:** 2026-06-17T04:16:23.447Z

## Who should check

- Anyone running Linux \>= 64d6b281ba4db044c946158387c74e1149b9487e, \< 6d0924c5b742036b4f20a0ffdf2b6cf3f963f5f6; \>= 64d6b281ba4db044c946158387c74e1149b9487e, \< 54a40fc3a1da21b52dbf19f72fdc27a2ec740760
- Anyone running Linux 5.12

## Description

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

btrfs: fix removed dentries still existing after log is synced

When we move one inode from one directory to another and both the inode
and its previous parent directory were logged before, we are not supposed
to have the dentry for the old parent if we have a power failure after the
log is synced. Only the new dentry is supposed to exist.

Generally this works correctly, however there is a scenario where this is
not currently working, because the old parent of the file/directory that
was moved is not authoritative for a range that includes the dir index and
dir item keys of the old dentry. This case is better explained with the
following example and reproducer:

  \# The test requires a very specific layout of keys and items in the
  \# fs/subvolume btree to trigger the bug. So we want to make sure that
  \# on whatever platform we are, we have the same leaf/node size.
  \#
  \# Currently in btrfs the node/leaf size can not be smaller than the page
  \# size (but it can be greater than the page size). So use the largest
  \# supported node/leaf size (64K).

  $ mkfs.btrfs -f -n 65536 /dev/sdc
  $ mount /dev/sdc /mnt

  \# "testdir" is inode 257.
  $ mkdir /mnt/testdir
  $ chmod 755 /mnt/testdir

  \# Create several empty files to have the directory "testdir" with its
  \# items spread over several leaves (7 in this case).
  $ for ((i = 1; i \<= 1200; i++)); do
       echo -n \> /mnt/testdir/file$i
    done

  \# Create our test directory "dira", inode number 1458, which gets all
  \# its items in leaf 7.
  \#
  \# The BTRFS\_DIR\_ITEM\_KEY item for inode 257 ("testdir") that points to
  \# the entry named "dira" is in leaf 2, while the BTRFS\_DIR\_INDEX\_KEY
  \# item that points to that entry is in leaf 3.
  \#
  \# For this particular filesystem node size (64K), file count and file
  \# names, we endup with the directory entry items from inode 257 in
  \# leaves 2 and 3, as previously mentioned - what matters for triggering
  \# the bug exercised by this test case is that those items are not placed
  \# in leaf 1, they must be placed in a leaf different from the one
  \# containing the inode item for inode 257.
  \#
  \# The corresponding BTRFS\_DIR\_ITEM\_KEY and BTRFS\_DIR\_INDEX\_KEY items for
  \# the parent inode (257) are the following:
  \#
  \#    item 460 key (257 DIR\_ITEM 3724298081) itemoff 48344 itemsize 34
  \#         location key (1458 INODE\_ITEM 0) type DIR
  \#         transid 6 data\_len 0 name\_len 4
  \#         name: dira
  \#
  \# and:
  \#
  \#    item 771 key (257 DIR\_INDEX 1202) itemoff 36673 itemsize 34
  \#         location key (1458 INODE\_ITEM 0) type DIR
  \#         transid 6 data\_len 0 name\_len 4
  \#         name: dira

  $ mkdir /mnt/testdir/dira

  \# Make sure everything done so far is durably persisted.
  $ sync

  \# Now do a change to inode 257 ("testdir") that does not result in
  \# COWing leaves 2 and 3 - the leaves that contain the directory items
  \# pointing to inode 1458 (directory "dira").
  \#
  \# Changing permissions, the owner/group, updating or adding a xattr,
  \# etc, will not change (COW) leaves 2 and 3. So for the sake of
  \# simplicity change the permissions of inode 257, which results in
  \# updating its inode item and therefore change (COW) only leaf 1.

  $ chmod 700 /mnt/testdir

  \# Now fsync directory inode 257.
  \#
  \# Since only the first leaf was changed/COWed, we log the inode item of
  \# inode 257 and only the dentries found in the first leaf, all have a
  \# key type of BTRFS\_DIR\_ITEM\_KEY, and no keys of type
  \# BTRFS\_DIR\_INDEX\_KEY, because they sort after the former type and none
  \# exist in the first leaf.
  \#
  \# We also log 3 items that represent ranges for dir items and dir
  \# indexes for which the log is authoritative:
  \#
  \# 1) a key of type BTRFS\_DIR\_LOG\_ITEM\_KEY, which indicates the log is
  \#    authoritative for all BTRFS\_DIR\_ITEM\_KEY keys that have an offset
  \#    in the range \[0, 2285968570\] (the offset here is th
---truncated---

## Affected and fixed versions

- Linux: \>= 64d6b281ba4db044c946158387c74e1149b9487e, \< 6d0924c5b742036b4f20a0ffdf2b6cf3f963f5f6; \>= 64d6b281ba4db044c946158387c74e1149b9487e, \< 54a40fc3a1da21b52dbf19f72fdc27a2ec740760 (cvelist)
- Linux: 5.12 (cvelist)

## Mitigation

- Upgrade Linux to 54a40fc3a1da21b52dbf19f72fdc27a2ec740760 or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2021-47072.md
Affected: Linux >= 64d6b281ba4db044c946158387c74e1149b9487e, < 6d0924c5b742036b4f20a0ffdf2b6cf3f963f5f6; >= 64d6b281ba4db044c946158387c74e1149b9487e, < 54a40fc3a1da21b52dbf19f72fdc27a2ec740760; Linux 5.12
Fixed in: Linux 6d0924c5b742036b4f20a0ffdf2b6cf3f963f5f6, Linux 54a40fc3a1da21b52dbf19f72fdc27a2ec740760

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-2021-47072 being exploited?

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

### How serious is CVE-2021-47072?

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

### Which versions are affected by CVE-2021-47072?

Linux \>= 64d6b281ba4db044c946158387c74e1149b9487e, \< 6d0924c5b742036b4f20a0ffdf2b6cf3f963f5f6; \>= 64d6b281ba4db044c946158387c74e1149b9487e, \< 54a40fc3a1da21b52dbf19f72fdc27a2ec740760; Linux 5.12.

### Is there a fix for CVE-2021-47072?

Yes. Fixed in Linux 6d0924c5b742036b4f20a0ffdf2b6cf3f963f5f6, Linux 54a40fc3a1da21b52dbf19f72fdc27a2ec740760. Upgrade Linux to 54a40fc3a1da21b52dbf19f72fdc27a2ec740760 or later.

### How do I check if I'm affected by CVE-2021-47072?

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/6d0924c5b742036b4f20a0ffdf2b6cf3f963f5f6>
- patch: <https://git.kernel.org/stable/c/54a40fc3a1da21b52dbf19f72fdc27a2ec740760>

## 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-2021-47072>

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