Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF8CC30C619 for ; Tue, 28 Oct 2025 11:50:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761652231; cv=none; b=Qlf6dfgIY+q3On89CTRQ4ASFohA8HyzOpTPfUTCUWteenXL8r7CgWnOpZwrARhxPTySfFTVio8GzPEKc01gRwXeeL2q3TB2RfXs48v7v9xmk1AhpdMv6h9QKyNTxUOvE8tp8iWkzFzkwfaGi9XnuWBeAFFUO3J8iEKztBQbL9yk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761652231; c=relaxed/simple; bh=rseToHv42BFySrsO5Id45D6zZ/of3K4CObg0lTNL0UM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ay0s26fipc3SqR7xY6CLM1ivrSx3wT+xuFhV+eBxRmeuck3FUIwQBlu6iF0QtjMlBW/jMeD+fq5hEYfgK1oZ14sgSxzQvN26+03+kLiiTlirOFII6utns3LayS3eIzQjWE3UYST3loAFkdUUPuDfB6JXMpq8jNtqcouJG6Hfwso= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TBmPkI6K; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TBmPkI6K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE1A9C4CEE7; Tue, 28 Oct 2025 11:50:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1761652231; bh=rseToHv42BFySrsO5Id45D6zZ/of3K4CObg0lTNL0UM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=TBmPkI6KktQMEIq7GMtczWxOh0zcV+rrlquFZB02cGxFADNEWRj5+cYP+kqBT88ZK Ur7mJ9GNHL603wwVzK9UnYm643OcA+8atWTAAwv0170VKs5itxPGqKSioUPpp1jsd2 aijpLH7aLFxmYTiVcB13mdTL85KwCqO8xfRwaZFc= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-40039: ksmbd: Fix race condition in RPC handle list access Date: Tue, 28 Oct 2025 12:48:16 +0100 Message-ID: <2025102812-CVE-2025-40039-2d65@gregkh> X-Mailer: git-send-email 2.51.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3276; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Rr63TNZNR+1jJ7FX9+gtHmL/6v/dWTCevyGzzlwXXoQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDJkMa2vCW83Nyg3MH2xpOJr739D+Qv5B7yO5YnU/U6bxl SzUOvW2I5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACay8SPDXAHLVQtNbT4cMjrS umKHWswEh67SjwwL1n3l0pg55/6v1J+rWE1XFxhuq0rzBwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== 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. The Linux kernel CVE team has assigned CVE-2025-40039 to this issue. Affected and fixed versions =========================== Issue introduced in 6.3 with commit b685757c7b08d5073046fb379be965fd6c06aafc and fixed in 6.12.53 with commit 5cc679ba0f4505936124cd4179ba66bb0a4bd9f3 Issue introduced in 6.3 with commit b685757c7b08d5073046fb379be965fd6c06aafc and fixed in 6.17.3 with commit 6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1 Issue introduced in 6.3 with commit b685757c7b08d5073046fb379be965fd6c06aafc and fixed in 6.18-rc1 with commit 305853cce379407090a73b38c5de5ba748893aee Issue introduced in 5.15.145 with commit 1f485b54d04a920723984062c912174330a05178 Issue introduced in 6.1.71 with commit 052b41ef2abe274f068e892aee81406f11bd1f3a Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2025-40039 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: fs/smb/server/mgmt/user_session.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/5cc679ba0f4505936124cd4179ba66bb0a4bd9f3 https://git.kernel.org/stable/c/6bd7e0e55dcea2cf0d391bbc21c2eb069b4be3e1 https://git.kernel.org/stable/c/305853cce379407090a73b38c5de5ba748893aee