# CVE-2024-56758: btrfs: check folio mapping after unlock in relocate\_one\_folio()

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

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; 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.30% (percentile 15, 2026-11-26)
- **CWE:** CWE-476
- **Published:** 2025-01-06T16:20:38.942Z
- **Modified:** 2026-06-17T08:12:55.433Z

## Who should check

- Anyone running Linux \>= 08daa38ca212d87f77beae839bc9be71079c7abf, \< 36679fab54fa7bcffafd469e2c474c1fc4beaee0; \>= e7f1326cc24e22b38afc3acd328480a1183f9e79, \< c7b1bd52a031ad0144d42eef0ba8471ce75122dd; \>= e7f1326cc24e22b38afc3acd328480a1183f9e79, \< d508e56270389b3a16f5b3cf247f4eb1bbad1578; \>= e7f1326cc24e22b38afc3acd328480a1183f9e79, \< 3e74859ee35edc33a022c3f3971df066ea0ca6b9; 9d1e020ed9649cf140fcfafd052cfdcce9e9d67d; \>= 6.1.54, \< 6.1.141; \>= 6.5.4, \< 6.6
- Anyone running Linux 6.6

## Description

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

btrfs: check folio mapping after unlock in relocate\_one\_folio()

When we call btrfs\_read\_folio() to bring a folio uptodate, we unlock the
folio. The result of that is that a different thread can modify the
mapping (like remove it with invalidate) before we call folio\_lock().
This results in an invalid page and we need to try again.

In particular, if we are relocating concurrently with aborting a
transaction, this can result in a crash like the following:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  PGD 0 P4D 0
  Oops: 0000 \[\#1\] SMP
  CPU: 76 PID: 1411631 Comm: kworker/u322:5
  Workqueue: events\_unbound btrfs\_reclaim\_bgs\_work
  RIP: 0010:set\_page\_extent\_mapped+0x20/0xb0
  RSP: 0018:ffffc900516a7be8 EFLAGS: 00010246
  RAX: ffffea009e851d08 RBX: ffffea009e0b1880 RCX: 0000000000000000
  RDX: 0000000000000000 RSI: ffffc900516a7b90 RDI: ffffea009e0b1880
  RBP: 0000000003573000 R08: 0000000000000001 R09: ffff88c07fd2f3f0
  R10: 0000000000000000 R11: 0000194754b575be R12: 0000000003572000
  R13: 0000000003572fff R14: 0000000000100cca R15: 0000000005582fff
  FS:  0000000000000000(0000) GS:ffff88c07fd00000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 0000000000000000 CR3: 000000407d00f002 CR4: 00000000007706f0
  DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
  DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
  PKRU: 55555554
  Call Trace:
  \<TASK\>
  ? \_\_die+0x78/0xc0
  ? page\_fault\_oops+0x2a8/0x3a0
  ? \_\_switch\_to+0x133/0x530
  ? wq\_worker\_running+0xa/0x40
  ? exc\_page\_fault+0x63/0x130
  ? asm\_exc\_page\_fault+0x22/0x30
  ? set\_page\_extent\_mapped+0x20/0xb0
  relocate\_file\_extent\_cluster+0x1a7/0x940
  relocate\_data\_extent+0xaf/0x120
  relocate\_block\_group+0x20f/0x480
  btrfs\_relocate\_block\_group+0x152/0x320
  btrfs\_relocate\_chunk+0x3d/0x120
  btrfs\_reclaim\_bgs\_work+0x2ae/0x4e0
  process\_scheduled\_works+0x184/0x370
  worker\_thread+0xc6/0x3e0
  ? blk\_add\_timer+0xb0/0xb0
  kthread+0xae/0xe0
  ? flush\_tlb\_kernel\_range+0x90/0x90
  ret\_from\_fork+0x2f/0x40
  ? flush\_tlb\_kernel\_range+0x90/0x90
  ret\_from\_fork\_asm+0x11/0x20
  \</TASK\>

This occurs because cleanup\_one\_transaction() calls
destroy\_delalloc\_inodes() which calls invalidate\_inode\_pages2() which
takes the folio\_lock before setting mapping to NULL. We fail to check
this, and subsequently call set\_extent\_mapping(), which assumes that
mapping != NULL (in fact it asserts that in debug mode)

Note that the "fixes" patch here is not the one that introduced the
race (the very first iteration of this code from 2009) but a more recent
change that made this particular crash happen in practice.

## Affected and fixed versions

- Linux: \>= 08daa38ca212d87f77beae839bc9be71079c7abf, \< 36679fab54fa7bcffafd469e2c474c1fc4beaee0; \>= e7f1326cc24e22b38afc3acd328480a1183f9e79, \< c7b1bd52a031ad0144d42eef0ba8471ce75122dd; \>= e7f1326cc24e22b38afc3acd328480a1183f9e79, \< d508e56270389b3a16f5b3cf247f4eb1bbad1578; \>= e7f1326cc24e22b38afc3acd328480a1183f9e79, \< 3e74859ee35edc33a022c3f3971df066ea0ca6b9; 9d1e020ed9649cf140fcfafd052cfdcce9e9d67d; \>= 6.1.54, \< 6.1.141; \>= 6.5.4, \< 6.6 (cvelist)
- Linux: 6.6 (cvelist)

## Mitigation

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

Details: https://flawdb.com/CVE-2024-56758.md
Affected: Linux >= 08daa38ca212d87f77beae839bc9be71079c7abf, < 36679fab54fa7bcffafd469e2c474c1fc4beaee0; >= e7f1326cc24e22b38afc3acd328480a1183f9e79, < c7b1bd52a031ad0144d42eef0ba8471ce75122dd; >= e7f1326cc24e22b38afc3acd328480a1183f9e79, < d508e56270389b3a16f5b3cf247f4eb1bbad1578; >= e7f1326cc24e22b38afc3ac…
Fixed in: Linux 36679fab54fa7bcffafd469e2c474c1fc4beaee0, Linux 3e74859ee35edc33a022c3f3971df066ea0ca6b9, Linux 6.1.141, Linux 6.6

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

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

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

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

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

Linux \>= 08daa38ca212d87f77beae839bc9be71079c7abf, \< 36679fab54fa7bcffafd469e2c474c1fc4beaee0; \>= e7f1326cc24e22b38afc3acd328480a1183f9e79, \< c7b1bd52a031ad0144d42eef0ba8471ce75122dd; \>= e7f1326cc24e22b38afc3acd328480a1183f9e79, \< d508e56270389b3a16f5b3cf247f4eb1bbad1578; \>= e7f1326cc24e22b38afc3acd328480a1183f9e79, \< 3e74859ee35edc33a022c3f3971df066ea0ca6b9; 9d1e020ed9649cf140fcfafd052cfdcce9e9d67d; \>= 6.1.54, \< 6.1.141; \>= 6.5.4, \< 6.6; Linux 6.6.

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

Yes. Fixed in Linux 36679fab54fa7bcffafd469e2c474c1fc4beaee0, Linux 3e74859ee35edc33a022c3f3971df066ea0ca6b9, Linux 6.1.141, Linux 6.6. Upgrade Linux to 6.6 or later.

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

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/d508e56270389b3a16f5b3cf247f4eb1bbad1578>
- patch: <https://git.kernel.org/stable/c/3e74859ee35edc33a022c3f3971df066ea0ca6b9>
- other: <https://git.kernel.org/stable/c/36679fab54fa7bcffafd469e2c474c1fc4beaee0>
- other: <https://git.kernel.org/stable/c/c7b1bd52a031ad0144d42eef0ba8471ce75122dd>
- other: <https://lists.debian.org/debian-lts-announce/2025/10/msg00008.html>

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

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