← Back to CVE Explorer

CVE-2025-40205

Full vulnerability record from the local CVENow database.

Description

In the Linux kernel, the following vulnerability has been resolved: btrfs: avoid potential out-of-bounds in btrfs_encode_fh() The function btrfs_encode_fh() does not properly account for the three cases it handles. Before writing to the file handle (fh), the function only returns to the user BTRFS_FID_SIZE_NON_CONNECTABLE (5 dwords, 20 bytes) or BTRFS_FID_SIZE_CONNECTABLE (8 dwords, 32 bytes). However, when a parent exists and the root ID of the parent and the inode are different, the function writes BTRFS_FID_SIZE_CONNECTABLE_ROOT (10 dwords, 40 bytes). If *max_len is not large enough, this write goes out of bounds because BTRFS_FID_SIZE_CONNECTABLE_ROOT is greater than BTRFS_FID_SIZE_CONNECTABLE originally returned. This results in an 8-byte out-of-bounds write at fid->parent_root_objectid = parent_root_id. A previous attempt to fix this issue was made but was lost. https://lore.kernel.org/all/[email protected]/ Although this issue does not seem to be easily triggerable, it is a potential memory corruption bug that should be fixed. This patch resolves the issue by ensuring the function returns the appropriate size for all three cases and validates that *max_len is large enough before writing any data.

Severity
HIGH
CVSS score
7.8 (v3.1)
Vulnerability status
Deferred
Source identifier
416baaa9-dc9f-4396-8d5f-8c081fb06d67
Published
2025-11-12 22:15:47.773000
Last modified
2026-10-19 21:10:00.160000
View original CVE JSON
{
  "id": "CVE-2025-40205",
  "sourceIdentifier": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
  "published": "2025-11-12T22:15:47.773",
  "lastModified": "2026-10-19T21:10:00.160",
  "vulnStatus": "Deferred",
  "cveTags": [],
  "descriptions": [
    {
      "lang": "en",
      "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: avoid potential out-of-bounds in btrfs_encode_fh()\n\nThe function btrfs_encode_fh() does not properly account for the three\ncases it handles.\n\nBefore writing to the file handle (fh), the function only returns to the\nuser BTRFS_FID_SIZE_NON_CONNECTABLE (5 dwords, 20 bytes) or\nBTRFS_FID_SIZE_CONNECTABLE (8 dwords, 32 bytes).\n\nHowever, when a parent exists and the root ID of the parent and the\ninode are different, the function writes BTRFS_FID_SIZE_CONNECTABLE_ROOT\n(10 dwords, 40 bytes).\n\nIf *max_len is not large enough, this write goes out of bounds because\nBTRFS_FID_SIZE_CONNECTABLE_ROOT is greater than\nBTRFS_FID_SIZE_CONNECTABLE originally returned.\n\nThis results in an 8-byte out-of-bounds write at\nfid->parent_root_objectid = parent_root_id.\n\nA previous attempt to fix this issue was made but was lost.\n\nhttps://lore.kernel.org/all/[email protected]/\n\nAlthough this issue does not seem to be easily triggerable, it is a\npotential memory corruption bug that should be fixed. This patch\nresolves the issue by ensuring the function returns the appropriate size\nfor all three cases and validates that *max_len is large enough before\nwriting any data."
    },
    {
      "lang": "es",
      "value": "En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nbtrfs: evita un potencial desbordamiento de límites en btrfs_encode_fh()\n\nLa función btrfs_encode_fh() no tiene en cuenta adecuadamente los tres casos que maneja.\n\nAntes de escribir en el descriptor de archivo (fh), la función solo devuelve al usuario BTRFS_FID_SIZE_NON_CONNECTABLE (5 dwords, 20 bytes) o BTRFS_FID_SIZE_CONNECTABLE (8 dwords, 32 bytes).\n\nSin embargo, cuando existe un padre y el ID raíz del padre y el inodo son diferentes, la función escribe BTRFS_FID_SIZE_CONNECTABLE_ROOT (10 dwords, 40 bytes).\n\nSi *max_len no es lo suficientemente grande, esta escritura se desborda porque BTRFS_FID_SIZE_CONNECTABLE_ROOT es mayor que BTRFS_FID_SIZE_CONNECTABLE devuelto originalmente.\n\nEsto resulta en una escritura fuera de límites de 8 bytes en fid->parent_root_objectid = parent_root_id.\n\nSe hizo un intento previo para solucionar este problema, pero se perdió.\n\nhttps://lore.kernel.org/all/[email protected]/\n\nAunque este problema no parece ser fácilmente activable, es un potencial error de corrupción de memoria que debería ser corregido. Este parche resuelve el problema asegurando que la función devuelva el tamaño apropiado para los tres casos y valida que *max_len sea lo suficientemente grande antes de escribir cualquier dato."
    }
  ],
  "affected": [
    {
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
      "affectedData": [
        {
          "vendor": "Linux",
          "product": "Linux",
          "defaultStatus": "unaffected",
          "programFiles": [
            "fs/btrfs/export.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "versions": [
            {
              "version": "be6e8dc0ba84029997075a1ec77b4ddb863cbe15",
              "lessThan": "60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db",
              "versionType": "git",
              "status": "affected"
            },
            {
              "version": "be6e8dc0ba84029997075a1ec77b4ddb863cbe15",
              "lessThan": "742b44342204e5dfe3926433823623c1a0c581df",
              "versionType": "git",
              "status": "affected"
            },
            {
              "version": "be6e8dc0ba84029997075a1ec77b4ddb863cbe15",
              "lessThan": "d3a9a8e1275eb9b87f006b5562a287aea3f6885f",
              "versionType": "git",
              "status": "affected"
            },
            {
              "version": "be6e8dc0ba84029997075a1ec77b4ddb863cbe15",
              "lessThan": "d91f6626133698362bba08fbc04bd72c466806d3",
              "versionType": "git",
              "status": "affected"
            },
            {
              "version": "be6e8dc0ba84029997075a1ec77b4ddb863cbe15",
              "lessThan": "0276c8582488022f057b4cec21975a5edf079f47",
              "versionType": "git",
              "status": "affected"
            },
            {
              "version": "be6e8dc0ba84029997075a1ec77b4ddb863cbe15",
              "lessThan": "361d67276eb8ec6be8f27f4ad6c6090459438fee",
              "versionType": "git",
              "status": "affected"
            },
            {
              "version": "be6e8dc0ba84029997075a1ec77b4ddb863cbe15",
              "lessThan": "43143776b0a7604d873d1a6f3e552a00aa930224",
              "versionType": "git",
              "status": "affected"
            },
            {
              "version": "be6e8dc0ba84029997075a1ec77b4ddb863cbe15",
              "lessThan": "dff4f9ff5d7f289e4545cc936362e01ed3252742",
              "versionType": "git",
              "status": "affected"
            }
          ]
        },
        {
          "vendor": "Linux",
          "product": "Linux",
          "defaultStatus": "affected",
          "programFiles": [
            "fs/btrfs/export.c"
          ],
          "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
          "versions": [
            {
              "version": "2.6.29",
              "status": "affected"
            },
            {
              "version": "0",
              "lessThan": "2.6.29",
              "versionType": "semver",
              "status": "unaffected"
            },
            {
              "version": "5.4.301",
              "lessThanOrEqual": "5.4.*",
              "versionType": "semver",
              "status": "unaffected"
            },
            {
              "version": "5.10.246",
              "lessThanOrEqual": "5.10.*",
              "versionType": "semver",
              "status": "unaffected"
            },
            {
              "version": "5.15.195",
              "lessThanOrEqual": "5.15.*",
              "versionType": "semver",
              "status": "unaffected"
            },
            {
              "version": "6.1.157",
              "lessThanOrEqual": "6.1.*",
              "versionType": "semver",
              "status": "unaffected"
            },
            {
              "version": "6.6.113",
              "lessThanOrEqual": "6.6.*",
              "versionType": "semver",
              "status": "unaffected"
            },
            {
              "version": "6.12.54",
              "lessThanOrEqual": "6.12.*",
              "versionType": "semver",
              "status": "unaffected"
            },
            {
              "version": "6.17.4",
              "lessThanOrEqual": "6.17.*",
              "versionType": "semver",
              "status": "unaffected"
            },
            {
              "version": "6.18",
              "lessThanOrEqual": "*",
              "versionType": "original_commit_for_fix",
              "status": "unaffected"
            }
          ]
        }
      ]
    }
  ],
  "metrics": {
    "cvssMetricV31": [
      {
        "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
        "type": "Secondary",
        "cvssData": {
          "version": "3.1",
          "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
          "baseScore": 7.8,
          "baseSeverity": "HIGH",
          "attackVector": "LOCAL",
          "attackComplexity": "LOW",
          "privilegesRequired": "LOW",
          "userInteraction": "NONE",
          "scope": "UNCHANGED",
          "confidentialityImpact": "HIGH",
          "integrityImpact": "HIGH",
          "availabilityImpact": "HIGH"
        },
        "exploitabilityScore": 1.8,
        "impactScore": 5.9
      }
    ],
    "ssvcV203": [
      {
        "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
        "ssvcData": {
          "timestamp": "2026-10-15T21:58:09.178444Z",
          "id": "CVE-2025-40205",
          "options": [
            {
              "exploitation": "none"
            },
            {
              "automatable": "no"
            },
            {
              "technicalImpact": "total"
            }
          ],
          "role": "CISA Coordinator",
          "version": "2.0.3"
        }
      }
    ]
  },
  "references": [
    {
      "url": "https://git.kernel.org/stable/c/0276c8582488022f057b4cec21975a5edf079f47",
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    },
    {
      "url": "https://git.kernel.org/stable/c/361d67276eb8ec6be8f27f4ad6c6090459438fee",
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    },
    {
      "url": "https://git.kernel.org/stable/c/43143776b0a7604d873d1a6f3e552a00aa930224",
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    },
    {
      "url": "https://git.kernel.org/stable/c/60de2f55d2aca53e81b4ef2a67d7cc9e1eb677db",
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    },
    {
      "url": "https://git.kernel.org/stable/c/742b44342204e5dfe3926433823623c1a0c581df",
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    },
    {
      "url": "https://git.kernel.org/stable/c/d3a9a8e1275eb9b87f006b5562a287aea3f6885f",
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    },
    {
      "url": "https://git.kernel.org/stable/c/d91f6626133698362bba08fbc04bd72c466806d3",
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    },
    {
      "url": "https://git.kernel.org/stable/c/dff4f9ff5d7f289e4545cc936362e01ed3252742",
      "source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
    }
  ]
}