{"id":"CVE-2024-50217","aliases":["CVE-2024-50217"],"related":[],"kind":"vulnerability","state":"published","title":"btrfs: fix use-after-free of block device file in __btrfs_free_extra_devids()","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: fix use-after-free of block device file in __btrfs_free_extra_devids()\n\nMounting btrfs from two images (which have the same one fsid and two\ndifferent dev_uuids) in certain executing order may trigger an UAF for\nvariable 'device->bdev_file' in __btrfs_free_extra_devids(). And\nfollowing are the details:\n\n1. Attach image_1 to loop0, attach image_2 to loop1, and scan btrfs\n   devices by ioctl(BTRFS_IOC_SCAN_DEV):\n\n             /  btrfs_device_1 → loop0\n   fs_device\n             \\  btrfs_device_2 → loop1\n2. mount /dev/loop0 /mnt\n   btrfs_open_devices\n    btrfs_device_1->bdev_file = btrfs_get_bdev_and_sb(loop0)\n    btrfs_device_2->bdev_file = btrfs_get_bdev_and_sb(loop1)\n   btrfs_fill_super\n    open_ctree\n     fail: btrfs_close_devices // -ENOMEM\n\t    btrfs_close_bdev(btrfs_device_1)\n             fput(btrfs_device_1->bdev_file)\n\t      // btrfs_device_1->bdev_file is freed\n\t    btrfs_close_bdev(btrfs_device_2)\n             fput(btrfs_device_2->bdev_file)\n\n3. mount /dev/loop1 /mnt\n   btrfs_open_devices\n    btrfs_get_bdev_and_sb(&bdev_file)\n     // EIO, btrfs_device_1->bdev_file is not assigned,\n     // which points to a freed memory area\n    btrfs_device_2->bdev_file = btrfs_get_bdev_and_sb(loop1)\n   btrfs_fill_super\n    open_ctree\n     btrfs_free_extra_devids\n      if (btrfs_device_1->bdev_file)\n       fput(btrfs_device_1->bdev_file) // UAF !\n\nFix it by setting 'device->bdev_file' as 'NULL' after closing the\nbtrfs_device in btrfs_close_one_device().","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: fix use-after-free of block device file in __btrfs_free_extra_devids()\n\nMounting btrfs from two images (which have the same one fsid and two\ndifferent dev_uuids) in certain executing order may trigger an UAF for\nvariable 'device->bdev_file' in __btrfs_free_extra_devids(). And\nfollowing are the details:\n\n1. Attach image_1 to loop0, attach image_2 to loop1, and scan btrfs\n   devices by ioctl(BTRFS_IOC_SCAN_DEV):\n\n             /  btrfs_device_1 → loop0\n   fs_device\n             \\  btrfs_device_2 → loop1\n2. mount /dev/loop0 /mnt\n   btrfs_open_devices\n    btrfs_device_1->bdev_file = btrfs_get_bdev_and_sb(loop0)\n    btrfs_device_2->bdev_file = btrfs_get_bdev_and_sb(loop1)\n   btrfs_fill_super\n    open_ctree\n     fail: btrfs_close_devices // -ENOMEM\n\t    btrfs_close_bdev(btrfs_device_1)\n             fput(btrfs_device_1->bdev_file)\n\t      // btrfs_device_1->bdev_file is freed\n\t    btrfs_close_bdev(btrfs_device_2)\n             fput(btrfs_device_2->bdev_file)\n\n3. mount /dev/loop1 /mnt\n   btrfs_open_devices\n    btrfs_get_bdev_and_sb(&bdev_file)\n     // EIO, btrfs_device_1->bdev_file is not assigned,\n     // which points to a freed memory area\n    btrfs_device_2->bdev_file = btrfs_get_bdev_and_sb(loop1)\n   btrfs_fill_super\n    open_ctree\n     btrfs_free_extra_devids\n      if (btrfs_device_1->bdev_file)\n       fput(btrfs_device_1->bdev_file) // UAF !\n\nFix it by setting 'device->bdev_file' as 'NULL' after closing the\nbtrfs_device in btrfs_close_one_device().","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: btrfs: se corrige el use-after-free del archivo del dispositivo de bloque en __btrfs_free_extra_devids(). Montar btrfs desde dos imágenes (que tienen el mismo fsid y dos dev_uuids diferentes) en cierto orden de ejecución puede activar un UAF para la variable 'device-&gt;bdev_file' en __btrfs_free_extra_devids(). Y a continuación se muestran los detalles: 1. Adjunte image_1 a loop0, adjunte image_2 a loop1 y escanee los dispositivos btrfs con ioctl(BTRFS_IOC_SCAN_DEV): / btrfs_device_1 ? loop0 fs_device \\ btrfs_device_2 ? loop1 2. monte /dev/loop0 /mnt btrfs_open_devices btrfs_device_1-&gt;bdev_file = btrfs_get_bdev_and_sb(loop0) btrfs_device_2-&gt;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-&gt;bdev_file) // btrfs_device_1-&gt;bdev_file se libera btrfs_close_bdev(btrfs_device_2) fput(btrfs_device_2-&gt;bdev_file) 3. mount /dev/loop1 /mnt btrfs_open_devices btrfs_get_bdev_and_sb(&amp;bdev_file) // EIO, btrfs_device_1-&gt;bdev_file no está asignado, // lo que apunta a un área de memoria liberada btrfs_device_2-&gt;bdev_file = btrfs_get_bdev_and_sb(loop1) btrfs_fill_super open_ctree btrfs_free_extra_devids if (btrfs_device_1-&gt;bdev_file) fput(btrfs_device_1-&gt;bdev_file) // UAF! Arréglelo configurando 'device-&gt;bdev_file' como 'NULL' después de cerrar btrfs_device en btrfs_close_one_device().","source":"nvd"}],"published":"2024-11-09T10:14:28.798Z","modified":"2026-08-05T11:42:34.683Z","severity":{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"}],"cwes":["CWE-416"],"affected":[{"ranges":[{"type":"git","introduced":"142388194191a3edc9ba01cfcfd8b691e0971fb2","fixed":"47a83f8df39545f3f552bb6a1b6d9c30e37621dd","status":"affected"},{"type":"git","introduced":"142388194191a3edc9ba01cfcfd8b691e0971fb2","fixed":"aec8e6bf839101784f3ef037dcdb9432c3f32343","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"4.8","status":"affected"},{"type":"semver","introduced":"0","fixed":"4.8","status":"unaffected"},{"type":"semver","introduced":"6.11.7","lastAffected":"6.11.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.12","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"4.8","fixed":"6.11.7"},{"status":"affected","version":"6.12"},{"status":"affected","version":"6.12"},{"status":"affected","version":"6.12"},{"status":"affected","version":"6.12"},{"status":"affected","version":"6.12"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/47a83f8df39545f3f552bb6a1b6d9c30e37621dd","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/aec8e6bf839101784f3ef037dcdb9432c3f32343","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"http://www.openwall.com/lists/oss-security/2025/04/10/4","tags":[],"sources":["cvelist","nvd"]},{"url":"http://www.openwall.com/lists/oss-security/2025/04/10/5","tags":[],"sources":["cvelist","nvd"]},{"url":"http://www.openwall.com/lists/oss-security/2025/04/10/6","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2024-12-11T14:25:44.077Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-50217","url":"https://www.cve.org/CVERecord?id=CVE-2024-50217","licence":"CVE Terms of Use","modified":"2026-08-05T11:42:34.683Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-50217","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-50217","licence":"Public domain","modified":"2026-08-04T11:21:33.953Z"}],"updatedAt":"2026-11-25T22:58:47.961Z","epss":{"score":0.00278,"percentile":0.21719,"date":"2026-12-01T12:00:22.000Z"}}