CVE-2022-48733
Severity CVSS v4.0:
Pending analysis
Type:
CWE-416
Use After Free
Publication date:
20/06/2024
Last modified:
03/11/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
btrfs: fix use-after-free after failure to create a snapshot<br />
<br />
At ioctl.c:create_snapshot(), we allocate a pending snapshot structure and<br />
then attach it to the transaction&#39;s list of pending snapshots. After that<br />
we call btrfs_commit_transaction(), and if that returns an error we jump<br />
to &#39;fail&#39; label, where we kfree() the pending snapshot structure. This can<br />
result in a later use-after-free of the pending snapshot:<br />
<br />
1) We allocated the pending snapshot and added it to the transaction&#39;s<br />
list of pending snapshots;<br />
<br />
2) We call btrfs_commit_transaction(), and it fails either at the first<br />
call to btrfs_run_delayed_refs() or btrfs_start_dirty_block_groups().<br />
In both cases, we don&#39;t abort the transaction and we release our<br />
transaction handle. We jump to the &#39;fail&#39; label and free the pending<br />
snapshot structure. We return with the pending snapshot still in the<br />
transaction&#39;s list;<br />
<br />
3) Another task commits the transaction. This time there&#39;s no error at<br />
all, and then during the transaction commit it accesses a pointer<br />
to the pending snapshot structure that the snapshot creation task<br />
has already freed, resulting in a user-after-free.<br />
<br />
This issue could actually be detected by smatch, which produced the<br />
following warning:<br />
<br />
fs/btrfs/ioctl.c:843 create_snapshot() warn: &#39;&pending_snapshot->list&#39; not removed from list<br />
<br />
So fix this by not having the snapshot creation ioctl directly add the<br />
pending snapshot to the transaction&#39;s list. Instead add the pending<br />
snapshot to the transaction handle, and then at btrfs_commit_transaction()<br />
we add the snapshot to the list only when we can guarantee that any error<br />
returned after that point will result in a transaction abort, in which<br />
case the ioctl code can safely free the pending snapshot and no one can<br />
access it anymore.
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:*:*:*:*:*:*:*:* | 5.10.226 (excluding) | |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.11 (including) | 5.15.22 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.16 (including) | 5.16.8 (excluding) |
| cpe:2.3:o:linux:linux_kernel:5.17:rc1:*:*:*:*:*:* | ||
| cpe:2.3:o:linux:linux_kernel:5.17:rc2:*:*:*:*:*:* |
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/28b21c558a3753171097193b6f6602a94169093a
- https://git.kernel.org/stable/c/7e4c72dbaf62f8978af8321a24dbd35566d3a78a
- https://git.kernel.org/stable/c/9372fa1d73da5f1673921e365d0cd2c27ec7adc2
- https://git.kernel.org/stable/c/a7b717fa15165d3d9245614680bebc48a52ac05d
- https://git.kernel.org/stable/c/28b21c558a3753171097193b6f6602a94169093a
- https://git.kernel.org/stable/c/9372fa1d73da5f1673921e365d0cd2c27ec7adc2
- https://git.kernel.org/stable/c/a7b717fa15165d3d9245614680bebc48a52ac05d
- https://lists.debian.org/debian-lts-announce/2024/10/msg00003.html



