CVE-2025-40039

Source
https://cve.org/CVERecord?id=CVE-2025-40039
Import Source
https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-40039.json
JSON Data
https://api.osv.dev/v1/vulns/CVE-2025-40039
Downstream
Related
Published
2025-10-28T11:48:19.781Z
Modified
2026-03-23T05:11:27.671909946Z
Summary
ksmbd: Fix race condition in RPC handle list access
Details

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

ksmbd: Fix race condition in RPC handle list access

The 'sess->rpchandlelist' XArray manages RPC handles within a ksmbd session. Access to this list is intended to be protected by 'sess->rpclock' (an rwsemaphore). However, the locking implementation was flawed, leading to potential race conditions.

In ksmbdsessionrpcopen(), the code incorrectly acquired only a read lock before calling xastore() 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, ksmbdsessionrpcmethod() accessed the list using xaload() 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 downwrite() and upwrite() in ksmbdsessionrpcopen() to ensure exclusive access during XArray modification, and ensuring the lock is correctly released on error paths. 2. Adding downread() and upread() in ksmbdsessionrpcmethod() to safely protect the lookup.

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/40xxx/CVE-2025-40039.json"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
a4348710a7267705b75692dc1a000920481d1d92
Fixed
69674b029002b1d90b655f014bdf64f404efa54d
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
b685757c7b08d5073046fb379be965fd6c06aafc
Fixed
6b615a8fb3af0baf8126cde3d4fee97d57222ffc
Fixed
5cc679ba0f4505936124cd4179ba66bb0a4bd9f3
Fixed
6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1
Fixed
305853cce379407090a73b38c5de5ba748893aee
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
0 Unknown introduced commit / All previous commits are affected
Last affected
1f485b54d04a920723984062c912174330a05178
Last affected
052b41ef2abe274f068e892aee81406f11bd1f3a

Database specific

source
"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-40039.json"