# CVE-2025-68359: btrfs: fix double free of qgroup record after failure to add delayed ref head

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

- **Severity:** CRITICAL 9.8
- **CVSS:** 9.8 (v3.1, CNA) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Network; Attack complexity: Low; Privileges required: None; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, no login needed
- **EPSS:** 0.89% (percentile 57, 2026-11-26)
- **Published:** 2025-12-24T10:32:48.456Z
- **Modified:** 2026-10-21T13:18:22.890Z

## Who should check

- Anyone running Linux \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 82d46660ebd94c269e3f25a77eb563621d8e67e3; \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 7617680769e3119dfb3b43a2b7c287ce2242211c; \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 364685c4c2d9c9f4408d95451bcf42fdeebc3ebb; \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 725e46298876a2cc1f1c3fb22ba69d29102c3ddf
- Anyone running Linux 6.12

## Description

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

btrfs: fix double free of qgroup record after failure to add delayed ref head

In the previous code it was possible to incur into a double kfree()
scenario when calling add\_delayed\_ref\_head(). This could happen if the
record was reported to already exist in the
btrfs\_qgroup\_trace\_extent\_nolock() call, but then there was an error
later on add\_delayed\_ref\_head(). In this case, since
add\_delayed\_ref\_head() returned an error, the caller went to free the
record. Since add\_delayed\_ref\_head() couldn't set this kfree'd pointer
to NULL, then kfree() would have acted on a non-NULL 'record' object
which was pointing to memory already freed by the callee.

The problem comes from the fact that the responsibility to kfree the
object is on both the caller and the callee at the same time. Hence, the
fix for this is to shift the ownership of the 'qrecord' object out of
the add\_delayed\_ref\_head(). That is, we will never attempt to kfree()
the given object inside of this function, and will expect the caller to
act on the 'qrecord' object on its own. The only exception where the
'qrecord' object cannot be kfree'd is if it was inserted into the
tracing logic, for which we already have the 'qrecord\_inserted\_ret'
boolean to account for this. Hence, the caller has to kfree the object
only if add\_delayed\_ref\_head() reports not to have inserted it on the
tracing logic.

As a side-effect of the above, we must guarantee that
'qrecord\_inserted\_ret' is properly initialized at the start of the
function, not at the end, and then set when an actual insert
happens. This way we avoid 'qrecord\_inserted\_ret' having an invalid
value on an early exit.

The documentation from the add\_delayed\_ref\_head() has also been updated
to reflect on the exact ownership of the 'qrecord' object.

## Affected and fixed versions

- Linux: \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 82d46660ebd94c269e3f25a77eb563621d8e67e3; \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 7617680769e3119dfb3b43a2b7c287ce2242211c; \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 364685c4c2d9c9f4408d95451bcf42fdeebc3ebb; \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 725e46298876a2cc1f1c3fb22ba69d29102c3ddf (cvelist)
- Linux: 6.12 (cvelist)

## Mitigation

- Upgrade Linux to 725e46298876a2cc1f1c3fb22ba69d29102c3ddf or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2025-68359.md
Affected: Linux >= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, < 82d46660ebd94c269e3f25a77eb563621d8e67e3; >= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, < 7617680769e3119dfb3b43a2b7c287ce2242211c; >= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, < 364685c4c2d9c9f4408d95451bcf42fdeebc3ebb; >= 6ef8fbce010421bf742b12b…
Fixed in: Linux 82d46660ebd94c269e3f25a77eb563621d8e67e3, Linux 7617680769e3119dfb3b43a2b7c287ce2242211c, Linux 364685c4c2d9c9f4408d95451bcf42fdeebc3ebb, Linux 725e46298876a2cc1f1c3fb22ba69d29102c3ddf

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-2025-68359 being exploited?

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

### How serious is CVE-2025-68359?

Critical: CVSS 9.8 (v3.1, scored by CNA). Remote, no login needed.

### Which versions are affected by CVE-2025-68359?

Linux \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 82d46660ebd94c269e3f25a77eb563621d8e67e3; \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 7617680769e3119dfb3b43a2b7c287ce2242211c; \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 364685c4c2d9c9f4408d95451bcf42fdeebc3ebb; \>= 6ef8fbce010421bf742b12b8f8f2b2d2ff154845, \< 725e46298876a2cc1f1c3fb22ba69d29102c3ddf; Linux 6.12.

### Is there a fix for CVE-2025-68359?

Yes. Fixed in Linux 82d46660ebd94c269e3f25a77eb563621d8e67e3, Linux 7617680769e3119dfb3b43a2b7c287ce2242211c, Linux 364685c4c2d9c9f4408d95451bcf42fdeebc3ebb, Linux 725e46298876a2cc1f1c3fb22ba69d29102c3ddf. Upgrade Linux to 725e46298876a2cc1f1c3fb22ba69d29102c3ddf or later.

### How do I check if I'm affected by CVE-2025-68359?

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/82d46660ebd94c269e3f25a77eb563621d8e67e3>
- other: <https://git.kernel.org/stable/c/7617680769e3119dfb3b43a2b7c287ce2242211c>
- other: <https://git.kernel.org/stable/c/364685c4c2d9c9f4408d95451bcf42fdeebc3ebb>
- other: <https://git.kernel.org/stable/c/725e46298876a2cc1f1c3fb22ba69d29102c3ddf>

## 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-2025-68359>

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