{"id":"CVE-2025-40039","aliases":["CVE-2025-40039"],"related":[],"kind":"vulnerability","state":"published","title":"ksmbd: Fix race condition in RPC handle list access","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nksmbd: Solución de condición de carrera en el acceso a la lista de manejadores RPC\n\nEl XArray 'sess->rpc_handle_list' gestiona los manejadores RPC dentro de una sesión ksmbd. El acceso a esta lista está destinado a ser protegido por 'sess->rpc_lock' (un rw_semaphore). Sin embargo, la implementación del bloqueo era defectuosa, lo que llevaba a potenciales condiciones de carrera.\n\nEn ksmbd_session_rpc_open(), el código adquirió incorrectamente solo un bloqueo de lectura antes de llamar a xa_store() y xa_erase(). Dado que estas operaciones modifican la estructura del XArray, se requiere un bloqueo de escritura para asegurar el acceso exclusivo y prevenir la corrupción de datos por modificaciones concurrentes.\n\nAdemás, ksmbd_session_rpc_method() accedió a la lista usando xa_load() sin mantener ningún bloqueo en absoluto. Esto podría llevar a la lectura de datos inconsistentes o a un potencial uso después de liberación si una entrada es eliminada concurrentemente y el puntero es desreferenciado.\n\nSe solucionan estos problemas de la siguiente manera:\n1. Usando down_write() y up_write() en ksmbd_session_rpc_open() para asegurar el acceso exclusivo durante la modificación del XArray, y asegurando que el bloqueo se libere correctamente en las rutas de error.\n2. Añadiendo down_read() y up_read() en ksmbd_session_rpc_method() para proteger de forma segura la búsqueda.","source":"nvd"}],"published":"2025-10-28T11:48:19.781Z","modified":"2026-10-19T21:10:00.160Z","severity":{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},"severities":[{"scorer":"Linux","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H","score":4.7,"rating":"MEDIUM"}],"cwes":["CWE-362"],"affected":[{"ranges":[{"type":"git","introduced":"a4348710a7267705b75692dc1a000920481d1d92","fixed":"69674b029002b1d90b655f014bdf64f404efa54d","status":"affected"},{"type":"git","introduced":"b685757c7b08d5073046fb379be965fd6c06aafc","fixed":"6b615a8fb3af0baf8126cde3d4fee97d57222ffc","status":"affected"},{"type":"git","introduced":"b685757c7b08d5073046fb379be965fd6c06aafc","fixed":"5cc679ba0f4505936124cd4179ba66bb0a4bd9f3","status":"affected"},{"type":"git","introduced":"b685757c7b08d5073046fb379be965fd6c06aafc","fixed":"6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1","status":"affected"},{"type":"git","introduced":"b685757c7b08d5073046fb379be965fd6c06aafc","fixed":"305853cce379407090a73b38c5de5ba748893aee","status":"affected"},{"type":"git","version":"1f485b54d04a920723984062c912174330a05178","status":"affected"},{"type":"git","version":"052b41ef2abe274f068e892aee81406f11bd1f3a","status":"affected"},{"type":"semver","introduced":"5.15.145","fixed":"5.16","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"6.3","status":"affected"},{"type":"semver","introduced":"0","fixed":"6.3","status":"unaffected"},{"type":"semver","introduced":"6.6.123","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.53","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.17.3","lastAffected":"6.17.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"6.18","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"5.15.145","fixed":"5.16"},{"status":"affected","introduced":"6.1.71","fixed":"6.2"},{"status":"affected","introduced":"6.3","fixed":"6.6.123"},{"status":"affected","introduced":"6.7","fixed":"6.12.53"},{"status":"affected","introduced":"6.13","fixed":"6.17.3"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/69674b029002b1d90b655f014bdf64f404efa54d","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/6b615a8fb3af0baf8126cde3d4fee97d57222ffc","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/5cc679ba0f4505936124cd4179ba66bb0a4bd9f3","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1","tags":["patch"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/305853cce379407090a73b38c5de5ba748893aee","tags":["patch"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-40039","url":"https://www.cve.org/CVERecord?id=CVE-2025-40039","licence":"CVE Terms of Use","modified":"2026-08-05T12:07:13.052Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-40039","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-40039","licence":"Public domain","modified":"2026-10-19T21:10:00.160Z"}],"updatedAt":"2026-11-25T22:59:06.928Z","epss":{"score":0.00317,"percentile":0.26607,"date":"2026-12-01T12:00:22.000Z"}}