# CVE-2024-39496: btrfs: zoned: fix use-after-free due to race with dev replace

- Severity: High 7.8 (CVSS:3.1, scored by Linux) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 0.29%, higher than 22% of CVEs (2026-12-01)
- Published: 2024-07-12T12:20:31.669Z
- Modified: 2026-08-05T11:33:45.997Z
- Weaknesses: CWE-416
- SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial
- Assigned by: Linux

## Description

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

btrfs: zoned: fix use-after-free due to race with dev replace

While loading a zone's info during creation of a block group, we can race
with a device replace operation and then trigger a use-after-free on the
device that was just replaced (source device of the replace operation).

This happens because at btrfs_load_zone_info() we extract a device from
the chunk map into a local variable and then use the device while not
under the protection of the device replace rwsem. So if there's a device
replace operation happening when we extract the device and that device
is the source of the replace operation, we will trigger a use-after-free
if before we finish using the device the replace operation finishes and
frees the device.

Fix this by enlarging the critical section under the protection of the
device replace rwsem so that all uses of the device are done inside the
critical section.

(As written by CVE List.)

## Affected

- Linux Linux: from 5b316468983dfa9473ff0f1c42e4e30b4c267141 before 17765964703b88d8befd899f8501150bb7e07e43; from 5b316468983dfa9473ff0f1c42e4e30b4c267141 before 092571ef9a812566c8f2c9038d9c2a64c49788d6; from 5b316468983dfa9473ff0f1c42e4e30b4c267141 before a0cc006f4214b87e70983c692e05bb36c59b5752; from 5b316468983dfa9473ff0f1c42e4e30b4c267141 before 0090d6e1b210551e63cf43958dc7a1ec942cdde9; 5.11 (not affected: before 5.11; from 6.1.95 up to 6.1.*; from 6.6.35 up to 6.6.*; from 6.9.6 up to 6.9.*; from 6.10 up to *)
- debian debian_linux: 11.0
- linux linux_kernel: from 5.12 before 6.1.95; from 6.2 before 6.6.35; from 6.7 before 6.9.6

## Every score

- Linux: CVSS:3.1 7.8 High `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- NVD: CVSS:3.1 7.8 High `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`

## References

- <https://git.kernel.org/stable/c/17765964703b88d8befd899f8501150bb7e07e43> (patch)
- <https://git.kernel.org/stable/c/092571ef9a812566c8f2c9038d9c2a64c49788d6> (patch)
- <https://git.kernel.org/stable/c/a0cc006f4214b87e70983c692e05bb36c59b5752> (patch)
- <https://git.kernel.org/stable/c/0090d6e1b210551e63cf43958dc7a1ec942cdde9> (patch)
- <https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html> (mailing-list, third-party-advisory)

## Sources

- CVE List: [CVE-2024-39496](https://www.cve.org/CVERecord?id=CVE-2024-39496), CVE Terms of Use, modified 2026-08-05
- NVD: [CVE-2024-39496](https://nvd.nist.gov/vuln/detail/CVE-2024-39496), Public domain, modified 2026-08-04

---

Page: https://cve.day/CVE-2024-39496 · Whole record: https://cve.day/CVE-2024-39496.json · Rebuilt by cve.day 2026-11-25T22:58:42.817Z
