# CVE-2024-27080: btrfs: fix race when detecting delalloc ranges during fiemap

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

- **Severity:** MEDIUM 4.7
- **CVSS:** 4.7 (v3.1, NVD) `CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: High; 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.22% (percentile 7, 2026-11-26)
- **CWE:** CWE-362
- **Published:** 2024-05-01T13:05:02.022Z
- **Modified:** 2026-10-30T13:17:25.913Z

## Who should check

- Anyone running Linux \>= ded566b4637f1b6b4c9ba74e7d0b8493e93f19cf, \< 49d640d2946c35a17b051d54171a032dd95b0f50; \>= b0ad381fa7690244802aed119b478b4bdafc31dd, \< ced63fffd63072c0ca55d5a451010d71bf08c0b3; \>= b0ad381fa7690244802aed119b478b4bdafc31dd, \< 978b63f7464abcfd364a6c95f734282c50f3decf; 06d3879bb51be205a04b3da752cfd121a3367fb1; 89bca7fe6382d61e88c67a0b0e7bce315986fb8b; \>= 6.6.24, \< 6.6.26; \>= 6.1.191, \< 6.2; \>= 6.7.12, \< 6.8
- Anyone running Linux 6.8

## Description

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

btrfs: fix race when detecting delalloc ranges during fiemap

For fiemap we recently stopped locking the target extent range for the
whole duration of the fiemap call, in order to avoid a deadlock in a
scenario where the fiemap buffer happens to be a memory mapped range of
the same file. This use case is very unlikely to be useful in practice but
it may be triggered by fuzz testing (syzbot, etc).

This however introduced a race that makes us miss delalloc ranges for
file regions that are currently holes, so the caller of fiemap will not
be aware that there's data for some file regions. This can be quite
serious for some use cases - for example in coreutils versions before 9.0,
the cp program used fiemap to detect holes and data in the source file,
copying only regions with data (extents or delalloc) from the source file
to the destination file in order to preserve holes (see the documentation
for its --sparse command line option). This means that if cp was used
with a source file that had delalloc in a hole, the destination file could
end up without that data, which is effectively a data loss issue, if it
happened to hit the race described below.

The race happens like this:

1) Fiemap is called, without the FIEMAP\_FLAG\_SYNC flag, for a file that
   has delalloc in the file range \[64M, 65M\[, which is currently a hole;

2) Fiemap locks the inode in shared mode, then starts iterating the
   inode's subvolume tree searching for file extent items, without having
   the whole fiemap target range locked in the inode's io tree - the
   change introduced recently by commit b0ad381fa769 ("btrfs: fix
   deadlock with fiemap and extent locking"). It only locks ranges in
   the io tree when it finds a hole or prealloc extent since that
   commit;

3) Note that fiemap clones each leaf before using it, and this is to
   avoid deadlocks when locking a file range in the inode's io tree and
   the fiemap buffer is memory mapped to some file, because writing
   to the page with btrfs\_page\_mkwrite() will wait on any ordered extent
   for the page's range and the ordered extent needs to lock the range
   and may need to modify the same leaf, therefore leading to a deadlock
   on the leaf;

4) While iterating the file extent items in the cloned leaf before
   finding the hole in the range \[64M, 65M\[, the delalloc in that range
   is flushed and its ordered extent completes - meaning the corresponding
   file extent item is in the inode's subvolume tree, but not present in
   the cloned leaf that fiemap is iterating over;

5) When fiemap finds the hole in the \[64M, 65M\[ range by seeing the gap in
   the cloned leaf (or a file extent item with disk\_bytenr == 0 in case
   the NO\_HOLES feature is not enabled), it will lock that file range in
   the inode's io tree and then search for delalloc by checking for the
   EXTENT\_DELALLOC bit in the io tree for that range and ordered extents
   (with btrfs\_find\_delalloc\_in\_range()). But it finds nothing since the
   delalloc in that range was already flushed and the ordered extent
   completed and is gone - as a result fiemap will not report that there's
   delalloc or an extent for the range \[64M, 65M\[, so user space will be
   mislead into thinking that there's a hole in that range.

This could actually be sporadically triggered with test case generic/094
from fstests, which reports a missing extent/delalloc range like this:

  generic/094 2s ... - output mismatch (see /home/fdmanana/git/hub/xfstests/results//generic/094.out.bad)
      --- tests/generic/094.out	2020-06-10 19:29:03.830519425 +0100
      +++ /home/fdmanana/git/hub/xfstests/results//generic/094.out.bad	2024-02-28 11:00:00.381071525 +0000
      @@ -1,3 +1,9 @@
       QA output created by 094
       fiemap run with sync
       fiemap run without sync
      +ERROR: couldn't find extent at 7
      +map is 'HHDDHPPDPHPH'
      +logical: \[       5..       6\] phys:
---truncated---

## Affected and fixed versions

- Linux: \>= ded566b4637f1b6b4c9ba74e7d0b8493e93f19cf, \< 49d640d2946c35a17b051d54171a032dd95b0f50; \>= b0ad381fa7690244802aed119b478b4bdafc31dd, \< ced63fffd63072c0ca55d5a451010d71bf08c0b3; \>= b0ad381fa7690244802aed119b478b4bdafc31dd, \< 978b63f7464abcfd364a6c95f734282c50f3decf; 06d3879bb51be205a04b3da752cfd121a3367fb1; 89bca7fe6382d61e88c67a0b0e7bce315986fb8b; \>= 6.6.24, \< 6.6.26; \>= 6.1.191, \< 6.2; \>= 6.7.12, \< 6.8 (cvelist)
- Linux: 6.8 (cvelist)

## Mitigation

- Upgrade Linux to 6.8 or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2024-27080.md
Affected: Linux >= ded566b4637f1b6b4c9ba74e7d0b8493e93f19cf, < 49d640d2946c35a17b051d54171a032dd95b0f50; >= b0ad381fa7690244802aed119b478b4bdafc31dd, < ced63fffd63072c0ca55d5a451010d71bf08c0b3; >= b0ad381fa7690244802aed119b478b4bdafc31dd, < 978b63f7464abcfd364a6c95f734282c50f3decf; 06d3879bb51be205a04b3da752…
Fixed in: Linux 49d640d2946c35a17b051d54171a032dd95b0f50, Linux 978b63f7464abcfd364a6c95f734282c50f3decf, Linux 6.6.26, Linux 6.2, Linux 6.8

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-2024-27080 being exploited?

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

### How serious is CVE-2024-27080?

Medium: CVSS 4.7 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed). The attack needs conditions outside the attacker's control, which makes it harder.

### Which versions are affected by CVE-2024-27080?

Linux \>= ded566b4637f1b6b4c9ba74e7d0b8493e93f19cf, \< 49d640d2946c35a17b051d54171a032dd95b0f50; \>= b0ad381fa7690244802aed119b478b4bdafc31dd, \< ced63fffd63072c0ca55d5a451010d71bf08c0b3; \>= b0ad381fa7690244802aed119b478b4bdafc31dd, \< 978b63f7464abcfd364a6c95f734282c50f3decf; 06d3879bb51be205a04b3da752cfd121a3367fb1; 89bca7fe6382d61e88c67a0b0e7bce315986fb8b; \>= 6.6.24, \< 6.6.26; \>= 6.1.191, \< 6.2; \>= 6.7.12, \< 6.8; Linux 6.8.

### Is there a fix for CVE-2024-27080?

Yes. Fixed in Linux 49d640d2946c35a17b051d54171a032dd95b0f50, Linux 978b63f7464abcfd364a6c95f734282c50f3decf, Linux 6.6.26, Linux 6.2, Linux 6.8. Upgrade Linux to 6.8 or later.

### How do I check if I'm affected by CVE-2024-27080?

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/49d640d2946c35a17b051d54171a032dd95b0f50>
- patch: <https://git.kernel.org/stable/c/ced63fffd63072c0ca55d5a451010d71bf08c0b3>
- patch: <https://git.kernel.org/stable/c/978b63f7464abcfd364a6c95f734282c50f3decf>

## 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-2024-27080>

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