Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a28d0e87 authored by Dan Carpenter's avatar Dan Carpenter Committed by David S. Miller
Browse files

wan/x25_asy: integer overflow in x25_asy_change_mtu()



If "newmtu * 2 + 4" is too large then it can cause an integer overflow
leading to memory corruption.  Eric Dumazet suggests that 65534 is a
reasonable upper limit.

Btw, "newmtu" is not allowed to be a negative number because of the
check in dev_set_mtu(), so that's ok.

Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cc25eaae
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -122,8 +122,12 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
{
	struct x25_asy *sl = netdev_priv(dev);
	unsigned char *xbuff, *rbuff;
	int len = 2 * newmtu;
	int len;

	if (newmtu > 65534)
		return -EINVAL;

	len = 2 * newmtu;
	xbuff = kmalloc(len + 4, GFP_ATOMIC);
	rbuff = kmalloc(len + 4, GFP_ATOMIC);