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 EBFD25012A5; Wed, 30 Sep 2026 16:16:09 +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=1790784972; cv=none; b=EKJmsVRRXQsj8HTYn+NYYbI9I4sZjkg7FHDTBde+AMMwkYxxrRMZ8yrzZ7ZU7jFsys17okB/5kO37ckNhvL+G6M3FcFs90SbS6gH2ErF+Zq9cXkodO2GsIuKGXb40jk/6G/46RcSDVnKRSvvfL1qoRNkuWQh+1Qqg2RzJn5FYQo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790784972; c=relaxed/simple; bh=fAI9bkA/dM4Wuag6RVAgj/B6J834A5yiOIOXqZMnLjY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WN5cg8yiJesPbPqhK8IE638IH4uJt4nv6Oh1nThBqKPKzhOkMkagW9QxtoRjzOiLP/AabqKTK3Kh9wEV2oqgWJMqYs9b7OmbBBav5VtUP3SxZaFKzVJqKZhw/31Z+nP/U3kqkfZVNNFiOMhHJcrz0bGCRVJqxo5m8keCRtBp70E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jPus4Rfq; 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="jPus4Rfq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A56B51F000FF; Wed, 30 Sep 2026 16:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790784966; bh=uzH6xicN4ikhFiU+dqt2sLIKVlfD/B+RHMJ//zvZnSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jPus4RfqMkRu8L4Tl5eQX3c//bV59qlkXsOiCEq4Ox1baXBSSHyht7YHa/KYAbh8N Lugdd1nl7U7TvVXChAPrk7G+fAIummme1GE9nQEy6nCvhbXAPVN7gvraUv1JwVnfCq DVyud/WoRcnNZ+2VLGmz6BuZ8cEKSh0pfCj9dIV8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Runyu Xiao , Jackie Liu , Xuanqiang Luo , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 340/982] raw: annotate disconnect-side IPv4 match writers Date: Wed, 30 Sep 2026 17:17:56 +0200 Message-ID: <20260930152424.120190791@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xuanqiang Luo [ Upstream commit ac08d183dac0441e41f77bbad50798fe609d90f1 ] raw_v4_match() reads inet_daddr, inet_rcv_saddr and sk_bound_dev_if locklessly under RCU. Bind and connect writers are annotated, but __udp_disconnect() still clears the same fields using plain stores. Commit 18f116931f52e ("raw: annotate lockless match fields in raw_v4_match()") added the lockless readers and annotated the raw bind and datagram connect writers. Its v4 revision intentionally left the shared disconnect-side IPv4 writers for follow-up cleanup. Complete that follow-up by using WRITE_ONCE() for the disconnect-side stores, including the inet_rcv_saddr reset in inet_reset_saddr(), to pair with the lockless raw socket matcher. Fixes: 0daf07e52709 ("raw: convert raw sockets to RCU") Link: https://lore.kernel.org/netdev/20260716142958.3064224-1-runyu.xiao@seu.edu.cn/ Suggested-by: Runyu Xiao Signed-off-by: Jackie Liu Signed-off-by: Xuanqiang Luo Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/20260828012918.1461-1-xuanqiang.luo@linux.dev Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- include/net/ip.h | 3 ++- net/ipv4/udp.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index 1b0722e9b55e4..05ce8b38e3dab 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -654,7 +654,8 @@ static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast, static __inline__ void inet_reset_saddr(struct sock *sk) { - inet_sk(sk)->inet_rcv_saddr = inet_sk(sk)->inet_saddr = 0; + inet_sk(sk)->inet_saddr = 0; + WRITE_ONCE(inet_sk(sk)->inet_rcv_saddr, 0); #if IS_ENABLED(CONFIG_IPV6) if (sk->sk_family == PF_INET6) { struct ipv6_pinfo *np = inet6_sk(sk); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index d1714aaedf176..6f745efa0db4b 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1968,10 +1968,10 @@ int __udp_disconnect(struct sock *sk, int flags) */ sk->sk_state = TCP_CLOSE; - inet->inet_daddr = 0; + WRITE_ONCE(inet->inet_daddr, 0); inet->inet_dport = 0; sock_rps_reset_rxhash(sk); - sk->sk_bound_dev_if = 0; + WRITE_ONCE(sk->sk_bound_dev_if, 0); if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) { inet_reset_saddr(sk); if (sk->sk_prot->rehash && -- 2.53.0