CVE-2023-54158

btrfs: don't free qgroup space unless specified

No CVSS score yet EPSS 0.27%

Published 24 Dec 2025 Updated 11 May 2026 CNA: Linux

Check your servers for CVE-2023-54158

The Vulnpocalypse collector sends the package list of each Linux server and of its container images once a day. Vulnpocalypse shows every server where CVE-2023-54158 affects the running kernel, with the command that installs the fix. The free plan covers one server and one domain and does not need a credit card.

Check my servers

Description

In the Linux kernel, the following vulnerability has been resolved:

btrfs: don't free qgroup space unless specified

Boris noticed in his simple quotas testing that he was getting a leak with Sweet Tea's change to subvol create that stopped doing a transaction commit. This was just a side effect of that change.

In the delayed inode code we have an optimization that will free extra reservations if we think we can pack a dir item into an already modified leaf. Previously this wouldn't be triggered in the subvolume create case because we'd commit the transaction, it was still possible but much harder to trigger. It could actually be triggered if we did a mkdir && subvol create with qgroups enabled.

This occurs because in btrfs_insert_delayed_dir_index(), which gets called when we're adding the dir item, we do the following:

btrfs_block_rsv_release(fs_info, trans->block_rsv, bytes, NULL);

if we're able to skip reserving space.

The problem here is that trans->block_rsv points at the temporary block rsv for the subvolume create, which has qgroup reservations in the block rsv.

This is a problem because btrfs_block_rsv_release() will do the following:

if (block_rsv->qgroup_rsv_reserved >= block_rsv->qgroup_rsv_size) { qgroup_to_release = block_rsv->qgroup_rsv_reserved - block_rsv->qgroup_rsv_size; block_rsv->qgroup_rsv_reserved = block_rsv->qgroup_rsv_size; }

The temporary block rsv just has ->qgroup_rsv_reserved set, ->qgroup_rsv_size == 0. The optimization in btrfs_insert_delayed_dir_index() sets ->qgroup_rsv_reserved = 0. Then later on when we call btrfs_subvolume_release_metadata() which has

btrfs_block_rsv_release(fs_info, rsv, (u64)-1, &qgroup_to_release); btrfs_qgroup_convert_reserved_meta(root, qgroup_to_release);

qgroup_to_release is set to 0, and we do not convert the reserved metadata space.

The problem here is that the block rsv code has been unconditionally messing with ->qgroup_rsv_reserved, because the main place this is used is delalloc, and any time we call btrfs_block_rsv_release() we do it with qgroup_to_release set, and thus do the proper accounting.

The subvolume code is the only other code that uses the qgroup reservation stuff, but it's intermingled with the above optimization, and thus was getting its reservation freed out from underneath it and thus leaking the reserved space.

The solution is to simply not mess with the qgroup reservations if we don't have qgroup_to_release set. This works with the existing code as anything that messes with the delalloc reservations always have qgroup_to_release set. This fixes the leak that Boris was observing.

Exploitation

EPSS 0.27%: the probability of exploitation activity in the next 30 days, from the EPSS model of FIRST. The score is higher than 20.4% of all scored CVEs. Scores of 1 Dec 2026.

Affected products

As the CNA lists them.

ProductVersions
Linux
affected from ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, before 1e05bf5e80bb1161b7294c9ce5292b26232ab853
affected from ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, before 148b16cd30b202999ec5b534e3e5d8ab4b766f21
affected from ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, before f264be24146bee2d652010a18ae2517df5856261
affected from ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, before 15e877e5923ec6d6caa5e447dcc4b79a8ff7cc53
affected from ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, before 04ff6bd0317735791ef3e443c7c89f3c0dda548d
affected from ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, before 478bd15f46b6e3aae78aac4f3788697f1546eea6
affected from ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, before d246331b78cbef86237f9c22389205bc9b4e1cc1
Other versions: unaffected
Linux
affected 4.17
unaffected before 4.17
unaffected from 5.4.243 up to and including 5.4.*
unaffected from 5.10.180 up to and including 5.10.*
unaffected from 5.15.112 up to and including 5.15.*
unaffected from 6.1.29 up to and including 6.1.*
unaffected from 6.2.16 up to and including 6.2.*
unaffected from 6.3.3 up to and including 6.3.*
unaffected 6.4 and later
Other versions: affected

Is my server affected?

This CVE is in the Linux kernel. Compare the running kernel with the fixed kernel version of your distribution, and reboot after a kernel update:

uname -r
# Debian, Ubuntu: does the changelog of the running kernel name the CVE?
zgrep -l CVE-2023-54158 /usr/share/doc/linux-image-$(uname -r)/changelog.Debian.gz
# RHEL, Rocky, Alma
rpm -q --changelog kernel | grep CVE-2023-54158

With Trivy, on the host and for a container image. When a package is affected, it prints the installed and the fixed version:

trivy rootfs --scanners vuln / | grep CVE-2023-54158
trivy image --scanners vuln IMAGE | grep CVE-2023-54158

Vulnpocalypse makes this comparison every day for the package lists of your servers and container images, including language packages (npm, PyPI, Go, Maven and others), and sends the command that installs the fix. Start free with one server and one domain or read how to install the collector.

References

Other references

Source: the record CVE-2023-54158 of the CVE List (CVE Program), CVE Terms of Use; EPSS of FIRST. The text of the record is shown as published. Data sources and licences.