From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.34 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794193020; b=LQPbYNTxauwOt9toSVmzj3a5pl6oynVv/UO5gKup4Snx/VpYu44w5p9EOuKz+i3gM/+I A7phQvTyH5HIQW7g0GrAhDi8oVmmnh4DwQb22SErdRTty21v90DEXtpBm97DsTXt7vgPf 5z7GJuf3KMXlc1LjcX6k9GMIfF9Tf0dw78nzIj++jbBTWNDOO3HPnQIHPtk5/JrSgWAG/ g6jScGCuB3rMTiAxobRKsPOQq8efuE6ucZbej2vDj29KCeOs/DVvUBS82jXVFzFQfxcMP b56KnJuYEdssvKF8gkDWIjVHQ8ra0j40PI/2IPYmqobL0zV8tOyT/jPQHrR7Xo38hQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794193020; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=amf3Y3vtqWCfA+hYsW3iaFHpj/KPEsqLUTq3odUhe94=; b=eU8P1Q7bZKSA4Cstd+nS8uJYabxf71/7bmN8L1qHaMD1+8VIGV2G5UmmUGsevi0GCW4c iJt872TYmtNfZMTEfyf8LMa9Mlfd1/aZwHs01OviVtLfyB8tZlku8EiqMBMbCuMqAM7ps o9vy9yYKV/KLEf5AmDFDLbc36Q8Zb5NnFSOGwGsLl0+6GqROt7elxZpAm2ZORxgRMcf62 KyQ5wFtr+hK9Zu2PENag/Bnis98cc1XXeNjAxCeIULu+iK3dXuhXpTVUP0qI3v/6bcxOg 2701NOAao4jKrng5IRP1i6ztTm8jADYdz58GPj27GhYGCjcTJk5Bqp/d/cQewZT2tdg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=n6+sH+Ns; arc=none smtp.remote-ip=95.215.58.34 Received: from mta1.migadu.com (out-34.mta1.migadu.com [95.215.58.34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DC7D606A325 for ; Mon, 9 Nov 2026 02:56:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3DC7D606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=n6+sH+Ns X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=gggsKdF+pSJpQv0nyo1SbJUQxyRR8b7X9hlpNF2qsEM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1794193018; v=1; x=1794797818; b=n6+sH+Ns42vQuuPh1M9IBHLusBfQG2hdiGYrRtTS2sxa+am2Yahzab+JT4kpQWsAwTQJBi/B An+lIKaf4MsLr82tv0KvMad01v/w8AkaF9o146wk80sAz0SbphfN0I4pGCEprCcjN3XP8GPWOuK xWcm3TgrFvX/XGbSmy0i2BcY= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 3ab2d1445e65b102; Mon, 09 Nov 2026 02:56:58 +0000 X-Mizu-Trace-ID: 3ab2d1445e65b102 X-Migadu-Flow: FLOW_OUT From: Jiayuan Chen To: netdev@vger.kernel.org Cc: Jiayuan Chen , David Ahern , Ido Schimmel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Pablo Neira Ayuso , Florian Westphal , Phil Sutter , Nikolay Aleksandrov , Paul Moore , Matthieu Baerts , Mat Martineau , Geliang Tang , Julian Anastasov , Allison Henderson , Marcelo Ricardo Leitner , Xin Long , "D. Wythe" , Dust Li , Sidraya Jayagond , Mahanta Jambigi , Tony Lu , Wen Gu , linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, bridge@lists.linux.dev, linux-security-module@vger.kernel.org, mptcp@lists.linux.dev, lvs-devel@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-sctp@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH net-next 04/14] ipv6: annotate data-races around icmpv6 reply sysctls Date: Mon, 9 Nov 2026 10:52:03 +0800 Message-ID: <20261109025425.328445-5-jiayuan.chen@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261109025425.328445-1-jiayuan.chen@linux.dev> References: <20261109025425.328445-1-jiayuan.chen@linux.dev> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit icmpv6_echo_ignore_all, icmpv6_echo_ignore_multicast, icmpv6_echo_ignore_anycast, anycast_src_echo_reply and fwmark_reflect are read without any lock while their sysctl handlers update them with WRITE_ONCE(). Add READ_ONCE() to the readers. KCSAN reports it when net.ipv6.icmp.echo_ignore_all is changed while ICMPv6 echo requests are received: BUG: KCSAN: data-race in icmpv6_rcv / proc_dou8vec_minmax write (marked) to 0xffffffff8ee2940d of 1 bytes by task 504 on cpu 0: proc_dou8vec_minmax+0x1ab/0x1f0 proc_sys_call_handler+0x282/0x3a0 proc_sys_write+0x13/0x20 ... read to 0xffffffff8ee2940d of 1 bytes by interrupt on cpu 3: icmpv6_rcv+0x99d/0xd40 ip6_protocol_deliver_rcu+0x787/0x9a0 ip6_input_finish+0xb0/0x1b0 ip6_input+0xa8/0x250 ipv6_rcv+0x14b/0x1c0 __netif_receive_skb_one_core+0x8f/0xe0 ... value changed: 0x01 -> 0x00 Signed-off-by: Jiayuan Chen --- include/net/ipv6.h | 2 +- net/ipv6/icmp.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 579df1516d251..b77dc5c3ea268 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -199,7 +199,7 @@ struct sk_buff *ip6_frag_next(struct sk_buff *skb, struct ip6_frag_state *state); #define IP6_REPLY_MARK(net, mark) \ - ((net)->ipv6.sysctl.fwmark_reflect ? (mark) : 0) + (READ_ONCE((net)->ipv6.sysctl.fwmark_reflect) ? (mark) : 0) #include diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index a95b0351824f3..3e95b1191c4f2 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -938,17 +938,17 @@ static enum skb_drop_reason icmpv6_echo_reply(struct sk_buff *skb) u8 type; if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr) && - net->ipv6.sysctl.icmpv6_echo_ignore_multicast) + READ_ONCE(net->ipv6.sysctl.icmpv6_echo_ignore_multicast)) return reason; saddr = &ipv6_hdr(skb)->daddr; acast = ipv6_anycast_destination(skb_dst(skb), saddr); - if (acast && net->ipv6.sysctl.icmpv6_echo_ignore_anycast) + if (acast && READ_ONCE(net->ipv6.sysctl.icmpv6_echo_ignore_anycast)) return reason; if (!ipv6_unicast_destination(skb) && - !(net->ipv6.sysctl.anycast_src_echo_reply && acast)) + !(READ_ONCE(net->ipv6.sysctl.anycast_src_echo_reply) && acast)) saddr = NULL; if (icmph->icmp6_type == ICMPV6_EXT_ECHO_REQUEST) @@ -1152,11 +1152,11 @@ static int icmpv6_rcv(struct sk_buff *skb) switch (type) { case ICMPV6_ECHO_REQUEST: - if (!net->ipv6.sysctl.icmpv6_echo_ignore_all) + if (!READ_ONCE(net->ipv6.sysctl.icmpv6_echo_ignore_all)) reason = icmpv6_echo_reply(skb); break; case ICMPV6_EXT_ECHO_REQUEST: - if (!net->ipv6.sysctl.icmpv6_echo_ignore_all && + if (!READ_ONCE(net->ipv6.sysctl.icmpv6_echo_ignore_all) && READ_ONCE(net->ipv4.sysctl_icmp_echo_enable_probe)) reason = icmpv6_echo_reply(skb); break; -- 2.43.0