CVE-2022-49075
Severity CVSS v4.0:
Pending analysis
Type:
CWE-190
Integer Overflow or Wraparound
Publication date:
26/02/2025
Last modified:
23/09/2025
Description
In the Linux kernel, the following vulnerability has been resolved:<br />
<br />
btrfs: fix qgroup reserve overflow the qgroup limit<br />
<br />
We use extent_changeset->bytes_changed in qgroup_reserve_data() to record<br />
how many bytes we set for EXTENT_QGROUP_RESERVED state. Currently the<br />
bytes_changed is set as "unsigned int", and it will overflow if we try to<br />
fallocate a range larger than 4GiB. The result is we reserve less bytes<br />
and eventually break the qgroup limit.<br />
<br />
Unlike regular buffered/direct write, which we use one changeset for<br />
each ordered extent, which can never be larger than 256M. For<br />
fallocate, we use one changeset for the whole range, thus it no longer<br />
respects the 256M per extent limit, and caused the problem.<br />
<br />
The following example test script reproduces the problem:<br />
<br />
$ cat qgroup-overflow.sh<br />
#!/bin/bash<br />
<br />
DEV=/dev/sdj<br />
MNT=/mnt/sdj<br />
<br />
mkfs.btrfs -f $DEV<br />
mount $DEV $MNT<br />
<br />
# Set qgroup limit to 2GiB.<br />
btrfs quota enable $MNT<br />
btrfs qgroup limit 2G $MNT<br />
<br />
# Try to fallocate a 3GiB file. This should fail.<br />
echo<br />
echo "Try to fallocate a 3GiB file..."<br />
fallocate -l 3G $MNT/3G.file<br />
<br />
# Try to fallocate a 5GiB file.<br />
echo<br />
echo "Try to fallocate a 5GiB file..."<br />
fallocate -l 5G $MNT/5G.file<br />
<br />
# See we break the qgroup limit.<br />
echo<br />
sync<br />
btrfs qgroup show -r $MNT<br />
<br />
umount $MNT<br />
<br />
When running the test:<br />
<br />
$ ./qgroup-overflow.sh<br />
(...)<br />
<br />
Try to fallocate a 3GiB file...<br />
fallocate: fallocate failed: Disk quota exceeded<br />
<br />
Try to fallocate a 5GiB file...<br />
<br />
qgroupid rfer excl max_rfer<br />
-------- ---- ---- --------<br />
0/5 5.00GiB 5.00GiB 2.00GiB<br />
<br />
Since we have no control of how bytes_changed is used, it&#39;s better to<br />
set it to u64.
Impact
Base Score 3.x
5.50
Severity 3.x
MEDIUM
Vulnerable products and versions
| CPE | From | Up to |
|---|---|---|
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.14.276 (excluding) | |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.15 (including) | 4.19.238 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 4.20 (including) | 5.4.189 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.5 (including) | 5.10.111 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.11 (including) | 5.15.34 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.16 (including) | 5.16.20 (excluding) |
| cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* | 5.17 (including) | 5.17.3 (excluding) |
| cpe:2.3:o:linux:linux_kernel:5.18:rc1:*:*:*:*:*:* |
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/0355387ea5b02d353c9415613fab908fac5c52a6
- https://git.kernel.org/stable/c/44277c50fdba5019ca25bfad1b71e2561b0de11b
- https://git.kernel.org/stable/c/4b98799e181b4326a613108cf37acc1f55d21b45
- https://git.kernel.org/stable/c/6bfff81286d4491f02dad7814bae5c77c9ad2320
- https://git.kernel.org/stable/c/7941b74ed49b6db25efbef2256ebef843c11a010
- https://git.kernel.org/stable/c/82ae73ac963cee877ce34f7c31b2b456b516e96c
- https://git.kernel.org/stable/c/b642b52d0b50f4d398cb4293f64992d0eed2e2ce
- https://git.kernel.org/stable/c/f3d97b22a708bf9e3f3ac2ba232bcefd0b0c136b



