# CVE-2024-42266: btrfs: make cow\_file\_range\_inline() honor locked\_page on error

> 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.29% (percentile 14, 2026-11-26)
- **CWE:** CWE-476
- **Published:** 2024-08-17T08:54:22.308Z
- **Modified:** 2026-08-05T11:36:11.043Z

## Who should check

- Anyone running Linux \>= 0586d0a89e77d717da14df42648ace4a9fd67981, \< 061e41581606000a83ce0f0f01d6ad338f3704e9; \>= 0586d0a89e77d717da14df42648ace4a9fd67981, \< 478574370bef7951fbd9ef5155537d6cbed49472
- Anyone running Linux 6.10

## Description

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

btrfs: make cow\_file\_range\_inline() honor locked\_page on error

The btrfs buffered write path runs through \_\_extent\_writepage() which
has some tricky return value handling for writepage\_delalloc().
Specifically, when that returns 1, we exit, but for other return values
we continue and end up calling btrfs\_folio\_end\_all\_writers(). If the
folio has been unlocked (note that we check the PageLocked bit at the
start of \_\_extent\_writepage()), this results in an assert panic like
this one from syzbot:

  BTRFS: error (device loop0 state EAL) in free\_log\_tree:3267: errno=-5 IO failure
  BTRFS warning (device loop0 state EAL): Skipping commit of aborted transaction.
  BTRFS: error (device loop0 state EAL) in cleanup\_transaction:2018: errno=-5 IO failure
  assertion failed: folio\_test\_locked(folio), in fs/btrfs/subpage.c:871
  ------------\[ cut here \]------------
  kernel BUG at fs/btrfs/subpage.c:871!
  Oops: invalid opcode: 0000 \[\#1\] PREEMPT SMP KASAN PTI
  CPU: 1 PID: 5090 Comm: syz-executor225 Not tainted
  6.10.0-syzkaller-05505-gb1bc554e009e \#0
  Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
  Google 06/27/2024
  RIP: 0010:btrfs\_folio\_end\_all\_writers+0x55b/0x610 fs/btrfs/subpage.c:871
  Code: e9 d3 fb ff ff e8 25 22 c2 fd 48 c7 c7 c0 3c 0e 8c 48 c7 c6 80 3d
  0e 8c 48 c7 c2 60 3c 0e 8c b9 67 03 00 00 e8 66 47 ad 07 90 \<0f\> 0b e8
  6e 45 b0 07 4c 89 ff be 08 00 00 00 e8 21 12 25 fe 4c 89
  RSP: 0018:ffffc900033d72e0 EFLAGS: 00010246
  RAX: 0000000000000045 RBX: 00fff0000000402c RCX: 663b7a08c50a0a00
  RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
  RBP: ffffc900033d73b0 R08: ffffffff8176b98c R09: 1ffff9200067adfc
  R10: dffffc0000000000 R11: fffff5200067adfd R12: 0000000000000001
  R13: dffffc0000000000 R14: 0000000000000000 R15: ffffea0001cbee80
  FS:  0000000000000000(0000) GS:ffff8880b9500000(0000)
  knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 00007f5f076012f8 CR3: 000000000e134000 CR4: 00000000003506f0
  DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
  DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
  Call Trace:
  \<TASK\>
  \_\_extent\_writepage fs/btrfs/extent\_io.c:1597 \[inline\]
  extent\_write\_cache\_pages fs/btrfs/extent\_io.c:2251 \[inline\]
  btrfs\_writepages+0x14d7/0x2760 fs/btrfs/extent\_io.c:2373
  do\_writepages+0x359/0x870 mm/page-writeback.c:2656
  filemap\_fdatawrite\_wbc+0x125/0x180 mm/filemap.c:397
  \_\_filemap\_fdatawrite\_range mm/filemap.c:430 \[inline\]
  \_\_filemap\_fdatawrite mm/filemap.c:436 \[inline\]
  filemap\_flush+0xdf/0x130 mm/filemap.c:463
  btrfs\_release\_file+0x117/0x130 fs/btrfs/file.c:1547
  \_\_fput+0x24a/0x8a0 fs/file\_table.c:422
  task\_work\_run+0x24f/0x310 kernel/task\_work.c:222
  exit\_task\_work include/linux/task\_work.h:40 \[inline\]
  do\_exit+0xa2f/0x27f0 kernel/exit.c:877
  do\_group\_exit+0x207/0x2c0 kernel/exit.c:1026
  \_\_do\_sys\_exit\_group kernel/exit.c:1037 \[inline\]
  \_\_se\_sys\_exit\_group kernel/exit.c:1035 \[inline\]
  \_\_x64\_sys\_exit\_group+0x3f/0x40 kernel/exit.c:1035
  x64\_sys\_call+0x2634/0x2640
  arch/x86/include/generated/asm/syscalls\_64.h:232
  do\_syscall\_x64 arch/x86/entry/common.c:52 \[inline\]
  do\_syscall\_64+0xf3/0x230 arch/x86/entry/common.c:83
  entry\_SYSCALL\_64\_after\_hwframe+0x77/0x7f
  RIP: 0033:0x7f5f075b70c9
  Code: Unable to access opcode bytes at
  0x7f5f075b709f.

I was hitting the same issue by doing hundreds of accelerated runs of
generic/475, which also hits IO errors by design.

I instrumented that reproducer with bpftrace and found that the
undesirable folio\_unlock was coming from the following callstack:

  folio\_unlock+5
  \_\_process\_pages\_contig+475
  cow\_file\_range\_inline.constprop.0+230
  cow\_file\_range+803
  btrfs\_run\_delalloc\_range+566
  writepage\_delalloc+332
  \_\_extent\_writepage \# inlined in my stacktrace, but I added it here
  extent\_write\_cache\_pages+622

Looking at the bisected-to pa
---truncated---

## Affected and fixed versions

- Linux: \>= 0586d0a89e77d717da14df42648ace4a9fd67981, \< 061e41581606000a83ce0f0f01d6ad338f3704e9; \>= 0586d0a89e77d717da14df42648ace4a9fd67981, \< 478574370bef7951fbd9ef5155537d6cbed49472 (cvelist)
- Linux: 6.10 (cvelist)

## Mitigation

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

Details: https://flawdb.com/CVE-2024-42266.md
Affected: Linux >= 0586d0a89e77d717da14df42648ace4a9fd67981, < 061e41581606000a83ce0f0f01d6ad338f3704e9; >= 0586d0a89e77d717da14df42648ace4a9fd67981, < 478574370bef7951fbd9ef5155537d6cbed49472; Linux 6.10
Fixed in: Linux 061e41581606000a83ce0f0f01d6ad338f3704e9, Linux 478574370bef7951fbd9ef5155537d6cbed49472

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

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

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

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

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

Linux \>= 0586d0a89e77d717da14df42648ace4a9fd67981, \< 061e41581606000a83ce0f0f01d6ad338f3704e9; \>= 0586d0a89e77d717da14df42648ace4a9fd67981, \< 478574370bef7951fbd9ef5155537d6cbed49472; Linux 6.10.

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

Yes. Fixed in Linux 061e41581606000a83ce0f0f01d6ad338f3704e9, Linux 478574370bef7951fbd9ef5155537d6cbed49472. Upgrade Linux to 478574370bef7951fbd9ef5155537d6cbed49472 or later.

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

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/061e41581606000a83ce0f0f01d6ad338f3704e9>
- patch: <https://git.kernel.org/stable/c/478574370bef7951fbd9ef5155537d6cbed49472>

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

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