# CVE-2025-40039: ksmbd: Fix race condition in RPC handle list access

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

- **Severity:** HIGH 8.8
- **CVSS:** 8.8 (v3.1, CNA) `CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Network; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, login needed
- **EPSS:** 0.32% (percentile 27, 2026-12-02)
- **CWE:** CWE-362
- **Published:** 2025-10-28T11:48:19.781Z
- **Modified:** 2026-10-19T21:10:00.160Z

## Who should check

- Anyone running Linux \>= a4348710a7267705b75692dc1a000920481d1d92, \< 69674b029002b1d90b655f014bdf64f404efa54d; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 6b615a8fb3af0baf8126cde3d4fee97d57222ffc; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 5cc679ba0f4505936124cd4179ba66bb0a4bd9f3; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 305853cce379407090a73b38c5de5ba748893aee; 1f485b54d04a920723984062c912174330a05178; 052b41ef2abe274f068e892aee81406f11bd1f3a; \>= 5.15.145, \< 5.16
- Anyone running Linux 6.3

## Description

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

ksmbd: Fix race condition in RPC handle list access

The 'sess-\>rpc\_handle\_list' XArray manages RPC handles within a ksmbd
session. Access to this list is intended to be protected by
'sess-\>rpc\_lock' (an rw\_semaphore). However, the locking implementation was
flawed, leading to potential race conditions.

In ksmbd\_session\_rpc\_open(), the code incorrectly acquired only a read lock
before calling xa\_store() and xa\_erase(). Since these operations modify
the XArray structure, a write lock is required to ensure exclusive access
and prevent data corruption from concurrent modifications.

Furthermore, ksmbd\_session\_rpc\_method() accessed the list using xa\_load()
without holding any lock at all. This could lead to reading inconsistent
data or a potential use-after-free if an entry is concurrently removed and
the pointer is dereferenced.

Fix these issues by:
1. Using down\_write() and up\_write() in ksmbd\_session\_rpc\_open()
   to ensure exclusive access during XArray modification, and ensuring
   the lock is correctly released on error paths.
2. Adding down\_read() and up\_read() in ksmbd\_session\_rpc\_method()
   to safely protect the lookup.

## Affected and fixed versions

- Linux: \>= a4348710a7267705b75692dc1a000920481d1d92, \< 69674b029002b1d90b655f014bdf64f404efa54d; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 6b615a8fb3af0baf8126cde3d4fee97d57222ffc; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 5cc679ba0f4505936124cd4179ba66bb0a4bd9f3; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 305853cce379407090a73b38c5de5ba748893aee; 1f485b54d04a920723984062c912174330a05178; 052b41ef2abe274f068e892aee81406f11bd1f3a; \>= 5.15.145, \< 5.16 (cvelist)
- Linux: 6.3 (cvelist)

## Mitigation

- Upgrade Linux to 5.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-40039. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2025-40039.md
Affected: Linux >= a4348710a7267705b75692dc1a000920481d1d92, < 69674b029002b1d90b655f014bdf64f404efa54d; >= b685757c7b08d5073046fb379be965fd6c06aafc, < 6b615a8fb3af0baf8126cde3d4fee97d57222ffc; >= b685757c7b08d5073046fb379be965fd6c06aafc, < 5cc679ba0f4505936124cd4179ba66bb0a4bd9f3; >= b685757c7b08d5073046fb3…
Fixed in: Linux 69674b029002b1d90b655f014bdf64f404efa54d, Linux 6b615a8fb3af0baf8126cde3d4fee97d57222ffc, Linux 5cc679ba0f4505936124cd4179ba66bb0a4bd9f3, Linux 6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1, Linux 305853cce379407090a73b38c5de5ba748893aee, Linux 5.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-40039 being exploited?

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

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

High: CVSS 8.8 (v3.1, scored by CNA). Remote, login needed.

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

Linux \>= a4348710a7267705b75692dc1a000920481d1d92, \< 69674b029002b1d90b655f014bdf64f404efa54d; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 6b615a8fb3af0baf8126cde3d4fee97d57222ffc; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 5cc679ba0f4505936124cd4179ba66bb0a4bd9f3; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1; \>= b685757c7b08d5073046fb379be965fd6c06aafc, \< 305853cce379407090a73b38c5de5ba748893aee; 1f485b54d04a920723984062c912174330a05178; 052b41ef2abe274f068e892aee81406f11bd1f3a; \>= 5.15.145, \< 5.16; Linux 6.3.

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

Yes. Fixed in Linux 69674b029002b1d90b655f014bdf64f404efa54d, Linux 6b615a8fb3af0baf8126cde3d4fee97d57222ffc, Linux 5cc679ba0f4505936124cd4179ba66bb0a4bd9f3, Linux 6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1, Linux 305853cce379407090a73b38c5de5ba748893aee, Linux 5.16. Upgrade Linux to 5.16 or later.

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

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

- patch: <https://git.kernel.org/stable/c/69674b029002b1d90b655f014bdf64f404efa54d>
- patch: <https://git.kernel.org/stable/c/6b615a8fb3af0baf8126cde3d4fee97d57222ffc>
- patch: <https://git.kernel.org/stable/c/5cc679ba0f4505936124cd4179ba66bb0a4bd9f3>
- patch: <https://git.kernel.org/stable/c/6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1>
- patch: <https://git.kernel.org/stable/c/305853cce379407090a73b38c5de5ba748893aee>

## 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-40039>

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