Skip to content
OpenAdvisories
Unscored CVE-2023-54158 EUVD-2023-60287GHSA-crmq-c99h-f986

btrfs: don't free qgroup space unless specified

Published Dec 24, 2025 · Updated May 11, 2026 · Assigned by Linux

Vendor: Linux Product: Linux Package: linux Package: linux Package: linux-allwinner-5.19 Package: linux-aws Package: linux-aws-5.0 Package: linux-aws-5.11 Package: linux-aws-5.13 Package: linux-aws-5.15 Package: linux-aws-5.19 Package: linux-aws-5.3 Package: linux-aws-5.4 Package: linux-aws-5.8 Package: linux-aws-6.2 Package: linux-aws-6.5 Package: linux-aws-fips Package: linux-azure Package: linux-azure-5.11 Package: linux-azure-5.13 Package: linux-azure-5.15 Package: linux-azure-5.19 Package: linux-azure-5.3 Package: linux-azure-5.4 Package: linux-azure-5.8 Package: linux-azure-6.11 Package: linux-azure-6.2 Package: linux-azure-6.5 Package: linux-azure-edge Package: linux-azure-fde Package: linux-azure-fde-5.19 Package: linux-azure-fde-6.2 Package: linux-azure-fips Package: linux-bluefield Package: linux-fips Package: linux-gcp Package: linux-gcp-5.11 Package: linux-gcp-5.13 Package: linux-gcp-5.15 Package: linux-gcp-5.19 Package: linux-gcp-5.3 Package: linux-gcp-5.4 Package: linux-gcp-5.8 Package: linux-gcp-6.11 Package: linux-gcp-6.2 Package: linux-gcp-6.5 Package: linux-gcp-fips Package: linux-gke Package: linux-gke-4.15 Package: linux-gke-5.15 Package: linux-gke-5.4 Package: linux-gkeop Package: linux-gkeop-5.15 Package: linux-gkeop-5.4 Package: linux-hwe Package: linux-hwe-5.11 Package: linux-hwe-5.13 Package: linux-hwe-5.15 Package: linux-hwe-5.19 Package: linux-hwe-5.4 Package: linux-hwe-5.8 Package: linux-hwe-6.11 Package: linux-hwe-6.2 Package: linux-hwe-6.5 Package: linux-hwe-edge Package: linux-ibm Package: linux-ibm-5.15 Package: linux-ibm-5.4 Package: linux-intel-5.13 Package: linux-intel-iot-realtime Package: linux-intel-iotg Package: linux-intel-iotg-5.15 Package: linux-iot Package: linux-kvm Package: linux-lowlatency Package: linux-lowlatency-hwe-5.15 Package: linux-lowlatency-hwe-5.19 Package: linux-lowlatency-hwe-6.11 Package: linux-lowlatency-hwe-6.2 Package: linux-lowlatency-hwe-6.5 Package: linux-nvidia Package: linux-nvidia-6.11 Package: linux-nvidia-6.2 Package: linux-nvidia-6.5 Package: linux-nvidia-tegra Package: linux-nvidia-tegra-5.15 Package: linux-nvidia-tegra-igx Package: linux-oem Package: linux-oem-5.10 Package: linux-oem-5.13 Package: linux-oem-5.14 Package: linux-oem-5.17 Package: linux-oem-5.6 Package: linux-oem-6.0 Package: linux-oem-6.1 Package: linux-oem-6.11 Package: linux-oem-6.5 Package: linux-oem-6.8 Package: linux-oracle Package: linux-oracle-5.0 Package: linux-oracle-5.11 Package: linux-oracle-5.13 Package: linux-oracle-5.15 Package: linux-oracle-5.3 Package: linux-oracle-5.4 Package: linux-oracle-5.8 Package: linux-oracle-6.5 Package: linux-raspi Package: linux-raspi-5.4 Package: linux-raspi-realtime Package: linux-raspi2 Package: linux-realtime Package: linux-riscv Package: linux-riscv-5.11 Package: linux-riscv-5.15 Package: linux-riscv-5.19 Package: linux-riscv-5.8 Package: linux-riscv-6.14 Package: linux-riscv-6.5 Package: linux-starfive-5.19 Package: linux-starfive-6.2 Package: linux-starfive-6.5 Package: linux-vmware Package: linux-xilinx-zynqmp Platform: Linux Ecosystem: Debian Ecosystem: Ubuntu

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.

Affected products

VendorProductAffectedFixed
Linux Linux 4.17 5.4.243

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 linux 6.3.7-1 —
Debian 13 linux 6.3.7-1 —
Debian 12 linux 6.1.37-1 —
ReleasePackageFixed inAdvisory
Ubuntu Nvidia-BlueField 22.04 LTS linux-bluefield 5.15.0-1023.25 —
Ubuntu 24.04 LTS linux-riscv +10 No fix yet —
Ubuntu 22.04 LTS linux +1 5.15.0-83.92 —
Ubuntu 22.04 LTS linux-aws 5.15.0-1044.49 —
Ubuntu 22.04 LTS linux-azure 5.15.0-1046.53 —
Ubuntu 22.04 LTS linux-azure-fde 5.15.0-1046.53.1 —
Ubuntu 22.04 LTS linux-gcp 5.15.0-1041.49 —
Ubuntu 22.04 LTS linux-gke +1 5.15.0-1041.46 —
Ubuntu 22.04 LTS linux-gkeop 5.15.0-1027.32 —
Ubuntu 22.04 LTS linux-ibm +1 5.15.0-1037.40 —
Ubuntu 22.04 LTS linux-intel-iotg 5.15.0-1039.45 —
Ubuntu 22.04 LTS linux-nvidia 5.15.0-1032.32 —
Ubuntu 22.04 LTS linux-nvidia-tegra 5.15.0-1017.17 —
Ubuntu 22.04 LTS linux-nvidia-tegra-igx 5.15.0-1004.4 —
Ubuntu 22.04 LTS linux-oracle 5.15.0-1042.48 —
Ubuntu 22.04 LTS linux-riscv +32 No fix yet —
Ubuntu 22.04 LTS linux-xilinx-zynqmp 5.15.0-1025.29 —
Ubuntu 20.04 LTS linux 5.4.0-162.179 —
Ubuntu 20.04 LTS linux-aws 5.4.0-1109.118 —
Ubuntu 20.04 LTS linux-aws-5.15 5.15.0-1044.49~20.04.1 —
Ubuntu 20.04 LTS linux-azure 5.4.0-1115.122 —
Ubuntu 20.04 LTS linux-azure-5.15 5.15.0-1046.53~20.04.1 —
Ubuntu 20.04 LTS linux-bluefield 5.4.0-1070.76 —
Ubuntu 20.04 LTS linux-gcp 5.4.0-1112.121 —
Ubuntu 20.04 LTS linux-gcp-5.15 5.15.0-1041.49~20.04.1 —
Ubuntu 20.04 LTS linux-gke +28 No fix yet —
Ubuntu 20.04 LTS linux-hwe-5.15 +1 5.15.0-83.92~20.04.1 —
Ubuntu 20.04 LTS linux-ibm 5.4.0-1056.61 —
Ubuntu 20.04 LTS linux-ibm-5.15 5.15.0-1037.40~20.04.1 —
Ubuntu 20.04 LTS linux-intel-iotg-5.15 5.15.0-1040.46~20.04.1 —
Ubuntu 20.04 LTS linux-iot 5.4.0-1021.22 —
Ubuntu 20.04 LTS linux-kvm 5.4.0-1098.104 —
Ubuntu 20.04 LTS linux-nvidia-tegra-5.15 5.15.0-1017.17~20.04.1 —
Ubuntu 20.04 LTS linux-oracle 5.4.0-1108.117 —
Ubuntu 20.04 LTS linux-oracle-5.15 5.15.0-1042.48~20.04.1 —
Ubuntu 20.04 LTS linux-raspi 5.4.0-1093.104 —
Ubuntu 20.04 LTS linux-riscv-5.15 5.15.0-1040.44~20.04.3 —
Ubuntu 20.04 LTS linux-xilinx-zynqmp 5.4.0-1029.33 —
Ubuntu 18.04 LTS linux-gcp +14 No fix yet —
Show 6 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu 16.04 LTS linux-hwe-edge No fix yet —
Ubuntu Pro Realtime 22.04 LTS linux-intel-iot-realtime 5.15.0-1038.40 —
Ubuntu Pro Realtime 22.04 LTS linux-realtime 5.15.0-1045.50 —
Ubuntu Pro FIPS 20.04 LTS linux-fips +3 No fix yet —
Ubuntu Pro FIPS-updates 20.04 LTS linux-aws-fips 5.4.0-1109.118+fips1 —
Ubuntu Pro FIPS-updates 20.04 LTS linux-azure-fips 5.4.0-1115.122+fips1 —
Ubuntu Pro FIPS-updates 20.04 LTS linux-fips 5.4.0-1084.93 —
Ubuntu Pro FIPS-updates 20.04 LTS linux-gcp-fips 5.4.0-1112.121+fips1 —
Ubuntu Pro FIPS-preview 22.04 LTS linux-fips No fix yet —
Ubuntu Pro 18.04 LTS linux-aws-5.4 5.4.0-1109.118~18.04.1 —
Ubuntu Pro 18.04 LTS linux-azure-5.4 5.4.0-1115.122~18.04.1 —
Ubuntu Pro 18.04 LTS linux-gcp-5.4 5.4.0-1112.121~18.04.1 —
Ubuntu Pro 18.04 LTS linux-hwe-5.4 5.4.0-162.179~18.04.1 —
Ubuntu Pro 18.04 LTS linux-ibm-5.4 5.4.0-1056.61~18.04.1 —
Ubuntu Pro 18.04 LTS linux-oracle-5.4 5.4.0-1108.117~18.04.1 —
Ubuntu Pro 18.04 LTS linux-raspi-5.4 5.4.0-1093.104~18.04.1 —
ReleasePackageFixed inAdvisory
SLES 12 SP5 kernel-syms +2 4.12.14-122.336.1 SUSE-SU-2026:4892-1
Show 1 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
SLE Live Patching 12 SP5 kernel-default 4.12.14-122.336.1 SUSE-SU-2026:4892-1
SLE Live Patching 12 SP5 kgraft-patch-SLE12-SP5_Update_89 1-8.3.1 SUSE-SU-2026:4892-1

Amazon Linux

ReleasePackageFixed inAdvisory
Amazon Linux 2023 kernel-livepatch-6.1.29-47.49 1.0-0.amzn2023 ALAS2023-2023-184
Amazon Linux 2023 perf +12 6.1.29-47.49.amzn2023 ALAS2023-2023-184

Advisories 3

References