Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: dst: annotate data-races around dst->input

dst_dev_put() can overwrite dst->input while other
cpus might read this field (for instance from dst_input())

Add READ_ONCE()/WRITE_ONCE() annotations to suppress
potential issues.

We will likely need full RCU protection later.

Fixes: 4a6ce2b6f2ec ("net: introduce a new function dst_dev_put()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250630121934.3399505-5-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
f1c5fd34 8f2b2282

+5 -5
+1 -1
include/net/dst.h
··· 468 468 /* Input packet from network to transport. */ 469 469 static inline int dst_input(struct sk_buff *skb) 470 470 { 471 - return INDIRECT_CALL_INET(skb_dst(skb)->input, 471 + return INDIRECT_CALL_INET(READ_ONCE(skb_dst(skb)->input), 472 472 ip6_input, ip_local_deliver, skb); 473 473 } 474 474
+2 -2
include/net/lwtunnel.h
··· 142 142 dst->output = lwtunnel_output; 143 143 } 144 144 if (lwtunnel_input_redirect(dst->lwtstate)) { 145 - dst->lwtstate->orig_input = dst->input; 146 - dst->input = lwtunnel_input; 145 + dst->lwtstate->orig_input = READ_ONCE(dst->input); 146 + WRITE_ONCE(dst->input, lwtunnel_input); 147 147 } 148 148 } 149 149 #else
+1 -1
net/core/dst.c
··· 148 148 WRITE_ONCE(dst->obsolete, DST_OBSOLETE_DEAD); 149 149 if (dst->ops->ifdown) 150 150 dst->ops->ifdown(dst, dev); 151 - dst->input = dst_discard; 151 + WRITE_ONCE(dst->input, dst_discard); 152 152 dst->output = dst_discard_out; 153 153 dst->dev = blackhole_netdev; 154 154 netdev_ref_replace(dev, blackhole_netdev, &dst->dev_tracker,
+1 -1
net/ipv4/route.c
··· 1687 1687 else if (rt->rt_gw_family == AF_INET6) 1688 1688 new_rt->rt_gw6 = rt->rt_gw6; 1689 1689 1690 - new_rt->dst.input = rt->dst.input; 1690 + new_rt->dst.input = READ_ONCE(rt->dst.input); 1691 1691 new_rt->dst.output = rt->dst.output; 1692 1692 new_rt->dst.error = rt->dst.error; 1693 1693 new_rt->dst.lastuse = jiffies;