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.
[
{
"signature_type": "Function",
"digest": {
"function_hash": "266562057513773730007998792081947424301",
"length": 809.0
},
"target": {
"file": "fs/smb/server/mgmt/user_session.c",
"function": "ksmbd_session_rpc_open"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1",
"id": "CVE-2025-40039-0f30dbca",
"deprecated": false,
"signature_version": "v1"
},
{
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"337566753483343490840431961593447723004",
"294605926555120234989819976711804808307",
"86315011534474434423814153753486174769",
"159856211502976868090248011298555650851",
"43193578365954758414812680120279962107",
"175662373062040952800086281338126726474",
"329425174821298231519442477882553847647",
"1872302389080047574122018150567093027",
"204740422948976573865836598920181289627",
"91354832398541238590343349083097163690",
"161882192596384315020885273095349104448",
"102200254867683314197196145651307890154",
"16260803909589468172582411947430966062",
"158371437439797100060088395628086898356",
"251577904853296210238819690244030992930",
"267298251400172636316730341565805739048",
"178900731704647933234501224886341078315",
"59008599647916747938833114924441875143",
"277557022212954019118998997955958030885",
"290391961774705267205557076082192113469",
"237113424920044827818504471835528062342",
"257590556037609968467821770696039849192",
"140862153186387191980476058414580927506",
"327115049206847172298311452259772224177",
"268301508340216504236085562855136095243",
"164832911895713730804431420398309515390",
"327354573362352853784641199924712673153",
"276925645339470774667654893701788632342",
"84129160537201508472243007315269775807",
"229489283003389811919360589182704726382"
]
},
"target": {
"file": "fs/smb/server/mgmt/user_session.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@305853cce379407090a73b38c5de5ba748893aee",
"id": "CVE-2025-40039-26912239",
"deprecated": false,
"signature_version": "v1"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "314928323857115072486438885387057892266",
"length": 153.0
},
"target": {
"file": "fs/smb/server/mgmt/user_session.c",
"function": "ksmbd_session_rpc_method"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@305853cce379407090a73b38c5de5ba748893aee",
"id": "CVE-2025-40039-3078c5ea",
"deprecated": false,
"signature_version": "v1"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "314928323857115072486438885387057892266",
"length": 153.0
},
"target": {
"file": "fs/smb/server/mgmt/user_session.c",
"function": "ksmbd_session_rpc_method"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5cc679ba0f4505936124cd4179ba66bb0a4bd9f3",
"id": "CVE-2025-40039-330e2597",
"deprecated": false,
"signature_version": "v1"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "314928323857115072486438885387057892266",
"length": 153.0
},
"target": {
"file": "fs/smb/server/mgmt/user_session.c",
"function": "ksmbd_session_rpc_method"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1",
"id": "CVE-2025-40039-48979c42",
"deprecated": false,
"signature_version": "v1"
},
{
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"337566753483343490840431961593447723004",
"294605926555120234989819976711804808307",
"86315011534474434423814153753486174769",
"159856211502976868090248011298555650851",
"43193578365954758414812680120279962107",
"175662373062040952800086281338126726474",
"329425174821298231519442477882553847647",
"1872302389080047574122018150567093027",
"204740422948976573865836598920181289627",
"91354832398541238590343349083097163690",
"161882192596384315020885273095349104448",
"102200254867683314197196145651307890154",
"16260803909589468172582411947430966062",
"158371437439797100060088395628086898356",
"251577904853296210238819690244030992930",
"267298251400172636316730341565805739048",
"178900731704647933234501224886341078315",
"59008599647916747938833114924441875143",
"277557022212954019118998997955958030885",
"290391961774705267205557076082192113469",
"237113424920044827818504471835528062342",
"257590556037609968467821770696039849192",
"140862153186387191980476058414580927506",
"327115049206847172298311452259772224177",
"268301508340216504236085562855136095243",
"164832911895713730804431420398309515390",
"327354573362352853784641199924712673153",
"276925645339470774667654893701788632342",
"84129160537201508472243007315269775807",
"229489283003389811919360589182704726382"
]
},
"target": {
"file": "fs/smb/server/mgmt/user_session.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1",
"id": "CVE-2025-40039-696b6ff3",
"deprecated": false,
"signature_version": "v1"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "266562057513773730007998792081947424301",
"length": 809.0
},
"target": {
"file": "fs/smb/server/mgmt/user_session.c",
"function": "ksmbd_session_rpc_open"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@305853cce379407090a73b38c5de5ba748893aee",
"id": "CVE-2025-40039-8328a73c",
"deprecated": false,
"signature_version": "v1"
},
{
"signature_type": "Function",
"digest": {
"function_hash": "266562057513773730007998792081947424301",
"length": 809.0
},
"target": {
"file": "fs/smb/server/mgmt/user_session.c",
"function": "ksmbd_session_rpc_open"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5cc679ba0f4505936124cd4179ba66bb0a4bd9f3",
"id": "CVE-2025-40039-b722eab3",
"deprecated": false,
"signature_version": "v1"
},
{
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"337566753483343490840431961593447723004",
"294605926555120234989819976711804808307",
"86315011534474434423814153753486174769",
"159856211502976868090248011298555650851",
"43193578365954758414812680120279962107",
"175662373062040952800086281338126726474",
"329425174821298231519442477882553847647",
"1872302389080047574122018150567093027",
"204740422948976573865836598920181289627",
"91354832398541238590343349083097163690",
"161882192596384315020885273095349104448",
"102200254867683314197196145651307890154",
"16260803909589468172582411947430966062",
"158371437439797100060088395628086898356",
"251577904853296210238819690244030992930",
"267298251400172636316730341565805739048",
"178900731704647933234501224886341078315",
"59008599647916747938833114924441875143",
"277557022212954019118998997955958030885",
"290391961774705267205557076082192113469",
"237113424920044827818504471835528062342",
"257590556037609968467821770696039849192",
"140862153186387191980476058414580927506",
"327115049206847172298311452259772224177",
"268301508340216504236085562855136095243",
"164832911895713730804431420398309515390",
"327354573362352853784641199924712673153",
"276925645339470774667654893701788632342",
"84129160537201508472243007315269775807",
"229489283003389811919360589182704726382"
]
},
"target": {
"file": "fs/smb/server/mgmt/user_session.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5cc679ba0f4505936124cd4179ba66bb0a4bd9f3",
"id": "CVE-2025-40039-ffb22e1b",
"deprecated": false,
"signature_version": "v1"
}
]