]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vxlan: unclone skb head before modifying eth header in route_shortcircuit()
authorEric Dumazet <edumazet@google.com>
Thu, 23 Jul 2026 14:42:46 +0000 (14:42 +0000)
committerJakub Kicinski <kuba@kernel.org>
Mon, 27 Jul 2026 22:15:13 +0000 (15:15 -0700)
When route_shortcircuit() performs L3 short-circuit routing, it modifies
the Ethernet header of the skb in-place:
    memcpy(eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest, dev->addr_len);
    memcpy(eth_hdr(skb)->h_dest, n->ha, dev->addr_len);

If the incoming skb is cloned (for example by packet sockets, tcpdump, or
dev_queue_xmit), modifying the Ethernet header without uncloning can corrupt
the packet header for other readers holding a reference to the cloned skb.

Ensure the skb header is writable and unshared by calling skb_cow_head(skb, 0)
prior to updating the Ethernet header. If skb_cow_head() fails, abort short-circuiting
and return false to allow standard packet processing fallback.

Fixes: e4f67addf158 ("add DOVE extensions for VXLAN")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260723144249.759100-3-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/vxlan/vxlan_core.c

index a05654a55bd605f7fb0141bb80806435b020ef94..e831fe2034427a8c2c6539c484f42c0592d1e272 100644 (file)
@@ -2163,6 +2163,10 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb)
 
                diff = !ether_addr_equal(eth_hdr(skb)->h_dest, n->ha);
                if (diff) {
+                       if (skb_cow_head(skb, 0)) {
+                               neigh_release(n);
+                               return false;
+                       }
                        memcpy(eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest,
                                dev->addr_len);
                        memcpy(eth_hdr(skb)->h_dest, n->ha, dev->addr_len);