# CVE-2024-46687: btrfs: fix a use-after-free when hitting errors inside btrfs\_submit\_chunk()

> 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.31% (percentile 17, 2026-11-26)
- **CWE:** CWE-415, CWE-416
- **Published:** 2024-09-13T05:29:18.429Z
- **Modified:** 2026-08-05T11:37:57.829Z

## Who should check

- Anyone running Linux \>= 852eee62d31abd695cd43e1b875d664ed292a8ca, \< 51722b99f41f5e722ffa10b8f61e802a0e70b331; \>= 852eee62d31abd695cd43e1b875d664ed292a8ca, \< 4a3b9e1a8e6cd1a8d427a905e159de58d38941cc; \>= 852eee62d31abd695cd43e1b875d664ed292a8ca, \< 10d9d8c3512f16cad47b2ff81ec6fc4b27d8ee10
- Anyone running Linux 6.3

## Description

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

btrfs: fix a use-after-free when hitting errors inside btrfs\_submit\_chunk()

\[BUG\]
There is an internal report that KASAN is reporting use-after-free, with
the following backtrace:

  BUG: KASAN: slab-use-after-free in btrfs\_check\_read\_bio+0xa68/0xb70 \[btrfs\]
  Read of size 4 at addr ffff8881117cec28 by task kworker/u16:2/45
  CPU: 1 UID: 0 PID: 45 Comm: kworker/u16:2 Not tainted 6.11.0-rc2-next-20240805-default+ \#76
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
  Workqueue: btrfs-endio btrfs\_end\_bio\_work \[btrfs\]
  Call Trace:
   dump\_stack\_lvl+0x61/0x80
   print\_address\_description.constprop.0+0x5e/0x2f0
   print\_report+0x118/0x216
   kasan\_report+0x11d/0x1f0
   btrfs\_check\_read\_bio+0xa68/0xb70 \[btrfs\]
   process\_one\_work+0xce0/0x12a0
   worker\_thread+0x717/0x1250
   kthread+0x2e3/0x3c0
   ret\_from\_fork+0x2d/0x70
   ret\_from\_fork\_asm+0x11/0x20

  Allocated by task 20917:
   kasan\_save\_stack+0x37/0x60
   kasan\_save\_track+0x10/0x30
   \_\_kasan\_slab\_alloc+0x7d/0x80
   kmem\_cache\_alloc\_noprof+0x16e/0x3e0
   mempool\_alloc\_noprof+0x12e/0x310
   bio\_alloc\_bioset+0x3f0/0x7a0
   btrfs\_bio\_alloc+0x2e/0x50 \[btrfs\]
   submit\_extent\_page+0x4d1/0xdb0 \[btrfs\]
   btrfs\_do\_readpage+0x8b4/0x12a0 \[btrfs\]
   btrfs\_readahead+0x29a/0x430 \[btrfs\]
   read\_pages+0x1a7/0xc60
   page\_cache\_ra\_unbounded+0x2ad/0x560
   filemap\_get\_pages+0x629/0xa20
   filemap\_read+0x335/0xbf0
   vfs\_read+0x790/0xcb0
   ksys\_read+0xfd/0x1d0
   do\_syscall\_64+0x6d/0x140
   entry\_SYSCALL\_64\_after\_hwframe+0x4b/0x53

  Freed by task 20917:
   kasan\_save\_stack+0x37/0x60
   kasan\_save\_track+0x10/0x30
   kasan\_save\_free\_info+0x37/0x50
   \_\_kasan\_slab\_free+0x4b/0x60
   kmem\_cache\_free+0x214/0x5d0
   bio\_free+0xed/0x180
   end\_bbio\_data\_read+0x1cc/0x580 \[btrfs\]
   btrfs\_submit\_chunk+0x98d/0x1880 \[btrfs\]
   btrfs\_submit\_bio+0x33/0x70 \[btrfs\]
   submit\_one\_bio+0xd4/0x130 \[btrfs\]
   submit\_extent\_page+0x3ea/0xdb0 \[btrfs\]
   btrfs\_do\_readpage+0x8b4/0x12a0 \[btrfs\]
   btrfs\_readahead+0x29a/0x430 \[btrfs\]
   read\_pages+0x1a7/0xc60
   page\_cache\_ra\_unbounded+0x2ad/0x560
   filemap\_get\_pages+0x629/0xa20
   filemap\_read+0x335/0xbf0
   vfs\_read+0x790/0xcb0
   ksys\_read+0xfd/0x1d0
   do\_syscall\_64+0x6d/0x140
   entry\_SYSCALL\_64\_after\_hwframe+0x4b/0x53

\[CAUSE\]
Although I cannot reproduce the error, the report itself is good enough
to pin down the cause.

The call trace is the regular endio workqueue context, but the
free-by-task trace is showing that during btrfs\_submit\_chunk() we
already hit a critical error, and is calling btrfs\_bio\_end\_io() to error
out.  And the original endio function called bio\_put() to free the whole
bio.

This means a double freeing thus causing use-after-free, e.g.:

1. Enter btrfs\_submit\_bio() with a read bio
   The read bio length is 128K, crossing two 64K stripes.

2. The first run of btrfs\_submit\_chunk()

2.1 Call btrfs\_map\_block(), which returns 64K
2.2 Call btrfs\_split\_bio()
    Now there are two bios, one referring to the first 64K, the other
    referring to the second 64K.
2.3 The first half is submitted.

3. The second run of btrfs\_submit\_chunk()

3.1 Call btrfs\_map\_block(), which by somehow failed
    Now we call btrfs\_bio\_end\_io() to handle the error

3.2 btrfs\_bio\_end\_io() calls the original endio function
    Which is end\_bbio\_data\_read(), and it calls bio\_put() for the
    original bio.

    Now the original bio is freed.

4. The submitted first 64K bio finished
   Now we call into btrfs\_check\_read\_bio() and tries to advance the bio
   iter.
   But since the original bio (thus its iter) is already freed, we
   trigger the above use-after free.

   And even if the memory is not poisoned/corrupted, we will later call
   the original endio function, causing a double freeing.

\[FIX\]
Instead of calling btrfs\_bio\_end\_io(), call btrfs\_orig\_bbio\_end\_io(),
which has the extra check on split bios and do the pr
---truncated---

## Affected and fixed versions

- Linux: \>= 852eee62d31abd695cd43e1b875d664ed292a8ca, \< 51722b99f41f5e722ffa10b8f61e802a0e70b331; \>= 852eee62d31abd695cd43e1b875d664ed292a8ca, \< 4a3b9e1a8e6cd1a8d427a905e159de58d38941cc; \>= 852eee62d31abd695cd43e1b875d664ed292a8ca, \< 10d9d8c3512f16cad47b2ff81ec6fc4b27d8ee10 (cvelist)
- Linux: 6.3 (cvelist)

## Mitigation

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

Details: https://flawdb.com/CVE-2024-46687.md
Affected: Linux >= 852eee62d31abd695cd43e1b875d664ed292a8ca, < 51722b99f41f5e722ffa10b8f61e802a0e70b331; >= 852eee62d31abd695cd43e1b875d664ed292a8ca, < 4a3b9e1a8e6cd1a8d427a905e159de58d38941cc; >= 852eee62d31abd695cd43e1b875d664ed292a8ca, < 10d9d8c3512f16cad47b2ff81ec6fc4b27d8ee10; Linux 6.3
Fixed in: Linux 51722b99f41f5e722ffa10b8f61e802a0e70b331, Linux 4a3b9e1a8e6cd1a8d427a905e159de58d38941cc, Linux 10d9d8c3512f16cad47b2ff81ec6fc4b27d8ee10

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

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

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

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

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

Linux \>= 852eee62d31abd695cd43e1b875d664ed292a8ca, \< 51722b99f41f5e722ffa10b8f61e802a0e70b331; \>= 852eee62d31abd695cd43e1b875d664ed292a8ca, \< 4a3b9e1a8e6cd1a8d427a905e159de58d38941cc; \>= 852eee62d31abd695cd43e1b875d664ed292a8ca, \< 10d9d8c3512f16cad47b2ff81ec6fc4b27d8ee10; Linux 6.3.

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

Yes. Fixed in Linux 51722b99f41f5e722ffa10b8f61e802a0e70b331, Linux 4a3b9e1a8e6cd1a8d427a905e159de58d38941cc, Linux 10d9d8c3512f16cad47b2ff81ec6fc4b27d8ee10. Upgrade Linux to 10d9d8c3512f16cad47b2ff81ec6fc4b27d8ee10 or later.

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

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/51722b99f41f5e722ffa10b8f61e802a0e70b331>
- patch: <https://git.kernel.org/stable/c/4a3b9e1a8e6cd1a8d427a905e159de58d38941cc>
- patch: <https://git.kernel.org/stable/c/10d9d8c3512f16cad47b2ff81ec6fc4b27d8ee10>

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

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