CVE-2025-40209
NoneCVSS
—
EPSS
0.2%
Published
Nov 21, 2025
CISA due date
—
Cloudanix analysis
A bug in the Linux kernel's btrfs storage code could let any local user slowly drain the system's memory by repeatedly performing a certain filesystem operation, and the problem is fixed by installing an updated kernel.
- Exploitation
- Local Privilege
- Attacker needs
- Low Privilege
- Complexity
- Low
- Impact
- Denial Of Service
- Component
- OS kernel
- Class
- Memory Corruption
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Early return in btrfs_add_qgroup_relation on invalid qgroup level validation (src >= dst) skips kfree of the caller-preallocated qgroup_list structure, leaving a 64-byte kernel memory leak per failed call because the caller unconditionally nulls the pointer afterward.
Why it matters to the business
Repeated triggering by any local user with write access to a btrfs filesystem can exhaust kernel memory over time, leading to performance degradation or denial of service on Linux systems; the issue affects widely deployed kernel packages with fixes available since late 2025.
How an attack unfolds
An attacker with access to a writable btrfs mount invokes the QGROUP_ASSIGN ioctl repeatedly with src qgroup level greater than or equal to dst; the level check fails before mutex acquisition or error cleanup, the prealloc pointer is nulled by the caller, and the 64-byte allocation is never freed, accumulating leaks until memory pressure occurs.
How to fix it
Upgrade affected Linux kernel packages to the fixed versions: linux-virt and linux-virt-doc to 6.12.25-r0 or later, and kernels containing commit 3412d0e973e8f8381747d69033eda809a57a2581. Reboot after upgrade; no configuration changes are required.
How to confirm the fix worked
Confirm kernel version is at or above the fixed releases; attempt to reproduce the original failing qgroup relation call and verify via slabinfo or kmemleak that the qgroup_list allocation is now released on the error path.
Typical attack path
- Obtain write access to a btrfs filesystem (mount or container)
- Prepare qgroup relation arguments where source level >= destination level
- Call btrfs_ioctl_qgroup_assign (or equivalent userspace tool) in a tight loop
- Observe gradual kernel memory consumption without corresponding process RSS growth
- Continue until system-wide memory pressure or OOM events manifest
How to detect it
Look in kernel logs for repeated btrfs qgroup ioctl failures around the time of memory pressure events; use kmemleak or slabtop to watch for accumulating qgroup_list objects that never decrease after failed relation assignments.
What your security team should do
- Prioritize patching btrfs-enabled systems that expose mounts to untrusted users
- Monitor EPSS trend and re-evaluate if exploit code appears
- Restrict unprivileged btrfs mount access via mount options or user namespaces where feasible until patched
The record
In the Linux kernel, the following vulnerability has been resolved: btrfs: fix memory leak of qgroup_list in btrfs_add_qgroup_relation When btrfs_add_qgroup_relation() is called with invalid qgroup levels (src >= dst), the function returns -EINVAL directly without freeing the preallocated qgroup_list structure passed by the caller. This causes a memory leak because the caller unconditionally sets the pointer to NULL after the call, preventing any cleanup. The issue occurs because the level validation check happens before the mutex is acquired and before any error handling path that would free the prealloc pointer. On this early return, the cleanup code at the 'out' label (which includes kfree(prealloc)) is never reached. In btrfs_ioctl_qgroup_assign(), the code pattern is: prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL); ret = btrfs_add_qgroup_relation(trans, sa->src, sa->dst, prealloc); prealloc = NULL; // Always set to NULL regardless of return value ... kfree(prealloc); // This becomes kfree(NULL), does nothing When the level check fails, 'prealloc' is never freed by either the callee or the caller, resulting in a 64-byte memory leak per failed operation. This can be triggered repeatedly by an unprivileged user with access to a writable btrfs mount, potentially exhausting kernel memory. Fix this by freeing prealloc before the early return, ensuring prealloc is always freed on all error paths.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Linux | Kernel | 6.11.0 | 6.12.58 |
| openSUSE:Leap 16.0 | dtb-aarch64 | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-64kb | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-azure | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-default | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-default-base | 0 | 6.12.0-160000.9.1.160000.2.6 |
| openSUSE:Leap 16.0 | kernel-docs | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-kvmsmall | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-obs-build | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-obs-qa | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-rt | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-source | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-syms | 0 | 6.12.0-160000.9.1 |
| openSUSE:Leap 16.0 | kernel-zfcpdump | 0 | 6.12.0-160000.9.1 |
Related vulnerabilities
- CVE-2026-23226 In the Linux kernel, the following vulnerability has been resolved: ksmbd: add chann_lock… Also affects Kernel
- CVE-2026-23225 In the Linux kernel, the following vulnerability has been resolved: sched/mmcid: Don't… Also affects Kernel
- CVE-2026-23230 In the Linux kernel, the following vulnerability has been resolved: smb: client: split… Also affects Kernel
- CVE-2026-23224 In the Linux kernel, the following vulnerability has been resolved: erofs: fix UAF issue… Also affects Kernel
- CVE-2026-23227 In the Linux kernel, the following vulnerability has been resolved: drm/exynos: vidi: use… Also affects Kernel
- CVE-2026-23223 In the Linux kernel, the following vulnerability has been resolved: xfs: fix UAF in… Also affects Kernel
- CVE-2026-23228 In the Linux kernel, the following vulnerability has been resolved: smb: server: fix leak… Also affects Kernel
- CVE-2026-23229 In the Linux kernel, the following vulnerability has been resolved: crypto: virtio - Add… Also affects Kernel