Linux Kernel up to 6.12.57/6.17.7/6.18-rc4 btrfs_add_qgroup_relation return value

| CVSS Meta Temp Score | Current Exploit Price (≈) | CTI Interest Score |
|---|---|---|
| 5.3 | $0-$5k | 0.00 |
Summary
A vulnerability has been found in Linux Kernel up to 6.12.57/6.17.7/6.18-rc4 and classified as critical. This affects the function btrfs_add_qgroup_relation. The manipulation leads to return value.
This vulnerability is listed as CVE-2025-40209. There is no available exploit.
The affected component should be upgraded.
Details
A vulnerability was found in Linux Kernel up to 6.12.57/6.17.7/6.18-rc4 and classified as critical. This issue affects the function btrfs_add_qgroup_relation. The manipulation with an unknown input leads to a return value vulnerability. Using CWE to declare the problem leads to CWE-252. The product does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions. The impact remains unknown. The summary by CVE is:
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.
It is possible to read the advisory at git.kernel.org. The identification of this vulnerability is CVE-2025-40209 since 04/16/2025. Technical details of the vulnerability are known, but there is no available exploit. The pricing for an exploit might be around USD $0-$5k at the moment (estimation calculated on 05/19/2026).
The vulnerability scanner Nessus provides a plugin with the ID 276580 (Linux Distros Unpatched Vulnerability : CVE-2025-40209), which helps to determine the existence of the flaw in a target environment.
Upgrading to version 6.12.58, 6.17.8 or 6.18-rc5 eliminates this vulnerability. Applying the patch 3412d0e973e8f8381747d69033eda809a57a2581/a4d9ebe23bcb79d9d057e3c995db73b7b3aae414/f260c6aff0b8af236084012d14f9f1bf792ea883 is able to eliminate this problem. The bugfix is ready for download at git.kernel.org. The best possible mitigation is suggested to be upgrading to the latest version.
The vulnerability is also documented in the databases at Tenable (276580) and CERT Bund (WID-SEC-2025-2658). Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.
Affected
- Debian Linux
- Amazon Linux 2
- Red Hat Enterprise Linux
- Ubuntu Linux
- SUSE Linux
- Oracle Linux
- SUSE openSUSE
- Open Source Linux Kernel
Product
Type
Vendor
Name
Version
- 6.12.0
- 6.12.1
- 6.12.2
- 6.12.3
- 6.12.4
- 6.12.5
- 6.12.6
- 6.12.7
- 6.12.8
- 6.12.9
- 6.12.10
- 6.12.11
- 6.12.12
- 6.12.13
- 6.12.14
- 6.12.15
- 6.12.16
- 6.12.17
- 6.12.18
- 6.12.19
- 6.12.20
- 6.12.21
- 6.12.22
- 6.12.23
- 6.12.24
- 6.12.25
- 6.12.26
- 6.12.27
- 6.12.28
- 6.12.29
- 6.12.30
- 6.12.31
- 6.12.32
- 6.12.33
- 6.12.34
- 6.12.35
- 6.12.36
- 6.12.37
- 6.12.38
- 6.12.39
- 6.12.40
- 6.12.41
- 6.12.42
- 6.12.43
- 6.12.44
- 6.12.45
- 6.12.46
- 6.12.47
- 6.12.48
- 6.12.49
- 6.12.50
- 6.12.51
- 6.12.52
- 6.12.53
- 6.12.54
- 6.12.55
- 6.12.56
- 6.12.57
- 6.17.0
- 6.17.1
- 6.17.2
- 6.17.3
- 6.17.4
- 6.17.5
- 6.17.6
- 6.17.7
- 6.18-rc1
- 6.18-rc2
- 6.18-rc3
- 6.18-rc4
License
Website
- Vendor: https://www.kernel.org/
CPE 2.3
CPE 2.2
CVSSv4
VulDB Vector: 🔒VulDB Reliability: 🔍
CVSSv3
VulDB Meta Base Score: 5.5VulDB Meta Temp Score: 5.3
VulDB Base Score: 5.5
VulDB Temp Score: 5.3
VulDB Vector: 🔒
VulDB Reliability: 🔍
CVSSv2
| AV | AC | Au | C | I | A |
|---|---|---|---|---|---|
| 💳 | 💳 | 💳 | 💳 | 💳 | 💳 |
| 💳 | 💳 | 💳 | 💳 | 💳 | 💳 |
| 💳 | 💳 | 💳 | 💳 | 💳 | 💳 |
| Vector | Complexity | Authentication | Confidentiality | Integrity | Availability |
|---|---|---|---|---|---|
| Unlock | Unlock | Unlock | Unlock | Unlock | Unlock |
| Unlock | Unlock | Unlock | Unlock | Unlock | Unlock |
| Unlock | Unlock | Unlock | Unlock | Unlock | Unlock |
VulDB Base Score: 🔒
VulDB Temp Score: 🔒
VulDB Reliability: 🔍
Exploiting
Class: Return valueCWE: CWE-252 / CWE-253
CAPEC: 🔒
ATT&CK: 🔒
Physical: No
Local: No
Remote: Partially
Availability: 🔒
Status: Not defined
EPSS Score: 🔒
EPSS Percentile: 🔒
Price Prediction: 🔍
Current Price Estimation: 🔒
| 0-Day | Unlock | Unlock | Unlock | Unlock |
|---|---|---|---|---|
| Today | Unlock | Unlock | Unlock | Unlock |
Nessus ID: 276580
Nessus Name: Linux Distros Unpatched Vulnerability : CVE-2025-40209
Threat Intelligence
Interest: 🔍Active Actors: 🔍
Active APT Groups: 🔍
Countermeasures
Recommended: UpgradeStatus: 🔍
0-Day Time: 🔒
Upgrade: Kernel 6.12.58/6.17.8/6.18-rc5
Patch: 3412d0e973e8f8381747d69033eda809a57a2581/a4d9ebe23bcb79d9d057e3c995db73b7b3aae414/f260c6aff0b8af236084012d14f9f1bf792ea883
Timeline
04/16/2025 CVE reserved11/21/2025 Advisory disclosed
11/21/2025 VulDB entry created
05/19/2026 VulDB entry last update
Sources
Vendor: kernel.orgAdvisory: git.kernel.org
Status: Confirmed
CVE: CVE-2025-40209 (🔒)
GCVE (CVE): GCVE-0-2025-40209
GCVE (VulDB): GCVE-100-333203
CERT Bund: WID-SEC-2025-2658 - Linux Kernel: Mehrere Schwachstellen ermöglichen Denial of Service
Entry
Created: 11/21/2025 11:28Updated: 05/19/2026 19:13
Changes: 11/21/2025 11:28 (58), 11/21/2025 16:38 (7), 11/23/2025 05:24 (2), 01/06/2026 10:19 (1), 02/24/2026 13:54 (1), 05/19/2026 19:13 (1)
Complete: 🔍
Cache ID: 216::103
Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.
No comments yet. Languages: en.
Please log in to comment.