CVE-2025-40039: ksmbd: Fix race condition in RPC handle list access
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.
Security readout for executives and security teams
Plain-English summary
A concurrency flaw in Linux’s ksmbd SMB server can corrupt RPC handle tracking when authenticated users trigger overlapping operations. The resulting inconsistent or freed memory access could compromise confidentiality, integrity, or availability. Systems are exposed only when they run affected kernels with ksmbd enabled and reachable.
Executive priority
Treat as a high-priority patching issue for exposed ksmbd file servers. Accelerate remediation where SMB is internet-accessible or broadly reachable by untrusted authenticated users. Systems not using ksmbd have substantially lower practical exposure, but inventory evidence should confirm that status.
Technical view
The session RPC handle XArray was modified under a read lock and queried without locking. Concurrent store, erase, and lookup operations could corrupt XArray state or produce a use-after-free. The kernel fix uses exclusive locking for modifications, shared locking for lookups, and correct lock release on error paths.
Likely exposure
Prioritize Linux systems using the in-kernel ksmbd SMB server, especially network-reachable file servers permitting low-privileged authenticated access. The supplied affected-version data is irregular and insufficient for reliable range determination; confirm exposure using distribution advisories, kernel package changelogs, and referenced fix commits.
Exploitation context
The supplied CVSS is 8.8 with network access, low complexity, low privileges, and no user interaction. However, the bundle marks KEV false and provides no evidence of active exploitation, public proof-of-concept availability, or confirmed attacks. Successful exploitation would likely depend on winning a concurrency race.
Researcher notes
The core issue is unsafe synchronization around sess->rpc_handle_list. Modification required write locking, while lookup required read locking to prevent inconsistent reads and use-after-free. The supplied version entries include unusual values and duplicate commit identifiers, so commit-level or distribution-specific verification is more reliable than interpreting the version list alone.
Mitigation direction
Install a vendor-supported kernel update containing the referenced ksmbd locking fixes.
If immediate patching is impossible, disable ksmbd where operationally acceptable.
Restrict SMB exposure to trusted networks and authorized users.
Check Linux distribution guidance for package-specific fixed versions.
Validation and detection
Confirm whether ksmbd is enabled, loaded, and serving SMB connections.
Identify the running kernel and distribution package release.
Check package changelogs for CVE-2025-40039 or referenced fix commits.
Verify SMB access is restricted to intended networks and accounts.
After updating, confirm the corrected kernel is running.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2025-40039 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
1CVSS vectors
3Timeline events
0ADP providers
6Source links
CVSS vector scores
1 official score
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.