# CVE-2024-50217: btrfs: fix use-after-free of block device file in \_\_btrfs\_free\_extra\_devids()

> 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:N/UI:R/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: None; User interaction: Required; 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.33% (percentile 19, 2026-11-26)
- **CWE:** CWE-416
- **Published:** 2024-11-09T10:14:28.798Z
- **Modified:** 2026-08-05T11:42:34.683Z

## Who should check

- Anyone running Linux \>= 142388194191a3edc9ba01cfcfd8b691e0971fb2, \< 47a83f8df39545f3f552bb6a1b6d9c30e37621dd; \>= 142388194191a3edc9ba01cfcfd8b691e0971fb2, \< aec8e6bf839101784f3ef037dcdb9432c3f32343
- Anyone running Linux 4.8

## Description

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

btrfs: fix use-after-free of block device file in \_\_btrfs\_free\_extra\_devids()

Mounting btrfs from two images (which have the same one fsid and two
different dev\_uuids) in certain executing order may trigger an UAF for
variable 'device-\>bdev\_file' in \_\_btrfs\_free\_extra\_devids(). And
following are the details:

1. Attach image\_1 to loop0, attach image\_2 to loop1, and scan btrfs
   devices by ioctl(BTRFS\_IOC\_SCAN\_DEV):

             /  btrfs\_device\_1 → loop0
   fs\_device
             \\  btrfs\_device\_2 → loop1
2. mount /dev/loop0 /mnt
   btrfs\_open\_devices
    btrfs\_device\_1-\>bdev\_file = btrfs\_get\_bdev\_and\_sb(loop0)
    btrfs\_device\_2-\>bdev\_file = btrfs\_get\_bdev\_and\_sb(loop1)
   btrfs\_fill\_super
    open\_ctree
     fail: btrfs\_close\_devices // -ENOMEM
	    btrfs\_close\_bdev(btrfs\_device\_1)
             fput(btrfs\_device\_1-\>bdev\_file)
	      // btrfs\_device\_1-\>bdev\_file is freed
	    btrfs\_close\_bdev(btrfs\_device\_2)
             fput(btrfs\_device\_2-\>bdev\_file)

3. mount /dev/loop1 /mnt
   btrfs\_open\_devices
    btrfs\_get\_bdev\_and\_sb(&bdev\_file)
     // EIO, btrfs\_device\_1-\>bdev\_file is not assigned,
     // which points to a freed memory area
    btrfs\_device\_2-\>bdev\_file = btrfs\_get\_bdev\_and\_sb(loop1)
   btrfs\_fill\_super
    open\_ctree
     btrfs\_free\_extra\_devids
      if (btrfs\_device\_1-\>bdev\_file)
       fput(btrfs\_device\_1-\>bdev\_file) // UAF !

Fix it by setting 'device-\>bdev\_file' as 'NULL' after closing the
btrfs\_device in btrfs\_close\_one\_device().

## Affected and fixed versions

- Linux: \>= 142388194191a3edc9ba01cfcfd8b691e0971fb2, \< 47a83f8df39545f3f552bb6a1b6d9c30e37621dd; \>= 142388194191a3edc9ba01cfcfd8b691e0971fb2, \< aec8e6bf839101784f3ef037dcdb9432c3f32343 (cvelist)
- Linux: 4.8 (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-50217. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-50217.md
Affected: Linux >= 142388194191a3edc9ba01cfcfd8b691e0971fb2, < 47a83f8df39545f3f552bb6a1b6d9c30e37621dd; >= 142388194191a3edc9ba01cfcfd8b691e0971fb2, < aec8e6bf839101784f3ef037dcdb9432c3f32343; Linux 4.8
Fixed in: Linux 47a83f8df39545f3f552bb6a1b6d9c30e37621dd

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

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

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

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed). A user has to take an action, such as opening a link, for the attack to work.

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

Linux \>= 142388194191a3edc9ba01cfcfd8b691e0971fb2, \< 47a83f8df39545f3f552bb6a1b6d9c30e37621dd; \>= 142388194191a3edc9ba01cfcfd8b691e0971fb2, \< aec8e6bf839101784f3ef037dcdb9432c3f32343; Linux 4.8.

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

Yes. Fixed in Linux 47a83f8df39545f3f552bb6a1b6d9c30e37621dd. No fix listed yet: follow the vendor advisory.

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

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/47a83f8df39545f3f552bb6a1b6d9c30e37621dd>
- patch: <https://git.kernel.org/stable/c/aec8e6bf839101784f3ef037dcdb9432c3f32343>
- other: <http://www.openwall.com/lists/oss-security/2025/04/10/4>
- other: <http://www.openwall.com/lists/oss-security/2025/04/10/5>
- other: <http://www.openwall.com/lists/oss-security/2025/04/10/6>

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

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