[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200214063814.229451-1-edumazet@google.com>
Date: Thu, 13 Feb 2020 22:38:14 -0800
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>
Cc: netdev <netdev@...r.kernel.org>,
Eric Dumazet <edumazet@...gle.com>,
Eric Dumazet <eric.dumazet@...il.com>,
syzbot <syzkaller@...glegroups.com>,
"Jason A . Donenfeld" <Jason@...c4.com>, wireguard@...ts.zx2c4.com
Subject: [PATCH net] wireguard: device: provide sane limits for mtu setting
If wireguard device mtu is set to zero, a divide by zero
crash happens in calculate_skb_padding().
This patch provides dev->min_mtu and dev->max_mtu bounds.
Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
Reported-by: syzbot <syzkaller@...glegroups.com>
Cc: Jason A. Donenfeld <Jason@...c4.com>
Cc: wireguard@...ts.zx2c4.com
---
drivers/net/wireguard/device.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c
index 43db442b1373073eaf5e805cfe6cfee15875437a..c02b84cca122d92ee8a81c5efdcf67aada2554d6 100644
--- a/drivers/net/wireguard/device.c
+++ b/drivers/net/wireguard/device.c
@@ -271,9 +271,14 @@ static void wg_setup(struct net_device *dev)
dev->features |= WG_NETDEV_FEATURES;
dev->hw_features |= WG_NETDEV_FEATURES;
dev->hw_enc_features |= WG_NETDEV_FEATURES;
+
dev->mtu = ETH_DATA_LEN - MESSAGE_MINIMUM_LENGTH -
sizeof(struct udphdr) -
max(sizeof(struct ipv6hdr), sizeof(struct iphdr));
+ dev->min_mtu = MESSAGE_PADDING_MULTIPLE;
+ dev->max_mtu = ETH_MAX_MTU - MESSAGE_MINIMUM_LENGTH -
+ sizeof(struct udphdr) -
+ max(sizeof(struct ipv6hdr), sizeof(struct iphdr));
SET_NETDEV_DEVTYPE(dev, &device_type);
--
2.25.0.265.gbab2e86ba0-goog
Powered by blists - more mailing lists