]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gro: remove rcu_read_lock/rcu_read_unlock from gro_complete handlers
authorEric Dumazet <edumazet@google.com>
Tue, 23 Nov 2021 22:56:08 +0000 (14:56 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Sep 2024 09:06:47 +0000 (11:06 +0200)
[ Upstream commit 627b94f75b82d13d1530b59155a545fd99d807db ]

All gro_complete() handlers are called from napi_gro_complete()
while rcu_read_lock() has been called.

There is no point stacking more rcu_read_lock()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 7e4196935069 ("fou: Fix null-ptr-deref in GRO.")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/geneve.c
net/8021q/vlan_core.c
net/ethernet/eth.c
net/ipv4/af_inet.c
net/ipv4/fou.c
net/ipv4/gre_offload.c
net/ipv4/udp_offload.c
net/ipv6/ip6_offload.c

index 17989688f54b0d637a41ffdbf4c30bdcff21b8c0..08b479f04ed060ce84557dc36c40ede8af56aea4 100644 (file)
@@ -556,13 +556,10 @@ static int geneve_gro_complete(struct sock *sk, struct sk_buff *skb,
        gh_len = geneve_hlen(gh);
        type = gh->proto_type;
 
-       rcu_read_lock();
        ptype = gro_find_complete_by_type(type);
        if (ptype)
                err = ptype->callbacks.gro_complete(skb, nhoff + gh_len);
 
-       rcu_read_unlock();
-
        skb_set_inner_mac_header(skb, nhoff + gh_len);
 
        return err;
index ff0d3fc82c0ff24fa8f3eae0b80b8acff8c7bf2b..c96ff4a1d4a0b2bfe2832749615f3ba2bbcde80b 100644 (file)
@@ -516,12 +516,10 @@ static int vlan_gro_complete(struct sk_buff *skb, int nhoff)
        struct packet_offload *ptype;
        int err = -ENOENT;
 
-       rcu_read_lock();
        ptype = gro_find_complete_by_type(type);
        if (ptype)
                err = ptype->callbacks.gro_complete(skb, nhoff + sizeof(*vhdr));
 
-       rcu_read_unlock();
        return err;
 }
 
index 2b0eb24199d6486b655cf2d736c7742810b8c647..081390c32707dee9237d554850cfe8ff5593867c 100644 (file)
@@ -457,13 +457,11 @@ int eth_gro_complete(struct sk_buff *skb, int nhoff)
        if (skb->encapsulation)
                skb_set_inner_mac_header(skb, nhoff);
 
-       rcu_read_lock();
        ptype = gro_find_complete_by_type(type);
        if (ptype != NULL)
                err = ptype->callbacks.gro_complete(skb, nhoff +
                                                    sizeof(struct ethhdr));
 
-       rcu_read_unlock();
        return err;
 }
 EXPORT_SYMBOL(eth_gro_complete);
index cac63bb20c16cfc9ba47d2ab9263f84085080b97..58dfca09093c2c1574834baa273cfbfb7797cd82 100644 (file)
@@ -1634,10 +1634,9 @@ int inet_gro_complete(struct sk_buff *skb, int nhoff)
        csum_replace2(&iph->check, iph->tot_len, newlen);
        iph->tot_len = newlen;
 
-       rcu_read_lock();
        ops = rcu_dereference(inet_offloads[proto]);
        if (WARN_ON(!ops || !ops->callbacks.gro_complete))
-               goto out_unlock;
+               goto out;
 
        /* Only need to add sizeof(*iph) to get to the next hdr below
         * because any hdr with option will have been flushed in
@@ -1647,9 +1646,7 @@ int inet_gro_complete(struct sk_buff *skb, int nhoff)
                              tcp4_gro_complete, udp4_gro_complete,
                              skb, nhoff + sizeof(*iph));
 
-out_unlock:
-       rcu_read_unlock();
-
+out:
        return err;
 }
 EXPORT_SYMBOL(inet_gro_complete);
index 5aacc75e495c4b4208befc00e069dad3ffbb153a..605d9673d6ec8917cafdb86dd5009cf3dfd1ab94 100644 (file)
@@ -265,19 +265,16 @@ static int fou_gro_complete(struct sock *sk, struct sk_buff *skb,
        const struct net_offload *ops;
        int err = -ENOSYS;
 
-       rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[proto]);
        if (WARN_ON(!ops || !ops->callbacks.gro_complete))
-               goto out_unlock;
+               goto out;
 
        err = ops->callbacks.gro_complete(skb, nhoff);
 
        skb_set_inner_mac_header(skb, nhoff);
 
-out_unlock:
-       rcu_read_unlock();
-
+out:
        return err;
 }
 
@@ -479,18 +476,16 @@ static int gue_gro_complete(struct sock *sk, struct sk_buff *skb, int nhoff)
                return err;
        }
 
-       rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[proto]);
        if (WARN_ON(!ops || !ops->callbacks.gro_complete))
-               goto out_unlock;
+               goto out;
 
        err = ops->callbacks.gro_complete(skb, nhoff + guehlen);
 
        skb_set_inner_mac_header(skb, nhoff + guehlen);
 
-out_unlock:
-       rcu_read_unlock();
+out:
        return err;
 }
 
index e9dabf1affe9ed079ce0b0483670d48b18e5cd30..b4da692b973421fbcf9e341f209aaa20c4964aa0 100644 (file)
@@ -248,13 +248,10 @@ static int gre_gro_complete(struct sk_buff *skb, int nhoff)
        if (greh->flags & GRE_CSUM)
                grehlen += GRE_HEADER_SECTION;
 
-       rcu_read_lock();
        ptype = gro_find_complete_by_type(type);
        if (ptype)
                err = ptype->callbacks.gro_complete(skb, nhoff + grehlen);
 
-       rcu_read_unlock();
-
        skb_set_inner_mac_header(skb, nhoff + grehlen);
 
        return err;
index 418da7a8a075588032e6b14fb41912355acb33f6..6e36eb1ba2763da7f628fca277c5aa820c729c89 100644 (file)
@@ -645,7 +645,6 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff,
 
        uh->len = newlen;
 
-       rcu_read_lock();
        sk = INDIRECT_CALL_INET(lookup, udp6_lib_lookup_skb,
                                udp4_lib_lookup_skb, skb, uh->source, uh->dest);
        if (sk && udp_sk(sk)->gro_complete) {
@@ -661,7 +660,6 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff,
        } else {
                err = udp_gro_complete_segment(skb);
        }
-       rcu_read_unlock();
 
        if (skb->remcsum_offload)
                skb_shinfo(skb)->gso_type |= SKB_GSO_TUNNEL_REMCSUM;
index f67921e0dd566f0be905062894955cce1de3280e..673f02ea62aae22b73b83357aedf0d56594be387 100644 (file)
@@ -328,18 +328,14 @@ INDIRECT_CALLABLE_SCOPE int ipv6_gro_complete(struct sk_buff *skb, int nhoff)
 
        iph->payload_len = htons(skb->len - nhoff - sizeof(*iph));
 
-       rcu_read_lock();
-
        nhoff += sizeof(*iph) + ipv6_exthdrs_len(iph, &ops);
        if (WARN_ON(!ops || !ops->callbacks.gro_complete))
-               goto out_unlock;
+               goto out;
 
        err = INDIRECT_CALL_L4(ops->callbacks.gro_complete, tcp6_gro_complete,
                               udp6_gro_complete, skb, nhoff);
 
-out_unlock:
-       rcu_read_unlock();
-
+out:
        return err;
 }