From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 71ABD3E49FD; Tue, 21 Jul 2026 22:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671805; cv=none; b=ugHxm+8Eo3vyf1Ee6UXYjpdfOk/d0FPCEoCOWRBFVKFUynyr4CCsPRAuDYMjCz+asxiH+Nxszz3QQyvYpjWZAtbTMTs3tLe4wIfVxsg+87hb96MFNzBjo9mNJeJ1lDQus1CsMiDlBJ6KaxA37Oe5bWW3O4j2r1lqzPMXGXQjMjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671805; c=relaxed/simple; bh=Vx0B1n4Vt0H4G71JSLSwVXyNB63yFlFcg3OV7qH+1qo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZCm87QioP/aB/8jh4IVXRS9FQT7XjSxRNMkk6NijXdCRdy77nV8UrEzMSar6QvkTA6qIAwXsY3F34FcE0ItDvpdPflyxYe+K+scWT6uusfccdtRT+Yh3T4jKzIl02eTGoevjIv18rOdoabfItNCX4Il4aslEPIYyzmGDWDDe+wU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lB2Mmhbw; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lB2Mmhbw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2CEE1F000E9; Tue, 21 Jul 2026 22:10:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784671804; bh=uKj3+2KphTXvW04Gqvj7EAEJT6SU2qdswvwt7oKJRDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lB2MmhbwDpiGJ5Ju426tnL4O32iXUSyWAnRXEMeqg7vk79HVzijMZ8ZOyxLmU9kVy +OKJrTwiwlXjARXRVJr6q7+5p29tlaSXQGX9CAQ0q3boOZErW3akHKXMB7TYRlwxIm 4LglUyEexj65qar/R2Fa1i+xsFGon357zk7AXcc4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Runyu Xiao , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 358/843] kcm: use WRITE_ONCE() when changing lower socket callbacks Date: Tue, 21 Jul 2026 17:19:53 +0200 Message-ID: <20260721152414.085487493@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Runyu Xiao [ Upstream commit 47186409c092cd7dd70350999186c700233e854d ] kcm_attach() replaces a live lower TCP socket's sk_data_ready and sk_write_space callbacks with KCM handlers, and kcm_unattach() restores them later. Those callback-pointer updates are still plain stores even though the same fields can be read and invoked concurrently on other CPUs. If another CPU observes an older callback snapshot after the live field has already been restored, callback execution can run with a mismatched target and sk_user_data state, leading to stale or misdirected wakeups. Use WRITE_ONCE() for the callback replacement and restore operations so these shared callback fields follow the same visibility contract already established by the earlier 4022 fixes. Fixes: ab7ac4eb9832 ("kcm: Kernel Connection Multiplexor module") Signed-off-by: Runyu Xiao Link: https://patch.msgid.link/20260611053543.2429462-1-runyu.xiao@seu.edu.cn Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/kcm/kcmsock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index a3b281f7a99bc4..a0533400af808c 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1404,8 +1404,8 @@ static int kcm_attach(struct socket *sock, struct socket *csock, psock->save_write_space = csk->sk_write_space; psock->save_state_change = csk->sk_state_change; csk->sk_user_data = psock; - csk->sk_data_ready = psock_data_ready; - csk->sk_write_space = psock_write_space; + WRITE_ONCE(csk->sk_data_ready, psock_data_ready); + WRITE_ONCE(csk->sk_write_space, psock_write_space); csk->sk_state_change = psock_state_change; write_unlock_bh(&csk->sk_callback_lock); @@ -1481,8 +1481,8 @@ static void kcm_unattach(struct kcm_psock *psock) */ write_lock_bh(&csk->sk_callback_lock); csk->sk_user_data = NULL; - csk->sk_data_ready = psock->save_data_ready; - csk->sk_write_space = psock->save_write_space; + WRITE_ONCE(csk->sk_data_ready, psock->save_data_ready); + WRITE_ONCE(csk->sk_write_space, psock->save_write_space); csk->sk_state_change = psock->save_state_change; strp_stop(&psock->strp); -- 2.53.0