btrfs: fix qgroup reserve overflow the qgroup limit
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 7bc329c1836866ffac8b2613f780a51b3ffe786d · < 6bfff81286d4491f02dad7814bae5c77c9ad2320| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
btrfs: fix qgroup reserve overflow the qgroup limit
We use extent_changeset->bytes_changed in qgroup_reserve_data() to record how many bytes we set for EXTENT_QGROUP_RESERVED state. Currently the bytes_changed is set as "unsigned int", and it will overflow if we try to fallocate a range larger than 4GiB. The result is we reserve less bytes and eventually break the qgroup limit.
Unlike regular buffered/direct write, which we use one changeset for each ordered extent, which can never be larger than 256M. For fallocate, we use one changeset for the whole range, thus it no longer respects the 256M per extent limit, and caused the problem.
The following example test script reproduces the problem:
$ cat qgroup-overflow.sh #!/bin/bash
DEV=/dev/sdj MNT=/mnt/sdj
mkfs.btrfs -f $DEV mount $DEV $MNT
From the CVE record · Linux
In the Linux kernel, a byte counter can overflow when fallocate reserves a btrfs range larger than 4 GiB. A user able to allocate files on a btrfs filesystem with qgroup limits enabled can exceed those limits; this requires local filesystem access, with no additional user interaction described.
Check Linux kernel installations using btrfs filesystems with qgroup limits enabled; affected versions are not specified.