Skip to content

Commit

Permalink
net: check for underlength tap writes
Browse files Browse the repository at this point in the history
If the user gives a packet under 14 bytes, we'll end up reading off the end
of the skb (not oopsing, just reading off the end).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-by: Max Krasnyanskiy <maxk@qualcomm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Rusty Russell authored and David S. Miller committed Apr 13, 2008
1 parent 14daa02 commit e01bf1c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit e01bf1c

Please sign in to comment.