{"id":"CVE-2025-40039","summary":"ksmbd: Fix race condition in RPC handle list access","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nksmbd: Fix race condition in RPC handle list access\n\nThe 'sess-\u003erpc_handle_list' XArray manages RPC handles within a ksmbd\nsession. Access to this list is intended to be protected by\n'sess-\u003erpc_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.","modified":"2026-03-20T12:43:09.266376Z","published":"2025-10-28T11:48:19.781Z","related":["openSUSE-SU-2025:15702-1","openSUSE-SU-2026:10301-1"],"database_specific":{"cna_assigner":"Linux","osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/40xxx/CVE-2025-40039.json"},"references":[{"type":"WEB","url":"https://git.kernel.org/stable/c/305853cce379407090a73b38c5de5ba748893aee"},{"type":"WEB","url":"https://git.kernel.org/stable/c/5cc679ba0f4505936124cd4179ba66bb0a4bd9f3"},{"type":"WEB","url":"https://git.kernel.org/stable/c/69674b029002b1d90b655f014bdf64f404efa54d"},{"type":"WEB","url":"https://git.kernel.org/stable/c/6b615a8fb3af0baf8126cde3d4fee97d57222ffc"},{"type":"WEB","url":"https://git.kernel.org/stable/c/6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/40xxx/CVE-2025-40039.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-40039"},{"type":"PACKAGE","url":"https://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"},{"last_affected":"1f485b54d04a920723984062c912174330a05178"},{"last_affected":"052b41ef2abe274f068e892aee81406f11bd1f3a"}]}],"database_specific":{"source":"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-40039.json"}}],"schema_version":"1.7.5"}