{"id":"CVE-2025-39759","aliases":["CVE-2025-39759"],"related":[],"kind":"vulnerability","state":"published","title":"btrfs: qgroup: fix race between quota disable and quota rescan ioctl","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: qgroup: fix race between quota disable and quota rescan ioctl\n\nThere's a race between a task disabling quotas and another running the\nrescan ioctl that can result in a use-after-free of qgroup records from\nthe fs_info->qgroup_tree rbtree.\n\nThis happens as follows:\n\n1) Task A enters btrfs_ioctl_quota_rescan() -> btrfs_qgroup_rescan();\n\n2) Task B enters btrfs_quota_disable() and calls\n   btrfs_qgroup_wait_for_completion(), which does nothing because at that\n   point fs_info->qgroup_rescan_running is false (it wasn't set yet by\n   task A);\n\n3) Task B calls btrfs_free_qgroup_config() which starts freeing qgroups\n   from fs_info->qgroup_tree without taking the lock fs_info->qgroup_lock;\n\n4) Task A enters qgroup_rescan_zero_tracking() which starts iterating\n   the fs_info->qgroup_tree tree while holding fs_info->qgroup_lock,\n   but task B is freeing qgroup records from that tree without holding\n   the lock, resulting in a use-after-free.\n\nFix this by taking fs_info->qgroup_lock at btrfs_free_qgroup_config().\nAlso at btrfs_qgroup_rescan() don't start the rescan worker if quotas\nwere already disabled.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: qgroup: fix race between quota disable and quota rescan ioctl\n\nThere's a race between a task disabling quotas and another running the\nrescan ioctl that can result in a use-after-free of qgroup records from\nthe fs_info->qgroup_tree rbtree.\n\nThis happens as follows:\n\n1) Task A enters btrfs_ioctl_quota_rescan() -> btrfs_qgroup_rescan();\n\n2) Task B enters btrfs_quota_disable() and calls\n   btrfs_qgroup_wait_for_completion(), which does nothing because at that\n   point fs_info->qgroup_rescan_running is false (it wasn't set yet by\n   task A);\n\n3) Task B calls btrfs_free_qgroup_config() which starts freeing qgroups\n   from fs_info->qgroup_tree without taking the lock fs_info->qgroup_lock;\n\n4) Task A enters qgroup_rescan_zero_tracking() which starts iterating\n   the fs_info->qgroup_tree tree while holding fs_info->qgroup_lock,\n   but task B is freeing qgroup records from that tree without holding\n   the lock, resulting in a use-after-free.\n\nFix this by taking fs_info->qgroup_lock at btrfs_free_qgroup_config().\nAlso at btrfs_qgroup_rescan() don't start the rescan worker if quotas\nwere already disabled.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nbtrfs: qgroup: solucionar condición de carrera entre la desactivación de cuotas y el ioctl de reescaneo de cuotas\n\nExiste una condición de carrera entre una tarea que desactiva las cuotas y otra que ejecuta el ioctl de reescaneo que puede resultar en un uso después de liberación de registros de qgroup del rbtree fs_info->qgroup_tree.\n\nEsto ocurre de la siguiente manera:\n\n1) La Tarea A entra en btrfs_ioctl_quota_rescan() -> btrfs_qgroup_rescan();\n\n2) La Tarea B entra en btrfs_quota_disable() y llama a btrfs_qgroup_wait_for_completion(), lo cual no hace nada porque en ese momento fs_info->qgroup_rescan_running es falso (aún no había sido establecido por la Tarea A);\n\n3) La Tarea B llama a btrfs_free_qgroup_config() que comienza a liberar qgroups del fs_info->qgroup_tree sin tomar el bloqueo fs_info->qgroup_lock;\n\n4) La Tarea A entra en qgroup_rescan_zero_tracking() que comienza a iterar el árbol fs_info->qgroup_tree mientras mantiene el fs_info->qgroup_lock, pero la Tarea B está liberando registros de qgroup de ese árbol sin mantener el bloqueo, resultando en un uso después de liberación.\n\nSolucione esto tomando fs_info->qgroup_lock en btrfs_free_qgroup_config(). También en btrfs_qgroup_rescan() no inicie el trabajador de reescaneo si las cuotas ya estaban desactivadas.","source":"nvd"}],"published":"2025-09-11T16:52:28.314Z","modified":"2026-10-19T21:10:00.160Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7,"rating":"HIGH"},"severities":[{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7,"rating":"HIGH"}],"cwes":["CWE-362"],"affected":[{"ranges":[{"type":"git","introduced":"e685da14af6b31e4b336a110cb1bae1afc268be8","fixed":"7cda0fdde5d9890976861421d207870500f9aace","status":"affected"},{"type":"git","introduced":"e685da14af6b31e4b336a110cb1bae1afc268be8","fixed":"b172535ccba12f0cf7d23b3b840989de47fc104d","status":"affected"},{"type":"git","introduced":"e685da14af6b31e4b336a110cb1bae1afc268be8","fixed":"dd0b28d877b293b1d7f8727a7de08ae36b6b9ef0","status":"affected"},{"type":"git","introduced":"e685da14af6b31e4b336a110cb1bae1afc268be8","fixed":"c38028ce0d0045ca600b6a8345a0ff92bfb47b66","status":"affected"},{"type":"git","introduced":"e685da14af6b31e4b336a110cb1bae1afc268be8","fixed":"2fd0f5ceb997f90f4332ccbab6c7e907e6b2d0eb","status":"affected"},{"type":"git","introduced":"e685da14af6b31e4b336a110cb1bae1afc268be8","fixed":"e1249667750399a48cafcf5945761d39fa584edf","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"3.12","status":"affected"},{"type":"semver","introduced":"0","fixed":"3.12","status":"unaffected"},{"type":"semver","introduced":"6.1.149","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.103","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.44","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.15.11","lastAffected":"6.15.*","status":"unaffected"},{"type":"semver","introduced":"6.16.2","lastAffected":"6.16.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.17","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":"3.12","fixed":"6.1.149"},{"status":"affected","introduced":"6.2","fixed":"6.6.103"},{"status":"affected","introduced":"6.7","fixed":"6.12.44"},{"status":"affected","introduced":"6.13","fixed":"6.15.11"},{"status":"affected","introduced":"6.16","fixed":"6.16.2"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"status":"affected","version":"11.0"}],"vendor":"debian","product":"debian_linux","cpe":"cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/7cda0fdde5d9890976861421d207870500f9aace","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/b172535ccba12f0cf7d23b3b840989de47fc104d","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/dd0b28d877b293b1d7f8727a7de08ae36b6b9ef0","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/c38028ce0d0045ca600b6a8345a0ff92bfb47b66","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/2fd0f5ceb997f90f4332ccbab6c7e907e6b2d0eb","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/e1249667750399a48cafcf5945761d39fa584edf","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2025/10/msg00008.html","tags":["mailing-list","third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://cert-portal.siemens.com/productcert/html/ssa-032379.html","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-39759","url":"https://www.cve.org/CVERecord?id=CVE-2025-39759","licence":"CVE Terms of Use","modified":"2026-05-12T12:06:49.038Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-39759","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-39759","licence":"Public domain","modified":"2026-10-19T21:10:00.160Z"}],"updatedAt":"2026-11-25T22:59:04.552Z","epss":{"score":0.00123,"percentile":0.02225,"date":"2026-12-01T12:00:22.000Z"}}