CVE-2025-40205

Description

A buffer overflow vulnerability was found in the Linux kernel's Btrfs filesystem when encoding file handles. A local user can trigger this issue when the filesystem needs to encode a file handle where the parent directory exists in a different subvolume than the file itself. The function tells callers it will write 32 bytes but actually writes 40 bytes when encoding the parent root ID, resulting in an 8-byte buffer overflow that can corrupt adjacent memory and cause crashes or denial of service.

Statement

Btrfs file handle encoding has three size cases: 20 bytes (no parent), 32 bytes (parent in same root), or 40 bytes (parent in different root). The function initially returns either 20 or 32 to the caller, who allocates that much space. If the parent is later discovered to be in a different root, the code writes parent_root_objectid—extending to 40 bytes and overwriting 8 bytes past the allocated buffer. While the specific parent/subvolume conditions make this difficult to trigger, it's a real memory corruption bug.

Common Vulnerability Scoring System (CVSS) Score Details

Info alert:Important note

CVSS scores for open source components depend on vendor-specific factors (e.g. version or build chain). Therefore, Red Hat's score and impact rating can be different from NVD and other vendors. Red Hat remains the authoritative CVE Naming Authority (CNA) source for its products and services (see Red Hat classifications).

The following CVSS metrics and score provided are preliminary and subject to review.

CVSS v3 Score Breakdown

Red HatNVDcve.org
Base Score5.5N/A7.8
Attack VectorLocalN/ALocal
Attack ComplexityLowN/ALow
Privileges RequiredLowN/ALow
User InteractionNoneN/ANone
ScopeUnchangedN/AUnchanged
ConfidentialityNoneN/AHigh
Integrity ImpactNoneN/AHigh
Availability ImpactHighN/AHigh

Vector

Red Hat: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

cve.org: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Understanding the Weakness (CWE)

Integrity,Availability,Confidentiality

Technical Impact: DoS: Crash, Exit, or Restart; Execute Unauthorized Code or Commands; Read Memory; Modify Memory

If the incorrect calculation is used in the context of memory allocation, then the software may create a buffer that is smaller or larger than expected. If the allocated buffer is smaller than expected, this could lead to an out-of-bounds read or write (CWE-119), possibly causing a crash, allowing arbitrary code execution, or exposing sensitive data.

Frequently Asked Questions

Want to get errata notifications? Sign up here.