1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: "Jason A. Donenfeld" <Jason@zx2c4.com>
3 Date: Mon, 22 Feb 2021 17:25:47 +0100
4 Subject: [PATCH] wireguard: device: do not generate ICMP for non-IP packets
6 commit 99fff5264e7ab06f45b0ad60243475be0a8d0559 upstream.
8 If skb->protocol doesn't match the actual skb->data header, it's
9 probably not a good idea to pass it off to icmp{,v6}_ndo_send, which is
10 expecting to reply to a valid IP packet. So this commit has that early
11 mismatch case jump to a later error label.
13 Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
14 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
15 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
16 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
18 drivers/net/wireguard/device.c | 7 ++++---
19 1 file changed, 4 insertions(+), 3 deletions(-)
21 --- a/drivers/net/wireguard/device.c
22 +++ b/drivers/net/wireguard/device.c
23 @@ -138,7 +138,7 @@ static netdev_tx_t wg_xmit(struct sk_buf
24 else if (skb->protocol == htons(ETH_P_IPV6))
25 net_dbg_ratelimited("%s: No peer has allowed IPs matching %pI6\n",
26 dev->name, &ipv6_hdr(skb)->daddr);
31 family = READ_ONCE(peer->endpoint.addr.sa_family);
32 @@ -201,12 +201,13 @@ static netdev_tx_t wg_xmit(struct sk_buf
37 - ++dev->stats.tx_errors;
39 if (skb->protocol == htons(ETH_P_IP))
40 icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0);
41 else if (skb->protocol == htons(ETH_P_IPV6))
42 icmpv6_ndo_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, 0);
44 + ++dev->stats.tx_errors;