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->output

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

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

We will likely need RCU protection in the future.

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-6-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
2dce8c52 f1c5fd34

+5 -5
+1 -1
include/net/dst.h
··· 458 458 /* Output packet to network from transport. */ 459 459 static inline int dst_output(struct net *net, struct sock *sk, struct sk_buff *skb) 460 460 { 461 - return INDIRECT_CALL_INET(skb_dst(skb)->output, 461 + return INDIRECT_CALL_INET(READ_ONCE(skb_dst(skb)->output), 462 462 ip6_output, ip_output, 463 463 net, sk, skb); 464 464 }
+2 -2
include/net/lwtunnel.h
··· 138 138 static inline void lwtunnel_set_redirect(struct dst_entry *dst) 139 139 { 140 140 if (lwtunnel_output_redirect(dst->lwtstate)) { 141 - dst->lwtstate->orig_output = dst->output; 142 - dst->output = lwtunnel_output; 141 + dst->lwtstate->orig_output = READ_ONCE(dst->output); 142 + WRITE_ONCE(dst->output, lwtunnel_output); 143 143 } 144 144 if (lwtunnel_input_redirect(dst->lwtstate)) { 145 145 dst->lwtstate->orig_input = READ_ONCE(dst->input);
+1 -1
net/core/dst.c
··· 149 149 if (dst->ops->ifdown) 150 150 dst->ops->ifdown(dst, dev); 151 151 WRITE_ONCE(dst->input, dst_discard); 152 - dst->output = dst_discard_out; 152 + WRITE_ONCE(dst->output, dst_discard_out); 153 153 dst->dev = blackhole_netdev; 154 154 netdev_ref_replace(dev, blackhole_netdev, &dst->dev_tracker, 155 155 GFP_ATOMIC);
+1 -1
net/ipv4/route.c
··· 1688 1688 new_rt->rt_gw6 = rt->rt_gw6; 1689 1689 1690 1690 new_rt->dst.input = READ_ONCE(rt->dst.input); 1691 - new_rt->dst.output = rt->dst.output; 1691 + new_rt->dst.output = READ_ONCE(rt->dst.output); 1692 1692 new_rt->dst.error = rt->dst.error; 1693 1693 new_rt->dst.lastuse = jiffies; 1694 1694 new_rt->dst.lwtstate = lwtstate_get(rt->dst.lwtstate);