# CVE-2024-26616: btrfs: scrub: avoid use-after-free when chunk length is not 64K aligned

> 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, NVD) `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.32% (percentile 17, 2026-11-26)
- **CWE:** CWE-416
- **Published:** 2024-02-29T15:52:19.452Z
- **Modified:** 2026-06-17T07:17:54.237Z

## Who should check

- Anyone running Linux \>= e02ee89baa66c40e1002cf8b09141fce7265e0f5, \< 642b9c520ef2f104277ad1f902f8526edbe087fb; \>= e02ee89baa66c40e1002cf8b09141fce7265e0f5, \< 34de0f04684ec00c093a0455648be055f0e8e24f; \>= e02ee89baa66c40e1002cf8b09141fce7265e0f5, \< f546c4282673497a06ecb6190b50ae7f6c85b02f
- Anyone running Linux 6.4

## Description

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

btrfs: scrub: avoid use-after-free when chunk length is not 64K aligned

\[BUG\]
There is a bug report that, on a ext4-converted btrfs, scrub leads to
various problems, including:

- "unable to find chunk map" errors
  BTRFS info (device vdb): scrub: started on devid 1
  BTRFS critical (device vdb): unable to find chunk map for logical 2214744064 length 4096
  BTRFS critical (device vdb): unable to find chunk map for logical 2214744064 length 45056

  This would lead to unrepariable errors.

- Use-after-free KASAN reports:
  ==================================================================
  BUG: KASAN: slab-use-after-free in \_\_blk\_rq\_map\_sg+0x18f/0x7c0
  Read of size 8 at addr ffff8881013c9040 by task btrfs/909
  CPU: 0 PID: 909 Comm: btrfs Not tainted 6.7.0-x64v3-dbg \#11 c50636e9419a8354555555245df535e380563b2b
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 2023.11-2 12/24/2023
  Call Trace:
   \<TASK\>
   dump\_stack\_lvl+0x43/0x60
   print\_report+0xcf/0x640
   kasan\_report+0xa6/0xd0
   \_\_blk\_rq\_map\_sg+0x18f/0x7c0
   virtblk\_prep\_rq.isra.0+0x215/0x6a0 \[virtio\_blk 19a65eeee9ae6fcf02edfad39bb9ddee07dcdaff\]
   virtio\_queue\_rqs+0xc4/0x310 \[virtio\_blk 19a65eeee9ae6fcf02edfad39bb9ddee07dcdaff\]
   blk\_mq\_flush\_plug\_list.part.0+0x780/0x860
   \_\_blk\_flush\_plug+0x1ba/0x220
   blk\_finish\_plug+0x3b/0x60
   submit\_initial\_group\_read+0x10a/0x290 \[btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965\]
   flush\_scrub\_stripes+0x38e/0x430 \[btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965\]
   scrub\_stripe+0x82a/0xae0 \[btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965\]
   scrub\_chunk+0x178/0x200 \[btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965\]
   scrub\_enumerate\_chunks+0x4bc/0xa30 \[btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965\]
   btrfs\_scrub\_dev+0x398/0x810 \[btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965\]
   btrfs\_ioctl+0x4b9/0x3020 \[btrfs e57987a360bed82fe8756dcd3e0de5406ccfe965\]
   \_\_x64\_sys\_ioctl+0xbd/0x100
   do\_syscall\_64+0x5d/0xe0
   entry\_SYSCALL\_64\_after\_hwframe+0x63/0x6b
  RIP: 0033:0x7f47e5e0952b

- Crash, mostly due to above use-after-free

\[CAUSE\]
The converted fs has the following data chunk layout:

    item 2 key (FIRST\_CHUNK\_TREE CHUNK\_ITEM 2214658048) itemoff 16025 itemsize 80
        length 86016 owner 2 stripe\_len 65536 type DATA\|single

For above logical bytenr 2214744064, it's at the chunk end
(2214658048 + 86016 = 2214744064).

This means btrfs\_submit\_bio() would split the bio, and trigger endio
function for both of the two halves.

However scrub\_submit\_initial\_read() would only expect the endio function
to be called once, not any more.
This means the first endio function would already free the bbio::bio,
leaving the bvec freed, thus the 2nd endio call would lead to
use-after-free.

\[FIX\]
- Make sure scrub\_read\_endio() only updates bits in its range
  Since we may read less than 64K at the end of the chunk, we should not
  touch the bits beyond chunk boundary.

- Make sure scrub\_submit\_initial\_read() only to read the chunk range
  This is done by calculating the real number of sectors we need to
  read, and add sector-by-sector to the bio.

Thankfully the scrub read repair path won't need extra fixes:

- scrub\_stripe\_submit\_repair\_read()
  With above fixes, we won't update error bit for range beyond chunk,
  thus scrub\_stripe\_submit\_repair\_read() should never submit any read
  beyond the chunk.

## Affected and fixed versions

- Linux: \>= e02ee89baa66c40e1002cf8b09141fce7265e0f5, \< 642b9c520ef2f104277ad1f902f8526edbe087fb; \>= e02ee89baa66c40e1002cf8b09141fce7265e0f5, \< 34de0f04684ec00c093a0455648be055f0e8e24f; \>= e02ee89baa66c40e1002cf8b09141fce7265e0f5, \< f546c4282673497a06ecb6190b50ae7f6c85b02f (cvelist)
- Linux: 6.4 (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-26616. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-26616.md
Affected: Linux >= e02ee89baa66c40e1002cf8b09141fce7265e0f5, < 642b9c520ef2f104277ad1f902f8526edbe087fb; >= e02ee89baa66c40e1002cf8b09141fce7265e0f5, < 34de0f04684ec00c093a0455648be055f0e8e24f; >= e02ee89baa66c40e1002cf8b09141fce7265e0f5, < f546c4282673497a06ecb6190b50ae7f6c85b02f; Linux 6.4
Fixed in: Linux 642b9c520ef2f104277ad1f902f8526edbe087fb, Linux 34de0f04684ec00c093a0455648be055f0e8e24f

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

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

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

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

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

Linux \>= e02ee89baa66c40e1002cf8b09141fce7265e0f5, \< 642b9c520ef2f104277ad1f902f8526edbe087fb; \>= e02ee89baa66c40e1002cf8b09141fce7265e0f5, \< 34de0f04684ec00c093a0455648be055f0e8e24f; \>= e02ee89baa66c40e1002cf8b09141fce7265e0f5, \< f546c4282673497a06ecb6190b50ae7f6c85b02f; Linux 6.4.

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

Yes. Fixed in Linux 642b9c520ef2f104277ad1f902f8526edbe087fb, Linux 34de0f04684ec00c093a0455648be055f0e8e24f. No fix listed yet: follow the vendor advisory.

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

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/642b9c520ef2f104277ad1f902f8526edbe087fb>
- patch: <https://git.kernel.org/stable/c/34de0f04684ec00c093a0455648be055f0e8e24f>
- patch: <https://git.kernel.org/stable/c/f546c4282673497a06ecb6190b50ae7f6c85b02f>

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

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