# CVE-2023-54158: btrfs: don't free qgroup space unless specified

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** UNSCORED
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Unknown
- **EPSS:** 0.29% (percentile 14, 2026-11-26)
- **Published:** 2025-12-24T13:07:07.438Z
- **Modified:** 2026-06-17T06:46:54.487Z

## Who should check

- Anyone running Linux \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 1e05bf5e80bb1161b7294c9ce5292b26232ab853; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 148b16cd30b202999ec5b534e3e5d8ab4b766f21; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< f264be24146bee2d652010a18ae2517df5856261; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 15e877e5923ec6d6caa5e447dcc4b79a8ff7cc53; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 04ff6bd0317735791ef3e443c7c89f3c0dda548d; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 478bd15f46b6e3aae78aac4f3788697f1546eea6; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< d246331b78cbef86237f9c22389205bc9b4e1cc1
- Anyone running Linux 4.17

## 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 and fixed versions

- Linux: \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 1e05bf5e80bb1161b7294c9ce5292b26232ab853; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 148b16cd30b202999ec5b534e3e5d8ab4b766f21; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< f264be24146bee2d652010a18ae2517df5856261; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 15e877e5923ec6d6caa5e447dcc4b79a8ff7cc53; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 04ff6bd0317735791ef3e443c7c89f3c0dda548d; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 478bd15f46b6e3aae78aac4f3788697f1546eea6; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< d246331b78cbef86237f9c22389205bc9b4e1cc1 (cvelist)
- Linux: 4.17 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2023-54158. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2023-54158.md
Affected: Linux >= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, < 1e05bf5e80bb1161b7294c9ce5292b26232ab853; >= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, < 148b16cd30b202999ec5b534e3e5d8ab4b766f21; >= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, < f264be24146bee2d652010a18ae2517df5856261; >= ff6bc37eb7f6e7b052e50c1…
Fixed in: Linux 1e05bf5e80bb1161b7294c9ce5292b26232ab853, Linux 148b16cd30b202999ec5b534e3e5d8ab4b766f21, Linux 15e877e5923ec6d6caa5e447dcc4b79a8ff7cc53, Linux 04ff6bd0317735791ef3e443c7c89f3c0dda548d, Linux 478bd15f46b6e3aae78aac4f3788697f1546eea6

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2023-54158 being exploited?

There is no confirmed exploitation: CVE-2023-54158 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.29% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2023-54158?

It has no CVSS score yet. Unknown.

### Which versions are affected by CVE-2023-54158?

Linux \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 1e05bf5e80bb1161b7294c9ce5292b26232ab853; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 148b16cd30b202999ec5b534e3e5d8ab4b766f21; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< f264be24146bee2d652010a18ae2517df5856261; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 15e877e5923ec6d6caa5e447dcc4b79a8ff7cc53; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 04ff6bd0317735791ef3e443c7c89f3c0dda548d; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< 478bd15f46b6e3aae78aac4f3788697f1546eea6; \>= ff6bc37eb7f6e7b052e50c13a480e1080b3ec07a, \< d246331b78cbef86237f9c22389205bc9b4e1cc1; Linux 4.17.

### Is there a fix for CVE-2023-54158?

Yes. Fixed in Linux 1e05bf5e80bb1161b7294c9ce5292b26232ab853, Linux 148b16cd30b202999ec5b534e3e5d8ab4b766f21, Linux 15e877e5923ec6d6caa5e447dcc4b79a8ff7cc53, Linux 04ff6bd0317735791ef3e443c7c89f3c0dda548d, Linux 478bd15f46b6e3aae78aac4f3788697f1546eea6. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2023-54158?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- other: <https://git.kernel.org/stable/c/1e05bf5e80bb1161b7294c9ce5292b26232ab853>
- other: <https://git.kernel.org/stable/c/148b16cd30b202999ec5b534e3e5d8ab4b766f21>
- other: <https://git.kernel.org/stable/c/f264be24146bee2d652010a18ae2517df5856261>
- other: <https://git.kernel.org/stable/c/15e877e5923ec6d6caa5e447dcc4b79a8ff7cc53>
- other: <https://git.kernel.org/stable/c/04ff6bd0317735791ef3e443c7c89f3c0dda548d>
- other: <https://git.kernel.org/stable/c/478bd15f46b6e3aae78aac4f3788697f1546eea6>
- other: <https://git.kernel.org/stable/c/d246331b78cbef86237f9c22389205bc9b4e1cc1>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2023-54158>

HTML: <https://flawdb.com/CVE-2023-54158> · JSON: <https://flawdb.com/api/v1/entries/CVE-2023-54158>
