{"id":"CVE-2022-48733","aliases":["CVE-2022-48733"],"related":[],"kind":"vulnerability","state":"published","title":"btrfs: fix use-after-free after failure to create a snapshot","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: fix use-after-free after failure to create a snapshot\n\nAt ioctl.c:create_snapshot(), we allocate a pending snapshot structure and\nthen attach it to the transaction's list of pending snapshots. After that\nwe call btrfs_commit_transaction(), and if that returns an error we jump\nto 'fail' label, where we kfree() the pending snapshot structure. This can\nresult in a later use-after-free of the pending snapshot:\n\n1) We allocated the pending snapshot and added it to the transaction's\n   list of pending snapshots;\n\n2) We call btrfs_commit_transaction(), and it fails either at the first\n   call to btrfs_run_delayed_refs() or btrfs_start_dirty_block_groups().\n   In both cases, we don't abort the transaction and we release our\n   transaction handle. We jump to the 'fail' label and free the pending\n   snapshot structure. We return with the pending snapshot still in the\n   transaction's list;\n\n3) Another task commits the transaction. This time there's no error at\n   all, and then during the transaction commit it accesses a pointer\n   to the pending snapshot structure that the snapshot creation task\n   has already freed, resulting in a user-after-free.\n\nThis issue could actually be detected by smatch, which produced the\nfollowing warning:\n\n  fs/btrfs/ioctl.c:843 create_snapshot() warn: '&pending_snapshot->list' not removed from list\n\nSo fix this by not having the snapshot creation ioctl directly add the\npending snapshot to the transaction's list. Instead add the pending\nsnapshot to the transaction handle, and then at btrfs_commit_transaction()\nwe add the snapshot to the list only when we can guarantee that any error\nreturned after that point will result in a transaction abort, in which\ncase the ioctl code can safely free the pending snapshot and no one can\naccess it anymore.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: fix use-after-free after failure to create a snapshot\n\nAt ioctl.c:create_snapshot(), we allocate a pending snapshot structure and\nthen attach it to the transaction's list of pending snapshots. After that\nwe call btrfs_commit_transaction(), and if that returns an error we jump\nto 'fail' label, where we kfree() the pending snapshot structure. This can\nresult in a later use-after-free of the pending snapshot:\n\n1) We allocated the pending snapshot and added it to the transaction's\n   list of pending snapshots;\n\n2) We call btrfs_commit_transaction(), and it fails either at the first\n   call to btrfs_run_delayed_refs() or btrfs_start_dirty_block_groups().\n   In both cases, we don't abort the transaction and we release our\n   transaction handle. We jump to the 'fail' label and free the pending\n   snapshot structure. We return with the pending snapshot still in the\n   transaction's list;\n\n3) Another task commits the transaction. This time there's no error at\n   all, and then during the transaction commit it accesses a pointer\n   to the pending snapshot structure that the snapshot creation task\n   has already freed, resulting in a user-after-free.\n\nThis issue could actually be detected by smatch, which produced the\nfollowing warning:\n\n  fs/btrfs/ioctl.c:843 create_snapshot() warn: '&pending_snapshot->list' not removed from list\n\nSo fix this by not having the snapshot creation ioctl directly add the\npending snapshot to the transaction's list. Instead add the pending\nsnapshot to the transaction handle, and then at btrfs_commit_transaction()\nwe add the snapshot to the list only when we can guarantee that any error\nreturned after that point will result in a transaction abort, in which\ncase the ioctl code can safely free the pending snapshot and no one can\naccess it anymore.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, se resolvió la siguiente vulnerabilidad: btrfs: corrige el use-after-free después de una falla al crear una instantánea En ioctl.c:create_snapshot(), asignamos una estructura de instantánea pendiente y luego la adjuntamos a la lista de transacciones de instantáneas pendientes. Después de eso, llamamos a btrfs_commit_transaction(), y si eso devuelve un error, saltamos a la etiqueta 'falla', donde liberamos() la estructura de instantánea pendiente. Esto puede resultar en un uso posterior después de la liberación de la instantánea pendiente: 1) Asignamos la instantánea pendiente y la agregamos a la lista de instantáneas pendientes de la transacción; 2) Llamamos a btrfs_commit_transaction(), y falla en la primera llamada a btrfs_run_delayed_refs() o btrfs_start_dirty_block_groups(). En ambos casos, no abortamos la transacción y liberamos nuestro identificador de transacción. Saltamos a la etiqueta 'fallo' y liberamos la estructura de instantánea pendiente. Regresamos con la instantánea pendiente todavía en la lista de transacciones; 3) Otra tarea confirma la transacción. Esta vez no hay ningún error y luego, durante la confirmación de la transacción, accede a un puntero a la estructura de instantánea pendiente que la tarea de creación de instantánea ya ha liberado, lo que resulta en una liberación de usuario. En realidad, este problema podría ser detectado por smatch, que produjo la siguiente advertencia: fs/btrfs/ioctl.c:843 create_snapshot() advertencia: '&amp;pending_snapshot-&gt;list' no se elimina de la lista. Así que solucione este problema al no tener el ioctl de creación de instantáneas directamente agregue la instantánea pendiente a la lista de transacciones. En su lugar, agregue la instantánea pendiente al identificador de la transacción, y luego en btrfs_commit_transaction() agregamos la instantánea a la lista solo cuando podamos garantizar que cualquier error devuelto después de ese punto resultará en la cancelación de la transacción, en cuyo caso el código ioctl puede Libera la instantánea pendiente y ya nadie podrá acceder a ella.","source":"nvd"}],"published":"2024-06-20T11:13:20.737Z","modified":"2026-08-05T08:52:01.350Z","severity":{"scorer":"Linux","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"},"severities":[{"scorer":"Linux","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":"c37b2b6269ee4637fb7cdb5da0d1e47215d57ce2","fixed":"7e4c72dbaf62f8978af8321a24dbd35566d3a78a","status":"affected"},{"type":"git","introduced":"c37b2b6269ee4637fb7cdb5da0d1e47215d57ce2","fixed":"a7b717fa15165d3d9245614680bebc48a52ac05d","status":"affected"},{"type":"git","introduced":"c37b2b6269ee4637fb7cdb5da0d1e47215d57ce2","fixed":"9372fa1d73da5f1673921e365d0cd2c27ec7adc2","status":"affected"},{"type":"git","introduced":"c37b2b6269ee4637fb7cdb5da0d1e47215d57ce2","fixed":"28b21c558a3753171097193b6f6602a94169093a","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"3.7","status":"affected"},{"type":"semver","introduced":"0","fixed":"3.7","status":"unaffected"},{"type":"semver","introduced":"5.10.226","lastAffected":"5.10.*","status":"unaffected"},{"type":"semver","introduced":"5.15.22","lastAffected":"5.15.*","status":"unaffected"},{"type":"semver","introduced":"5.16.8","lastAffected":"5.16.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"5.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","fixed":"5.10.226"},{"status":"affected","introduced":"5.11","fixed":"5.15.22"},{"status":"affected","introduced":"5.16","fixed":"5.16.8"},{"status":"affected","version":"5.17"},{"status":"affected","version":"5.17"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/7e4c72dbaf62f8978af8321a24dbd35566d3a78a","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/a7b717fa15165d3d9245614680bebc48a52ac05d","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/9372fa1d73da5f1673921e365d0cd2c27ec7adc2","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/28b21c558a3753171097193b6f6602a94169093a","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2024/10/msg00003.html","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-09-10T17:10:54.149Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-48733","url":"https://www.cve.org/CVERecord?id=CVE-2022-48733","licence":"CVE Terms of Use","modified":"2026-08-05T08:52:01.350Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-48733","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-48733","licence":"Public domain","modified":"2026-08-04T10:17:18.320Z"}],"updatedAt":"2026-11-25T22:58:19.841Z","epss":{"score":0.0023,"percentile":0.14806,"date":"2026-12-01T12:00:22.000Z"}}