CVE-2023-54158 json
btrfs: don't free qgroup space unless specified
published 2025-12-24 10 mo ago modified 2026-06-17 4 mo ago also EUVD-2023-60287
- cvss
- —
- not scored
- cisa kev
- Not listed
- not in CISA's catalog
- epss
- 0.2%
- EPSS 0.2% chance of exploitation in 30 days, percentile 15%
- public exploits
- 0
- none known
Summary
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.
Patch / fix
- Linux Linux 5.4.243, 5.10.180, 5.15.112, 6.1.29, 6.2.16, 6.3.3, 6.4
- linux Debian 12 6.1.37-1
- linux Debian 14, Debian 13 6.3.7-1
debian advisories DEBIAN-CVE-2023-54158
- linux Ubuntu 20.04 LTS 5.4.0-162.179
- linux Ubuntu 22.04 LTS 5.15.0-83.92
- linux-aws Ubuntu 20.04 LTS 5.4.0-1109.118
- linux-aws Ubuntu 22.04 LTS 5.15.0-1044.49
- linux-gcp Ubuntu 20.04 LTS 5.4.0-1112.121
- linux-gcp Ubuntu 22.04 LTS 5.15.0-1041.49
- linux-gke Ubuntu 22.04 LTS 5.15.0-1041.46
- linux-ibm Ubuntu 20.04 LTS 5.4.0-1056.61
ubuntu advisories UBUNTU-CVE-2023-54158
Ubuntu security data © Canonical Ltd., from https://github.com/canonical/ubuntu-security-notices via OSV; changed: normalised to fixed package versions per release. CC BY-SA 4.0
- kernel-syms SLES LTSS Extended Security 12 SP5, SLES 12 SP5-LTSS 4.12.14-122.336.1
- kernel-source SLES LTSS Extended Security 12 SP5, SLES 12 SP5-LTSS 4.12.14-122.336.1
- kernel-default SLES LTSS Extended Security 12 SP5, SLES 12 SP5-LTSS, SLE Live Patching 12 SP5 4.12.14-122.336.1
- kgraft-patch-SLE12-SP5_Update_89 SLE Live Patching 12 SP5 1-8.3.1
suse advisories SUSE-SU-2026:4892-1
- git.kernel.org/stable/c/1e05bf5e80bb1161b7294c9ce5292b26232ab853 commit
- git.kernel.org/stable/c/148b16cd30b202999ec5b534e3e5d8ab4b766f21 commit
- git.kernel.org/stable/c/f264be24146bee2d652010a18ae2517df5856261 commit
- git.kernel.org/stable/c/15e877e5923ec6d6caa5e447dcc4b79a8ff7cc53 commit
- git.kernel.org/stable/c/04ff6bd0317735791ef3e443c7c89f3c0dda548d commit
- git.kernel.org/stable/c/478bd15f46b6e3aae78aac4f3788697f1546eea6 commit
- git.kernel.org/stable/c/d246331b78cbef86237f9c22389205bc9b4e1cc1 commit
Vendor advisories
What the vendors themselves say about their products: affected, fixed or not affected, and what to do.
red hat product security vex CVE-2023-54158 updated
kernel: btrfs: don't free qgroup space unless specified
-
Red Hat Enterprise Linux 6 perf, kernel, python-perf, kernel-kdump, kernel-firmware, kernel-bootwrapper, +1 more Red Hat Enterprise Linux 7 perf, kernel, bpftool, kernel-rt, python-perf, kernel-kdump, +8 more Red Hat Enterprise Linux 8 perf, kernel, bpftool, kernel-rt, kernel-core, kernel-tools, +29 more Red Hat Enterprise Linux 9 rv, perf, rtla, kernel, bpftool, libperf, +83 more Red Hat Enterprise Linux 10 kernelnot affected: vulnerable code not present
Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf
Exploit prediction
0.24% chance of exploitation in the next 30 days, higher than 15% of all scored CVEs (FIRST EPSS, 2026-11-08).
Affected products
- Linux Linux
Classification
- Technology feeds
References
- git.kernel.org /stable/c/1e05bf5e80bb1161b7294c9ce5292b26232ab853
- git.kernel.org /stable/c/148b16cd30b202999ec5b534e3e5d8ab4b766f21
- git.kernel.org /stable/c/f264be24146bee2d652010a18ae2517df5856261
- git.kernel.org /stable/c/15e877e5923ec6d6caa5e447dcc4b79a8ff7cc53
- git.kernel.org /stable/c/04ff6bd0317735791ef3e443c7c89f3c0dda548d
- git.kernel.org /stable/c/478bd15f46b6e3aae78aac4f3788697f1546eea6
- git.kernel.org /stable/c/d246331b78cbef86237f9c22389205bc9b4e1cc1
Sources
- CVE List CVE-2023-54158
- NVD CVE-2023-54158
Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.