# CVE-2025-40007: netfs: fix reference leak

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** UNSCORED
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Unknown
- **EPSS:** 0.26% (percentile 11, 2026-11-28)
- **Published:** 2025-10-20T15:26:53.880Z
- **Modified:** 2026-10-19T21:10:00.160Z

## Who should check

- Anyone running Linux \>= 20d72b00ca814d748f5663484e5c53bb2bf37a3a, \< 8df142e93098b4531fadb5dfcf93087649f570b3; \>= 20d72b00ca814d748f5663484e5c53bb2bf37a3a, \< 4d428dca252c858bfac691c31fa95d26cd008706; 1a8360c2eed3b292ed654c2ac61b09de4a80e298; \>= 6.15.3, \< 6.16
- Anyone running Linux 6.16

## Description

In the Linux kernel, the following vulnerability has been resolved:

netfs: fix reference leak

Commit 20d72b00ca81 ("netfs: Fix the request's work item to not
require a ref") modified netfs\_alloc\_request() to initialize the
reference counter to 2 instead of 1.  The rationale was that the
requet's "work" would release the second reference after completion
(via netfs\_{read,write}\_collection\_worker()).  That works most of the
time if all goes well.

However, it leaks this additional reference if the request is released
before the I/O operation has been submitted: the error code path only
decrements the reference counter once and the work item will never be
queued because there will never be a completion.

This has caused outages of our whole server cluster today because
tasks were blocked in netfs\_wait\_for\_outstanding\_io(), leading to
deadlocks in Ceph (another bug that I will address soon in another
patch).  This was caused by a netfs\_pgpriv2\_begin\_copy\_to\_cache() call
which failed in fscache\_begin\_write\_operation().  The leaked
netfs\_io\_request was never completed, leaving \`netfs\_inode.io\_count\`
with a positive value forever.

All of this is super-fragile code.  Finding out which code paths will
lead to an eventual completion and which do not is hard to see:

- Some functions like netfs\_create\_write\_req() allocate a request, but
  will never submit any I/O.

- netfs\_unbuffered\_read\_iter\_locked() calls netfs\_unbuffered\_read()
  and then netfs\_put\_request(); however, netfs\_unbuffered\_read() can
  also fail early before submitting the I/O request, therefore another
  netfs\_put\_request() call must be added there.

A rule of thumb is that functions that return a \`netfs\_io\_request\` do
not submit I/O, and all of their callers must be checked.

For my taste, the whole netfs code needs an overhaul to make reference
counting easier to understand and less fragile & obscure.  But to fix
this bug here and now and produce a patch that is adequate for a
stable backport, I tried a minimal approach that quickly frees the
request object upon early failure.

I decided against adding a second netfs\_put\_request() each time
because that would cause code duplication which obscures the code
further.  Instead, I added the function netfs\_put\_failed\_request()
which frees such a failed request synchronously under the assumption
that the reference count is exactly 2 (as initially set by
netfs\_alloc\_request() and never touched), verified by a
WARN\_ON\_ONCE().  It then deinitializes the request object (without
going through the "cleanup\_work" indirection) and frees the allocation
(with RCU protection to protect against concurrent access by
netfs\_requests\_seq\_start()).

All code paths that fail early have been changed to call
netfs\_put\_failed\_request() instead of netfs\_put\_request().
Additionally, I have added a netfs\_put\_request() call to
netfs\_unbuffered\_read() as explained above because the
netfs\_put\_failed\_request() approach does not work there.

## Affected and fixed versions

- Linux: \>= 20d72b00ca814d748f5663484e5c53bb2bf37a3a, \< 8df142e93098b4531fadb5dfcf93087649f570b3; \>= 20d72b00ca814d748f5663484e5c53bb2bf37a3a, \< 4d428dca252c858bfac691c31fa95d26cd008706; 1a8360c2eed3b292ed654c2ac61b09de4a80e298; \>= 6.15.3, \< 6.16 (cvelist)
- Linux: 6.16 (cvelist)

## Mitigation

- Upgrade Linux to 6.16 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2025-40007. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-40007.md
Affected: Linux >= 20d72b00ca814d748f5663484e5c53bb2bf37a3a, < 8df142e93098b4531fadb5dfcf93087649f570b3; >= 20d72b00ca814d748f5663484e5c53bb2bf37a3a, < 4d428dca252c858bfac691c31fa95d26cd008706; 1a8360c2eed3b292ed654c2ac61b09de4a80e298; >= 6.15.3, < 6.16; Linux 6.16
Fixed in: Linux 8df142e93098b4531fadb5dfcf93087649f570b3, Linux 4d428dca252c858bfac691c31fa95d26cd008706, Linux 6.16

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2025-40007 being exploited?

There is no confirmed exploitation: CVE-2025-40007 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.26% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2025-40007?

It has no CVSS score yet. Unknown.

### Which versions are affected by CVE-2025-40007?

Linux \>= 20d72b00ca814d748f5663484e5c53bb2bf37a3a, \< 8df142e93098b4531fadb5dfcf93087649f570b3; \>= 20d72b00ca814d748f5663484e5c53bb2bf37a3a, \< 4d428dca252c858bfac691c31fa95d26cd008706; 1a8360c2eed3b292ed654c2ac61b09de4a80e298; \>= 6.15.3, \< 6.16; Linux 6.16.

### Is there a fix for CVE-2025-40007?

Yes. Fixed in Linux 8df142e93098b4531fadb5dfcf93087649f570b3, Linux 4d428dca252c858bfac691c31fa95d26cd008706, Linux 6.16. Upgrade Linux to 6.16 or later.

### How do I check if I'm affected by CVE-2025-40007?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- other: <https://git.kernel.org/stable/c/8df142e93098b4531fadb5dfcf93087649f570b3>
- other: <https://git.kernel.org/stable/c/4d428dca252c858bfac691c31fa95d26cd008706>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2025-40007>

HTML: <https://flawdb.com/CVE-2025-40007> · JSON: <https://flawdb.com/api/v1/entries/CVE-2025-40007>
