* [PATCH net] ipmr, ip6mr: annotate data-races in vif_seq_show()
@ 2026-09-10 9:34 Linkui Xiao
2026-09-15 1:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Linkui Xiao @ 2026-09-10 9:34 UTC (permalink / raw)
To: dsahern, idosch, davem, edumazet, kuba, pabeni, horms
Cc: netdev, linux-kernel, Linkui Xiao
From: Linkui Xiao <xiaolinkui@kylinos.cn>
ipmr_vif_seq_show() and ip6mr_vif_seq_show() read vif->bytes_in,
vif->pkt_in, vif->bytes_out and vif->pkt_out with only rcu_read_lock()
held: since commit b96ef16d2f83 ("ipmr: convert /proc handlers to
rcu_read_lock()") both seq_start helpers are annotated __acquires(RCU)
and no longer take mrt_lock.
Those counters are updated from softirq context and the writers already
use WRITE_ONCE(): ipmr_prepare_xmit() and ip_mr_forward() on the IPv4
side, ip6mr_prepare_xmit() and ip6_mr_forward() on the IPv6 side. The
other lockless readers use READ_ONCE() as well - ipmr_ioctl(),
ipmr_compat_ioctl(), ipmr_fill_vif(), ip6mr_ioctl() and
ip6mr_compat_ioctl().
The two vif_seq_show() helpers are the only remaining bare readers, so
KCSAN flags them and the compiler is free to tear or reload the values
while the /proc/net/ip_mr_vif and /proc/net/ip6_mr_vif lines are being
formatted. Annotate them like the other readers; these are plain
statistics, no locking is needed.
Fixes: b96ef16d2f83 ("ipmr: convert /proc handlers to rcu_read_lock()")
Assisted-by: Qwen:Qwen3.8-max
Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
---
net/ipv4/ipmr.c | 5 +++--
net/ipv6/ip6mr.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index e5f2b1c6150d..36d1b0410a08 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -3178,8 +3178,9 @@ static int ipmr_vif_seq_show(struct seq_file *seq, void *v)
seq_printf(seq,
"%2td %-10s %8ld %7ld %8ld %7ld %05X %08X %08X\n",
vif - mrt->vif_table,
- name, vif->bytes_in, vif->pkt_in,
- vif->bytes_out, vif->pkt_out,
+ name,
+ READ_ONCE(vif->bytes_in), READ_ONCE(vif->pkt_in),
+ READ_ONCE(vif->bytes_out), READ_ONCE(vif->pkt_out),
vif->flags, vif->local, vif->remote);
}
return 0;
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 3f2ed9b77deb..7a3c795ec68b 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -485,8 +485,9 @@ static int ip6mr_vif_seq_show(struct seq_file *seq, void *v)
seq_printf(seq,
"%2td %-10s %8ld %7ld %8ld %7ld %05X\n",
vif - mrt->vif_table,
- name, vif->bytes_in, vif->pkt_in,
- vif->bytes_out, vif->pkt_out,
+ name,
+ READ_ONCE(vif->bytes_in), READ_ONCE(vif->pkt_in),
+ READ_ONCE(vif->bytes_out), READ_ONCE(vif->pkt_out),
vif->flags);
}
return 0;
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net] ipmr, ip6mr: annotate data-races in vif_seq_show()
2026-09-10 9:34 [PATCH net] ipmr, ip6mr: annotate data-races in vif_seq_show() Linkui Xiao
@ 2026-09-15 1:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-15 1:10 UTC (permalink / raw)
To: Linkui Xiao
Cc: dsahern, idosch, davem, edumazet, kuba, pabeni, horms, netdev,
linux-kernel, xiaolinkui
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 10 Sep 2026 17:34:52 +0800 you wrote:
> From: Linkui Xiao <xiaolinkui@kylinos.cn>
>
> ipmr_vif_seq_show() and ip6mr_vif_seq_show() read vif->bytes_in,
> vif->pkt_in, vif->bytes_out and vif->pkt_out with only rcu_read_lock()
> held: since commit b96ef16d2f83 ("ipmr: convert /proc handlers to
> rcu_read_lock()") both seq_start helpers are annotated __acquires(RCU)
> and no longer take mrt_lock.
>
> [...]
Here is the summary with links:
- [net] ipmr, ip6mr: annotate data-races in vif_seq_show()
https://git.kernel.org/netdev/net-next/c/0019aa65bbc6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-15 1:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-10 9:34 [PATCH net] ipmr, ip6mr: annotate data-races in vif_seq_show() Linkui Xiao
2026-09-15 1:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®