{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2025-40039","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","state":"PUBLISHED","assignerShortName":"Linux","dateReserved":"2025-04-16T07:20:57.153Z","datePublished":"2025-10-28T11:48:19.781Z","dateUpdated":"2026-08-05T12:07:13.052Z"},"containers":{"cna":{"providerMetadata":{"orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","shortName":"Linux","dateUpdated":"2026-08-05T12:07:13.052Z"},"descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nksmbd: Fix race condition in RPC handle list access\n\nThe 'sess->rpc_handle_list' XArray manages RPC handles within a ksmbd\nsession. Access to this list is intended to be protected by\n'sess->rpc_lock' (an rw_semaphore). However, the locking implementation was\nflawed, leading to potential race conditions.\n\nIn ksmbd_session_rpc_open(), the code incorrectly acquired only a read lock\nbefore calling xa_store() and xa_erase(). Since these operations modify\nthe XArray structure, a write lock is required to ensure exclusive access\nand prevent data corruption from concurrent modifications.\n\nFurthermore, ksmbd_session_rpc_method() accessed the list using xa_load()\nwithout holding any lock at all. This could lead to reading inconsistent\ndata or a potential use-after-free if an entry is concurrently removed and\nthe pointer is dereferenced.\n\nFix these issues by:\n1. Using down_write() and up_write() in ksmbd_session_rpc_open()\n   to ensure exclusive access during XArray modification, and ensuring\n   the lock is correctly released on error paths.\n2. Adding down_read() and up_read() in ksmbd_session_rpc_method()\n   to safely protect the lookup."}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":8.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:N - The vulnerable code is in ksmbd, the in-kernel SMB server, and is driven entirely by SMB2 requests (CREATE/CLOSE/IOCTL/READ/WRITE/QUERY_INFO) arriving over TCP port 445 from a remote peer. No local access is needed.\nAC:L - The attacker controls both sides of the race: the pipe handle is an attacker-chosen VolatileFileId, and ksmbd_queue_work() executes each SMB2 request on a separate ksmbd-io worker (plus SMB3 multichannel), so concurrent SMB2_CLOSE and SMB2_IOCTL/READ/WRITE requests run in parallel with unlimited retries.\nPR:L - Reaching create_smb2_pipe() requires a session in SMB2_SESSION_VALID state (ksmbd_session_lookup_all() rejects IN_PROGRESS) plus a tree connect to IPC$, i.e. any valid low-privileged SMB account; no administrative rights are needed, and with guest mapping enabled even credentials are unnecessary.\nUI:N - The entire sequence is performed by the attacker's own SMB client against the server; no action by any local user or administrator is required.\nS:U - The use-after-free corrupts kernel heap state within the same kernel security authority; no hypervisor, IOMMU, or sandbox boundary is crossed.\nC:H - The unlocked xa_load() dereferences a kfree()'d struct ksmbd_session_rpc, disclosing reused kernel heap contents as the RPC method flags; a UAF of this kind gives control over freed-object contents and can be leveraged into arbitrary kernel memory disclosure, and the resulting flags can steer the root ksmbd.mountd daemon into SAMR/LSARPC handlers the client never opened.\nI:H - The stale entry->method value read from a reused 8-byte slab object is heap-groomable by the attacker and directly selects which privileged RPC method the root-privileged userspace daemon executes with client-supplied payload; use-after-free conditions are generally leverageable into arbitrary-write and control-flow hijack primitives.\nA:H - Dereferencing the freed entry after the slab object or page has been released oopses the ksmbd worker thread, and the unsynchronized RPC handle teardown corrupts session state, yielding a repeatable remote kernel crash / denial of service."}]}],"affected":[{"product":"Linux","vendor":"Linux","defaultStatus":"unaffected","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/smb/server/mgmt/user_session.c"],"versions":[{"version":"a4348710a7267705b75692dc1a000920481d1d92","lessThan":"69674b029002b1d90b655f014bdf64f404efa54d","status":"affected","versionType":"git"},{"version":"b685757c7b08d5073046fb379be965fd6c06aafc","lessThan":"6b615a8fb3af0baf8126cde3d4fee97d57222ffc","status":"affected","versionType":"git"},{"version":"b685757c7b08d5073046fb379be965fd6c06aafc","lessThan":"5cc679ba0f4505936124cd4179ba66bb0a4bd9f3","status":"affected","versionType":"git"},{"version":"b685757c7b08d5073046fb379be965fd6c06aafc","lessThan":"6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1","status":"affected","versionType":"git"},{"version":"b685757c7b08d5073046fb379be965fd6c06aafc","lessThan":"305853cce379407090a73b38c5de5ba748893aee","status":"affected","versionType":"git"},{"version":"1f485b54d04a920723984062c912174330a05178","status":"affected","versionType":"git"},{"version":"052b41ef2abe274f068e892aee81406f11bd1f3a","status":"affected","versionType":"git"},{"version":"5.15.145","lessThan":"5.16","status":"affected","versionType":"semver"}]},{"product":"Linux","vendor":"Linux","defaultStatus":"affected","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["fs/smb/server/mgmt/user_session.c"],"versions":[{"version":"6.3","status":"affected"},{"version":"0","lessThan":"6.3","status":"unaffected","versionType":"semver"},{"version":"6.6.123","lessThanOrEqual":"6.6.*","status":"unaffected","versionType":"semver"},{"version":"6.12.53","lessThanOrEqual":"6.12.*","status":"unaffected","versionType":"semver"},{"version":"6.17.3","lessThanOrEqual":"6.17.*","status":"unaffected","versionType":"semver"},{"version":"6.18","lessThanOrEqual":"*","status":"unaffected","versionType":"original_commit_for_fix"}]}],"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.3","versionEndExcluding":"6.6.123"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.3","versionEndExcluding":"6.12.53"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.3","versionEndExcluding":"6.17.3"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.3","versionEndExcluding":"6.18"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.15.145"}]}]}],"references":[{"url":"https://git.kernel.org/stable/c/69674b029002b1d90b655f014bdf64f404efa54d"},{"url":"https://git.kernel.org/stable/c/6b615a8fb3af0baf8126cde3d4fee97d57222ffc"},{"url":"https://git.kernel.org/stable/c/5cc679ba0f4505936124cd4179ba66bb0a4bd9f3"},{"url":"https://git.kernel.org/stable/c/6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1"},{"url":"https://git.kernel.org/stable/c/305853cce379407090a73b38c5de5ba748893aee"}],"title":"ksmbd: Fix race condition in RPC handle list access","x_generator":{"engine":"bippy-1.2.0"}}}}