From 528ab932002935b796f17b89a0db32593db690bf Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 11 Jan 2025 07:08:10 +0000 Subject: [PATCH] Revert "ip_tunnel: annotate data-races around t->parms.link" This reverts commit c3c53b16928e256879bde8be268220d4ebcdd127 which is commit f694eee9e1c00d6ca06c5e59c04e3b6ff7d64aa9 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: Ieb61f22977ab6a0cf16fa46b80083d43a0b9a553 Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_tunnel.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index 196fe734ad38..d56cfb6c3da4 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -102,9 +102,10 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, if (!ip_tunnel_key_match(&t->parms, flags, key)) continue; - if (READ_ONCE(t->parms.link) == link) + if (t->parms.link == link) return t; - cand = t; + else + cand = t; } hlist_for_each_entry_rcu(t, head, hash_node) { @@ -116,9 +117,9 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, if (!ip_tunnel_key_match(&t->parms, flags, key)) continue; - if (READ_ONCE(t->parms.link) == link) + if (t->parms.link == link) return t; - if (!cand) + else if (!cand) cand = t; } @@ -136,9 +137,9 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, if (!ip_tunnel_key_match(&t->parms, flags, key)) continue; - if (READ_ONCE(t->parms.link) == link) + if (t->parms.link == link) return t; - if (!cand) + else if (!cand) cand = t; } @@ -149,9 +150,9 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, !(t->dev->flags & IFF_UP)) continue; - if (READ_ONCE(t->parms.link) == link) + if (t->parms.link == link) return t; - if (!cand) + else if (!cand) cand = t; } @@ -220,7 +221,7 @@ static struct ip_tunnel *ip_tunnel_find(struct ip_tunnel_net *itn, hlist_for_each_entry_rcu(t, head, hash_node) { if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr && - link == READ_ONCE(t->parms.link) && + link == t->parms.link && type == t->dev->type && ip_tunnel_key_match(&t->parms, flags, key)) break; @@ -773,7 +774,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, ip_tunnel_init_flow(&fl4, protocol, dst, tnl_params->saddr, tunnel->parms.o_key, RT_TOS(tos), - dev_net(dev), READ_ONCE(tunnel->parms.link), + dev_net(dev), tunnel->parms.link, tunnel->fwmark, skb_get_hash(skb), 0); if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0) @@ -893,7 +894,7 @@ static void ip_tunnel_update(struct ip_tunnel_net *itn, if (t->parms.link != p->link || t->fwmark != fwmark) { int mtu; - WRITE_ONCE(t->parms.link, p->link); + t->parms.link = p->link; t->fwmark = fwmark; mtu = ip_tunnel_bind_dev(dev); if (set_mtu) @@ -1083,9 +1084,9 @@ EXPORT_SYMBOL(ip_tunnel_get_link_net); int ip_tunnel_get_iflink(const struct net_device *dev) { - const struct ip_tunnel *tunnel = netdev_priv(dev); + struct ip_tunnel *tunnel = netdev_priv(dev); - return READ_ONCE(tunnel->parms.link); + return tunnel->parms.link; } EXPORT_SYMBOL(ip_tunnel_get_iflink);