{
  "affected": [
    {
      "ranges": [
        {
          "events": [
            {
              "introduced": "1618aa3c2e0163f5ac34d514ae89474521910536"
            },
            {
              "fixed": "4125a194db4a6cf91f619f38788272651cb97dce"
            },
            {
              "fixed": "450e6a685d0cad95b15f8af152057bd0bf79f50b"
            },
            {
              "fixed": "ab1e022379c3c811aa72da8eb0c7507859a1d0f5"
            },
            {
              "fixed": "316fb1b3169efb081d2db910cbbfef445afa03b9"
            }
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "type": "GIT"
        }
      ]
    },
    {
      "package": {
        "ecosystem": "Linux",
        "name": "Kernel"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "6.10.0"
            },
            {
              "fixed": "6.12.82"
            }
          ],
          "type": "ECOSYSTEM"
        },
        {
          "events": [
            {
              "introduced": "6.13.0"
            },
            {
              "fixed": "6.18.23"
            }
          ],
          "type": "ECOSYSTEM"
        },
        {
          "events": [
            {
              "introduced": "6.19.0"
            },
            {
              "fixed": "6.19.13"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "database_specific": {
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/31xxx/CVE-2026-31666.json"
  },
  "details": "In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: fix incorrect return value after changing leaf in lookup_extent_data_ref()\n\nAfter commit 1618aa3c2e01 (\"btrfs: simplify return variables in\nlookup_extent_data_ref()\"), the err and ret variables were merged into\na single ret variable. However, when btrfs_next_leaf() returns 0\n(success), ret is overwritten from -ENOENT to 0. If the first key in\nthe next leaf does not match (different objectid or type), the function\nreturns 0 instead of -ENOENT, making the caller believe the lookup\nsucceeded when it did not. This can lead to operations on the wrong\nextent tree item, potentially causing extent tree corruption.\n\nFix this by returning -ENOENT directly when the key does not match,\ninstead of relying on the ret variable.",
  "id": "CVE-2026-31666",
  "modified": "2026-08-12T03:51:25.968794483Z",
  "published": "2026-04-24T14:45:15.271Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/316fb1b3169efb081d2db910cbbfef445afa03b9"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/4125a194db4a6cf91f619f38788272651cb97dce"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/450e6a685d0cad95b15f8af152057bd0bf79f50b"
    },
    {
      "type": "WEB",
      "url": "https://git.kernel.org/stable/c/ab1e022379c3c811aa72da8eb0c7507859a1d0f5"
    },
    {
      "type": "ADVISORY",
      "url": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/31xxx/CVE-2026-31666.json"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-31666"
    },
    {
      "type": "PACKAGE",
      "url": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
    }
  ],
  "schema_version": "1.9.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "btrfs: fix incorrect return value after changing leaf in lookup_extent_data_ref()"
}