# CVE-2024-35949: btrfs: make sure that WRITTEN is set on all metadata blocks

> 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.33% (percentile 19, 2026-11-26)
- **CWE:** CWE-787
- **Published:** 2024-05-20T09:17:38.893Z
- **Modified:** 2026-08-05T11:31:08.601Z

## Who should check

- Anyone running Linux \>= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, \< 9dff3e36ea89e8003516841c27c45af562b6ef44; \>= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, \< ef3ba8ce8cf7075b716aa4afcefc3034215878ee; \>= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, \< e03418abde871314e1a3a550f4c8afb7b89cb273
- Anyone running Linux 6.5

## Description

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

btrfs: make sure that WRITTEN is set on all metadata blocks

We previously would call btrfs\_check\_leaf() if we had the check
integrity code enabled, which meant that we could only run the extended
leaf checks if we had WRITTEN set on the header flags.

This leaves a gap in our checking, because we could end up with
corruption on disk where WRITTEN isn't set on the leaf, and then the
extended leaf checks don't get run which we rely on to validate all of
the item pointers to make sure we don't access memory outside of the
extent buffer.

However, since 732fab95abe2 ("btrfs: check-integrity: remove
CONFIG\_BTRFS\_FS\_CHECK\_INTEGRITY option") we no longer call
btrfs\_check\_leaf() from btrfs\_mark\_buffer\_dirty(), which means we only
ever call it on blocks that are being written out, and thus have WRITTEN
set, or that are being read in, which should have WRITTEN set.

Add checks to make sure we have WRITTEN set appropriately, and then make
sure \_\_btrfs\_check\_leaf() always does the item checking.  This will
protect us from file systems that have been corrupted and no longer have
WRITTEN set on some of the blocks.

This was hit on a crafted image tweaking the WRITTEN bit and reported by
KASAN as out-of-bound access in the eb accessors. The example is a dir
item at the end of an eb.

  \[2.042\] BTRFS warning (device loop1): bad eb member start: ptr 0x3fff start 30572544 member offset 16410 size 2
  \[2.040\] general protection fault, probably for non-canonical address 0xe0009d1000000003: 0000 \[\#1\] PREEMPT SMP KASAN NOPTI
  \[2.537\] KASAN: maybe wild-memory-access in range \[0x0005088000000018-0x000508800000001f\]
  \[2.729\] CPU: 0 PID: 2587 Comm: mount Not tainted 6.8.2 \#1
  \[2.729\] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
  \[2.621\] RIP: 0010:btrfs\_get\_16+0x34b/0x6d0
  \[2.621\] RSP: 0018:ffff88810871fab8 EFLAGS: 00000206
  \[2.621\] RAX: 0000a11000000003 RBX: ffff888104ff8720 RCX: ffff88811b2288c0
  \[2.621\] RDX: dffffc0000000000 RSI: ffffffff81dd8aca RDI: ffff88810871f748
  \[2.621\] RBP: 000000000000401a R08: 0000000000000001 R09: ffffed10210e3ee9
  \[2.621\] R10: ffff88810871f74f R11: 205d323430333737 R12: 000000000000001a
  \[2.621\] R13: 000508800000001a R14: 1ffff110210e3f5d R15: ffffffff850011e8
  \[2.621\] FS:  00007f56ea275840(0000) GS:ffff88811b200000(0000) knlGS:0000000000000000
  \[2.621\] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  \[2.621\] CR2: 00007febd13b75c0 CR3: 000000010bb50000 CR4: 00000000000006f0
  \[2.621\] Call Trace:
  \[2.621\]  \<TASK\>
  \[2.621\]  ? show\_regs+0x74/0x80
  \[2.621\]  ? die\_addr+0x46/0xc0
  \[2.621\]  ? exc\_general\_protection+0x161/0x2a0
  \[2.621\]  ? asm\_exc\_general\_protection+0x26/0x30
  \[2.621\]  ? btrfs\_get\_16+0x33a/0x6d0
  \[2.621\]  ? btrfs\_get\_16+0x34b/0x6d0
  \[2.621\]  ? btrfs\_get\_16+0x33a/0x6d0
  \[2.621\]  ? \_\_pfx\_btrfs\_get\_16+0x10/0x10
  \[2.621\]  ? \_\_pfx\_mutex\_unlock+0x10/0x10
  \[2.621\]  btrfs\_match\_dir\_item\_name+0x101/0x1a0
  \[2.621\]  btrfs\_lookup\_dir\_item+0x1f3/0x280
  \[2.621\]  ? \_\_pfx\_btrfs\_lookup\_dir\_item+0x10/0x10
  \[2.621\]  btrfs\_get\_tree+0xd25/0x1910

\[ copy more details from report \]

## Affected and fixed versions

- Linux: \>= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, \< 9dff3e36ea89e8003516841c27c45af562b6ef44; \>= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, \< ef3ba8ce8cf7075b716aa4afcefc3034215878ee; \>= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, \< e03418abde871314e1a3a550f4c8afb7b89cb273 (cvelist)
- Linux: 6.5 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2024-35949.md
Affected: Linux >= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, < 9dff3e36ea89e8003516841c27c45af562b6ef44; >= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, < ef3ba8ce8cf7075b716aa4afcefc3034215878ee; >= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, < e03418abde871314e1a3a550f4c8afb7b89cb273; Linux 6.5
Fixed in: Linux 9dff3e36ea89e8003516841c27c45af562b6ef44

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

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

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

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

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

Linux \>= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, \< 9dff3e36ea89e8003516841c27c45af562b6ef44; \>= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, \< ef3ba8ce8cf7075b716aa4afcefc3034215878ee; \>= 85d8a826c7cde17f9cca9c4debecb4538bdb6573, \< e03418abde871314e1a3a550f4c8afb7b89cb273; Linux 6.5.

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

Yes. Fixed in Linux 9dff3e36ea89e8003516841c27c45af562b6ef44. No fix listed yet: follow the vendor advisory.

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

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/9dff3e36ea89e8003516841c27c45af562b6ef44>
- patch: <https://git.kernel.org/stable/c/ef3ba8ce8cf7075b716aa4afcefc3034215878ee>
- patch: <https://git.kernel.org/stable/c/e03418abde871314e1a3a550f4c8afb7b89cb273>
- other: <https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/OTB4HWU2PTVW5NEYHHLOCXDKG3PYA534/>

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

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