Skip to content
Heist/ feed
Back to feed
CriticalFix available

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

Type: advisorySources: OSV

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_inser

Products
Kernel
Affected versions
Not specified
Fixed versions
6.12.114, 6.17.13, 6.18.2
CVEs
CVE-2025-68359
Confirmed fixed CVEs
Not specified
Updated in this feed
4 Nov 2026, 16:45 UTC · Revision 1

Source evidence

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

core-osv · Original source

Published 24 Dec 2025, 10:32 UTC

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_inser

osv:CVE-2025-68359

Kernel

Fixed versions: 6.12.114, 6.17.13, 6.18.2

Complete source record
{
  "id": "7c0d9fa6ee660cc8a82d49470e2ca2af763972c45f4ad4927608c70457b0f51b",
  "url": "https://osv.dev/vulnerability/CVE-2025-68359",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "btrfs: fix double free of qgroup record after failure to add delayed ref head",
    "summary": "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_inser",
    "evidence": "osv:CVE-2025-68359",
    "products": [
      {
        "name": {
          "value": "Kernel",
          "evidence": "/affected/1/package/name"
        },
        "prerequisites": [],
        "fixed_versions": [
          {
            "value": "6.12.114",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.17.13",
            "evidence": "/affected/1/ranges"
          },
          {
            "value": "6.18.2",
            "evidence": "/affected/1/ranges"
          }
        ],
        "affected_versions": []
      }
    ],
    "severity": "critical",
    "structured": {
      "id": "CVE-2025-68359",
      "aliases": [
        "CVE-2025-68359"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
              "type": "GIT",
              "events": [
                {
                  "introduced": "6ef8fbce010421bf742b12b8f8f2b2d2ff154845"
                },
                {
                  "fixed": "82d46660ebd94c269e3f25a77eb563621d8e67e3"
                },
                {
                  "fixed": "7617680769e3119dfb3b43a2b7c287ce2242211c"
                },
                {
                  "fixed": "364685c4c2d9c9f4408d95451bcf42fdeebc3ebb"
                },
                {
                  "fixed": "725e46298876a2cc1f1c3fb22ba69d29102c3ddf"
                }
              ]
            }
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-68359.json"
          }
        },
        {
          "ranges": [
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "6.12.0"
                },
                {
                  "fixed": "6.12.114"
                }
              ]
            },
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "6.13.0"
                },
                {
                  "fixed": "6.17.13"
                }
              ]
            },
            {
              "type": "ECOSYSTEM",
              "events": [
                {
                  "introduced": "6.18.0"
                },
                {
                  "fixed": "6.18.2"
                }
              ]
            }
          ],
          "package": {
            "name": "Kernel",
            "ecosystem": "Linux"
          },
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-68359.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:37.411557343Z",
      "provider": "osv",
      "references": [
        "https://git.kernel.org/stable/c/364685c4c2d9c9f4408d95451bcf42fdeebc3ebb",
        "https://git.kernel.org/stable/c/725e46298876a2cc1f1c3fb22ba69d29102c3ddf",
        "https://git.kernel.org/stable/c/7617680769e3119dfb3b43a2b7c287ce2242211c",
        "https://git.kernel.org/stable/c/82d46660ebd94c269e3f25a77eb563621d8e67e3",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/68xxx/CVE-2025-68359.json",
        "https://nvd.nist.gov/vuln/detail/CVE-2025-68359",
        "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
      ],
      "provider_metadata": {
        "cna_assigner": "Linux",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/68xxx/CVE-2025-68359.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2025-68359",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 504882,
  "published_at": "2025-12-24T10:32:48.456+00:00"
}