CVE-2022-48733

In the Linux kernel, the following vulnerability has been resolved: btrfs: fix use-after-free after failure to create a snapshot At ioctl.c:create_snapshot(), we allocate a pending snapshot structure and then attach it to the transaction's list of pending snapshots. After that we call btrfs_commit_transaction(), and if that returns an error we jump to 'fail' label, where we kfree() the pending snapshot structure. This can result in a later use-after-free of the pending snapshot: 1) We allocated the pending snapshot and added it to the transaction's list of pending snapshots; 2) We call btrfs_commit_transaction(), and it fails either at the first call to btrfs_run_delayed_refs() or btrfs_start_dirty_block_groups(). In both cases, we don't abort the transaction and we release our transaction handle. We jump to the 'fail' label and free the pending snapshot structure. We return with the pending snapshot still in the transaction's list; 3) Another task commits the transaction. This time there's no error at all, and then during the transaction commit it accesses a pointer to the pending snapshot structure that the snapshot creation task has already freed, resulting in a user-after-free. This issue could actually be detected by smatch, which produced the following warning: fs/btrfs/ioctl.c:843 create_snapshot() warn: '&pending_snapshot->list' not removed from list So fix this by not having the snapshot creation ioctl directly add the pending snapshot to the transaction's list. Instead add the pending snapshot to the transaction handle, and then at btrfs_commit_transaction() we add the snapshot to the list only when we can guarantee that any error returned after that point will result in a transaction abort, in which case the ioctl code can safely free the pending snapshot and no one can access it anymore.
Configurations

Configuration 1 (hide)

OR cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*

History

12 Sep 2024, 12:15

Type Values Removed Values Added
References
  • () https://git.kernel.org/stable/c/7e4c72dbaf62f8978af8321a24dbd35566d3a78a -

19 Aug 2024, 17:39

Type Values Removed Values Added
References () https://git.kernel.org/stable/c/28b21c558a3753171097193b6f6602a94169093a - () https://git.kernel.org/stable/c/28b21c558a3753171097193b6f6602a94169093a - Patch
References () https://git.kernel.org/stable/c/9372fa1d73da5f1673921e365d0cd2c27ec7adc2 - () https://git.kernel.org/stable/c/9372fa1d73da5f1673921e365d0cd2c27ec7adc2 - Patch
References () https://git.kernel.org/stable/c/a7b717fa15165d3d9245614680bebc48a52ac05d - () https://git.kernel.org/stable/c/a7b717fa15165d3d9245614680bebc48a52ac05d - Patch
Summary
  • (es) 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: '&pending_snapshot->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.
CWE CWE-416
CVSS v2 : unknown
v3 : unknown
v2 : unknown
v3 : 7.8
CPE cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
First Time Linux
Linux linux Kernel

20 Jun 2024, 12:15

Type Values Removed Values Added
New CVE

Information

Published : 2024-06-20 12:15

Updated : 2024-09-12 12:15


NVD link : CVE-2022-48733

Mitre link : CVE-2022-48733

CVE.ORG link : CVE-2022-48733


JSON object : View

Products Affected

linux

  • linux_kernel
CWE
CWE-416

Use After Free