# CVE-2024-37354: btrfs: fix crash on racing fsync and size-extending write into prealloc

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

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; 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.25% (percentile 10, 2026-11-28)
- **CWE:** CWE-362
- **Published:** 2024-06-25T14:22:36.228Z
- **Modified:** 2026-08-05T11:32:30.724Z

## Who should check

- Anyone running Linux \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< c993fd02ba471e296ca1996f13626fc917120158; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< 1ff2bd566fbcefcb892be85c493bdb92b911c428; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< 3d08c52ba1887a1ff9c179d4b6a18b427bcb2097; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< f4e5ed974876c14d3623e04dc43d3e3281bc6011; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< 9d274c19a71b3a276949933859610721a453946b; 61a9f6b7fe0ca9706b49a23cecf5f9a9c802b6ce; \>= 4.14.57, \< 4.15
- Anyone running Linux 4.17

## Description

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

btrfs: fix crash on racing fsync and size-extending write into prealloc

We have been seeing crashes on duplicate keys in
btrfs\_set\_item\_key\_safe():

  BTRFS critical (device vdb): slot 4 key (450 108 8192) new key (450 108 8192)
  ------------\[ cut here \]------------
  kernel BUG at fs/btrfs/ctree.c:2620!
  invalid opcode: 0000 \[\#1\] PREEMPT SMP PTI
  CPU: 0 PID: 3139 Comm: xfs\_io Kdump: loaded Not tainted 6.9.0 \#6
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-2.fc40 04/01/2014
  RIP: 0010:btrfs\_set\_item\_key\_safe+0x11f/0x290 \[btrfs\]

With the following stack trace:

  \#0  btrfs\_set\_item\_key\_safe (fs/btrfs/ctree.c:2620:4)
  \#1  btrfs\_drop\_extents (fs/btrfs/file.c:411:4)
  \#2  log\_one\_extent (fs/btrfs/tree-log.c:4732:9)
  \#3  btrfs\_log\_changed\_extents (fs/btrfs/tree-log.c:4955:9)
  \#4  btrfs\_log\_inode (fs/btrfs/tree-log.c:6626:9)
  \#5  btrfs\_log\_inode\_parent (fs/btrfs/tree-log.c:7070:8)
  \#6  btrfs\_log\_dentry\_safe (fs/btrfs/tree-log.c:7171:8)
  \#7  btrfs\_sync\_file (fs/btrfs/file.c:1933:8)
  \#8  vfs\_fsync\_range (fs/sync.c:188:9)
  \#9  vfs\_fsync (fs/sync.c:202:9)
  \#10 do\_fsync (fs/sync.c:212:9)
  \#11 \_\_do\_sys\_fdatasync (fs/sync.c:225:9)
  \#12 \_\_se\_sys\_fdatasync (fs/sync.c:223:1)
  \#13 \_\_x64\_sys\_fdatasync (fs/sync.c:223:1)
  \#14 do\_syscall\_x64 (arch/x86/entry/common.c:52:14)
  \#15 do\_syscall\_64 (arch/x86/entry/common.c:83:7)
  \#16 entry\_SYSCALL\_64+0xaf/0x14c (arch/x86/entry/entry\_64.S:121)

So we're logging a changed extent from fsync, which is splitting an
extent in the log tree. But this split part already exists in the tree,
triggering the BUG().

This is the state of the log tree at the time of the crash, dumped with
drgn (https://github.com/osandov/drgn/blob/main/contrib/btrfs\_tree.py)
to get more details than btrfs\_print\_leaf() gives us:

  \>\>\> print\_extent\_buffer(prog.crashed\_thread().stack\_trace()\[0\]\["eb"\])
  leaf 33439744 level 0 items 72 generation 9 owner 18446744073709551610
  leaf 33439744 flags 0x100000000000000
  fs uuid e5bd3946-400c-4223-8923-190ef1f18677
  chunk uuid d58cb17e-6d02-494a-829a-18b7d8a399da
          item 0 key (450 INODE\_ITEM 0) itemoff 16123 itemsize 160
                  generation 7 transid 9 size 8192 nbytes 8473563889606862198
                  block group 0 mode 100600 links 1 uid 0 gid 0 rdev 0
                  sequence 204 flags 0x10(PREALLOC)
                  atime 1716417703.220000000 (2024-05-22 15:41:43)
                  ctime 1716417704.983333333 (2024-05-22 15:41:44)
                  mtime 1716417704.983333333 (2024-05-22 15:41:44)
                  otime 17592186044416.000000000 (559444-03-08 01:40:16)
          item 1 key (450 INODE\_REF 256) itemoff 16110 itemsize 13
                  index 195 namelen 3 name: 193
          item 2 key (450 XATTR\_ITEM 1640047104) itemoff 16073 itemsize 37
                  location key (0 UNKNOWN.0 0) type XATTR
                  transid 7 data\_len 1 name\_len 6
                  name: user.a
                  data a
          item 3 key (450 EXTENT\_DATA 0) itemoff 16020 itemsize 53
                  generation 9 type 1 (regular)
                  extent data disk byte 303144960 nr 12288
                  extent data offset 0 nr 4096 ram 12288
                  extent compression 0 (none)
          item 4 key (450 EXTENT\_DATA 4096) itemoff 15967 itemsize 53
                  generation 9 type 2 (prealloc)
                  prealloc data disk byte 303144960 nr 12288
                  prealloc data offset 4096 nr 8192
          item 5 key (450 EXTENT\_DATA 8192) itemoff 15914 itemsize 53
                  generation 9 type 2 (prealloc)
                  prealloc data disk byte 303144960 nr 12288
                  prealloc data offset 8192 nr 4096
  ...

So the real problem happened earlier: notice that items 4 (4k-12k) and 5
(8k-12k) overlap. Both are prealloc extents. Item 4 straddles i\_size and
item 5 starts at i\_size.

Here is the state of 
---truncated---

## Affected and fixed versions

- Linux: \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< c993fd02ba471e296ca1996f13626fc917120158; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< 1ff2bd566fbcefcb892be85c493bdb92b911c428; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< 3d08c52ba1887a1ff9c179d4b6a18b427bcb2097; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< f4e5ed974876c14d3623e04dc43d3e3281bc6011; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< 9d274c19a71b3a276949933859610721a453946b; 61a9f6b7fe0ca9706b49a23cecf5f9a9c802b6ce; \>= 4.14.57, \< 4.15 (cvelist)
- Linux: 4.17 (cvelist)

## Mitigation

- Upgrade Linux to 4.15 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-37354. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-37354.md
Affected: Linux >= 31d11b83b96faaee4bb514d375a09489117c3e8d, < c993fd02ba471e296ca1996f13626fc917120158; >= 31d11b83b96faaee4bb514d375a09489117c3e8d, < 1ff2bd566fbcefcb892be85c493bdb92b911c428; >= 31d11b83b96faaee4bb514d375a09489117c3e8d, < 3d08c52ba1887a1ff9c179d4b6a18b427bcb2097; >= 31d11b83b96faaee4bb514d…
Fixed in: Linux 1ff2bd566fbcefcb892be85c493bdb92b911c428, Linux 3d08c52ba1887a1ff9c179d4b6a18b427bcb2097, Linux 9d274c19a71b3a276949933859610721a453946b, Linux 4.15

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-37354 being exploited?

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

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

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

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

Linux \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< c993fd02ba471e296ca1996f13626fc917120158; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< 1ff2bd566fbcefcb892be85c493bdb92b911c428; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< 3d08c52ba1887a1ff9c179d4b6a18b427bcb2097; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< f4e5ed974876c14d3623e04dc43d3e3281bc6011; \>= 31d11b83b96faaee4bb514d375a09489117c3e8d, \< 9d274c19a71b3a276949933859610721a453946b; 61a9f6b7fe0ca9706b49a23cecf5f9a9c802b6ce; \>= 4.14.57, \< 4.15; Linux 4.17.

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

Yes. Fixed in Linux 1ff2bd566fbcefcb892be85c493bdb92b911c428, Linux 3d08c52ba1887a1ff9c179d4b6a18b427bcb2097, Linux 9d274c19a71b3a276949933859610721a453946b, Linux 4.15. Upgrade Linux to 4.15 or later.

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

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/1ff2bd566fbcefcb892be85c493bdb92b911c428>
- patch: <https://git.kernel.org/stable/c/3d08c52ba1887a1ff9c179d4b6a18b427bcb2097>
- patch: <https://git.kernel.org/stable/c/f4e5ed974876c14d3623e04dc43d3e3281bc6011>
- patch: <https://git.kernel.org/stable/c/9d274c19a71b3a276949933859610721a453946b>
- other: <https://git.kernel.org/stable/c/c993fd02ba471e296ca1996f13626fc917120158>

## 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-37354>

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