]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arp: use RCU protection in arp_xmit()
authorEric Dumazet <edumazet@google.com>
Fri, 7 Feb 2025 13:58:36 +0000 (13:58 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 12:50:08 +0000 (13:50 +0100)
[ Upstream commit a42b69f692165ec39db42d595f4f65a4c8f42e44 ]

arp_xmit() can be called without RTNL or RCU protection.

Use RCU protection to avoid potential UAF.

Fixes: 29a26a568038 ("netfilter: Pass struct net into the netfilter hooks")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250207135841.1948589-5-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/arp.c

index ccff96820a703e070f95315c5c207b0b70fa9b1b..8f9b5568f1dc100ec5c7c9f66989bf83aca4ad0c 100644 (file)
@@ -658,10 +658,12 @@ static int arp_xmit_finish(struct net *net, struct sock *sk, struct sk_buff *skb
  */
 void arp_xmit(struct sk_buff *skb)
 {
+       rcu_read_lock();
        /* Send it off, maybe filter it using firewalling first.  */
        NF_HOOK(NFPROTO_ARP, NF_ARP_OUT,
-               dev_net(skb->dev), NULL, skb, NULL, skb->dev,
+               dev_net_rcu(skb->dev), NULL, skb, NULL, skb->dev,
                arp_xmit_finish);
+       rcu_read_unlock();
 }
 EXPORT_SYMBOL(arp_xmit);