{"id":"CVE-2026-31666","state":"PUBLISHED","title":"btrfs: fix incorrect return value after changing leaf in lookup_extent_data_ref()","description":"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.","publishedAt":"2026-04-24T14:45:15.271Z","updatedAt":"2026-10-19T18:56:02.816Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"1618aa3c2e0163f5ac34d514ae89474521910536","status":"affected","lessThan":"4125a194db4a6cf91f619f38788272651cb97dce","versionType":"git"},{"version":"1618aa3c2e0163f5ac34d514ae89474521910536","status":"affected","lessThan":"450e6a685d0cad95b15f8af152057bd0bf79f50b","versionType":"git"},{"version":"1618aa3c2e0163f5ac34d514ae89474521910536","status":"affected","lessThan":"ab1e022379c3c811aa72da8eb0c7507859a1d0f5","versionType":"git"},{"version":"1618aa3c2e0163f5ac34d514ae89474521910536","status":"affected","lessThan":"316fb1b3169efb081d2db910cbbfef445afa03b9","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/btrfs/extent-tree.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.10","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.10","versionType":"semver"},{"version":"6.12.82","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.23","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"6.19.13","status":"unaffected","lessThanOrEqual":"6.19.*","versionType":"semver"},{"version":"7.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/btrfs/extent-tree.c"]}],"references":["https://git.kernel.org/stable/c/4125a194db4a6cf91f619f38788272651cb97dce","https://git.kernel.org/stable/c/450e6a685d0cad95b15f8af152057bd0bf79f50b","https://git.kernel.org/stable/c/ab1e022379c3c811aa72da8eb0c7507859a1d0f5","https://git.kernel.org/stable/c/316fb1b3169efb081d2db910cbbfef445afa03b9"],"weaknesses":["CWE-754"],"ingestedAt":"2026-10-29T20:11:40.391Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/31xxx/CVE-2026-31666.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-31666","state":"PUBLISHED","datePublished":"2026-04-24T14:45:15.271Z","dateUpdated":"2026-10-19T18:56:02.816Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-03-09T15:48:24.129Z"},"containers":{"cna":{"title":"btrfs: fix incorrect return value after changing leaf in lookup_extent_data_ref()","descriptions":[{"lang":"en","value":"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."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"1618aa3c2e0163f5ac34d514ae89474521910536","status":"affected","lessThan":"4125a194db4a6cf91f619f38788272651cb97dce","versionType":"git"},{"version":"1618aa3c2e0163f5ac34d514ae89474521910536","status":"affected","lessThan":"450e6a685d0cad95b15f8af152057bd0bf79f50b","versionType":"git"},{"version":"1618aa3c2e0163f5ac34d514ae89474521910536","status":"affected","lessThan":"ab1e022379c3c811aa72da8eb0c7507859a1d0f5","versionType":"git"},{"version":"1618aa3c2e0163f5ac34d514ae89474521910536","status":"affected","lessThan":"316fb1b3169efb081d2db910cbbfef445afa03b9","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/btrfs/extent-tree.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.10","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.10","versionType":"semver"},{"version":"6.12.82","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.18.23","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"6.19.13","status":"unaffected","lessThanOrEqual":"6.19.*","versionType":"semver"},{"version":"7.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/btrfs/extent-tree.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/4125a194db4a6cf91f619f38788272651cb97dce"},{"url":"https://git.kernel.org/stable/c/450e6a685d0cad95b15f8af152057bd0bf79f50b"},{"url":"https://git.kernel.org/stable/c/ab1e022379c3c811aa72da8eb0c7507859a1d0f5"},{"url":"https://git.kernel.org/stable/c/316fb1b3169efb081d2db910cbbfef445afa03b9"}],"metrics":[{"cvssV3_1":{"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"},"scenarios":[{"lang":"en","value":"AV:L - The vulnerable Btrfs extent-reference code is reached through local filesystem syscalls such as reflink/dedupe, truncate, unlink, and hole punching on a writable mounted Btrfs filesystem.\nAC:L - The trigger depends on attacker-shaped filesystem metadata and ordinary repeated file operations, not on a race or condition outside attacker control; when uncertain, the lower-complexity value is appropriate.\nPR:L - A basic unprivileged local user with write access to files on the Btrfs mount can exercise the relevant paths; no real root or init-namespace capability is required.\nUI:N - No separate victim action is required after the attacker has local access to a writable Btrfs filesystem; the attacker can issue the file operations directly.\nS:U - The impact remains within the local kernel/filesystem security authority and does not cross a VM, IOMMU, or similar security boundary.\nC:H - Incorrectly deleting or decrementing the wrong extent data reference can corrupt Btrfs extent ownership, plausibly causing stale or unrelated file data exposure through block reuse or aliasing.\nI:H - The bug can operate on the wrong extent tree item and corrupt filesystem metadata, plausibly enabling corruption or loss of arbitrary file data beyond the attacker's own intended files.\nA:H - The corrupted extent tree path can trigger transaction aborts, read-only remounts, BUG_ON/oops conditions, or persistent filesystem corruption, causing high availability impact."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T12:24:16.096Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.10","versionEndExcluding":"6.12.82"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.10","versionEndExcluding":"6.18.23"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.10","versionEndExcluding":"6.19.13"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.10","versionEndExcluding":"7.0"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"id":"CVE-2026-31666","role":"CISA Coordinator","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"total"}],"version":"2.0.3","timestamp":"2026-10-16T15:11:52.641665Z"}}}],"problemTypes":[{"descriptions":[{"cweId":"CWE-754","lang":"en","type":"CWE","description":"CWE-754 Improper Check for Unusual or Exceptional Conditions"}]}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2026-10-19T18:56:02.816Z"}}]}}}