CVE-2022-48733·Kernel vulnerability
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.
- Severity
- high
- Software
- Kernel
- Fixed in
- 5.16.8
- Published
- 2024-06-20
Affected versions
From: 5.16
Until: 5.16.8
Fixed in: 5.16.8
How to fix this CVE
Update your Linux kernel to version 5.16.8 or later to resolve a use-after-free vulnerability in the Btrfs snapshot creation code. This vulnerability occurs when snapshot creation fails and improperly frees memory structures that remain referenced by active transactions. Apply the patch immediately to systems running vulnerable kernel versions 5.16.0 through 5.16.7.
sudo dnf update kernel kernel-develDefensia detects this vulnerability
How to check if you are affected
- Run 'uname -r' to check your current kernel version. If it returns 5.16.0 through 5.16.7, your system is vulnerable.
- Execute 'grep -i btrfs /proc/filesystems' to verify if Btrfs is enabled on your system; if present, snapshot functionality is available.
- Search kernel logs with 'dmesg | grep -i "use.after.free\|btrfs\|snapshot"' for memory corruption or snapshot-related errors.
- After patching, run 'uname -r' again to confirm the kernel version is 5.16.8 or later, then reboot if necessary.
FAQ
What is CVE-2022-48733?
CVE-2022-48733 is a use-after-free vulnerability in the Linux kernel's Btrfs filesystem implementation. When snapshot creation fails during a transaction commit, the pending snapshot structure is freed prematurely but remains attached to the transaction list, allowing concurrent operations to access freed memory.
Is CVE-2022-48733 being actively exploited?
No, CVE-2022-48733 is not listed in CISA's Known Exploited Vulnerabilities catalog and has no public exploit available. However, the high CVSS score (7.8) indicates significant risk if local attackers can trigger failed snapshot operations.
What versions of Kernel are affected by CVE-2022-48733?
Linux kernel versions 5.16.0 through 5.16.7 are affected. The vulnerability was fixed in version 5.16.8.
How do I check if my server is vulnerable to CVE-2022-48733?
Run 'uname -r' and check if the output is between 5.16.0 and 5.16.7. If so, your system is vulnerable. Also verify Btrfs is in use with 'grep btrfs /proc/filesystems' or 'df -T | grep btrfs'.
Does Defensia detect CVE-2022-48733?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If the Linux kernel is installed on a monitored server, CVE-2022-48733 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- 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
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2022-48733. Free for 1 server.
Get started free