]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/tun.c
net: check for underlength tap writes
[linux-2.6-omap-h63xx.git] / drivers / net / tun.c
index 970ec4793442e001bc0008659ad1be485ddb7415..5b5d87585d914cf29dbad9c0f84d466590f7d537 100644 (file)
@@ -286,8 +286,11 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv,
                        return -EFAULT;
        }
 
-       if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV)
+       if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
                align = NET_IP_ALIGN;
+               if (unlikely(len < ETH_HLEN))
+                       return -EINVAL;
+       }
 
        if (!(skb = alloc_skb(len + align, GFP_KERNEL))) {
                tun->dev->stats.rx_dropped++;