CVE-2024-50217
Severity CVSS v4.0:
Pending analysis
Type:
CWE-416
Use After Free
Publication date:
09/11/2024
Last modified:
11/04/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
btrfs: fix use-after-free of block device file in __btrfs_free_extra_devids()<br />
<br />
Mounting btrfs from two images (which have the same one fsid and two<br />
different dev_uuids) in certain executing order may trigger an UAF for<br />
variable &#39;device->bdev_file&#39; in __btrfs_free_extra_devids(). And<br />
following are the details:<br />
<br />
1. Attach image_1 to loop0, attach image_2 to loop1, and scan btrfs<br />
devices by ioctl(BTRFS_IOC_SCAN_DEV):<br />
<br />
/ btrfs_device_1 → loop0<br />
fs_device<br />
\ btrfs_device_2 → loop1<br />
2. mount /dev/loop0 /mnt<br />
btrfs_open_devices<br />
btrfs_device_1->bdev_file = btrfs_get_bdev_and_sb(loop0)<br />
btrfs_device_2->bdev_file = btrfs_get_bdev_and_sb(loop1)<br />
btrfs_fill_super<br />
open_ctree<br />
fail: btrfs_close_devices // -ENOMEM<br />
btrfs_close_bdev(btrfs_device_1)<br />
fput(btrfs_device_1->bdev_file)<br />
// btrfs_device_1->bdev_file is freed<br />
btrfs_close_bdev(btrfs_device_2)<br />
fput(btrfs_device_2->bdev_file)<br />
<br />
3. mount /dev/loop1 /mnt<br />
btrfs_open_devices<br />
btrfs_get_bdev_and_sb(&bdev_file)<br />
// EIO, btrfs_device_1->bdev_file is not assigned,<br />
// which points to a freed memory area<br />
btrfs_device_2->bdev_file = btrfs_get_bdev_and_sb(loop1)<br />
btrfs_fill_super<br />
open_ctree<br />
btrfs_free_extra_devids<br />
if (btrfs_device_1->bdev_file)<br />
fput(btrfs_device_1->bdev_file) // UAF !<br />
<br />
Fix it by setting &#39;device->bdev_file&#39; as &#39;NULL&#39; after closing the<br />
btrfs_device in btrfs_close_one_device().
Impact
Base Score 3.x
7.80
Severity 3.x
HIGH
Vulnerable products and versions
| CPE | From | Up to |
|---|---|---|
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.8 (including) | 6.11.7 (excluding) |
| cpe:2.3:o:linux:linux_kernel:6.12:rc1:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.12:rc2:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.12:rc3:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.12:rc4:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:6.12:rc5:*:*:*:*:*:* |
To consult the complete list of CPE names with products and versions, see this page
References to Advisories, Solutions, and Tools
- https://git.kernel.org/stable/c/47a83f8df39545f3f552bb6a1b6d9c30e37621dd
- https://git.kernel.org/stable/c/aec8e6bf839101784f3ef037dcdb9432c3f32343
- http://www.openwall.com/lists/oss-security/2025/04/10/4
- http://www.openwall.com/lists/oss-security/2025/04/10/5
- http://www.openwall.com/lists/oss-security/2025/04/10/6



