login
Header Space

 
 

[PATCH 2/2] net: check for underlength tap writes

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Miller <davem@...>
Cc: Max Krasnyansky <maxk@...>, <netdev@...>
Date: Saturday, April 5, 2008 - 7:54 am

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>

diff -r 99132ad16999 drivers/net/tun.c
--- a/drivers/net/tun.c	Sat Apr 05 21:20:32 2008 +1100
+++ b/drivers/net/tun.c	Sat Apr 05 22:47:20 2008 +1100
@@ -286,8 +286,11 @@ static __inline__ ssize_t tun_get_user(s
 			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++;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 1/2] net: make struct tun_struct private to tun.c, Max Krasnyanskiy, (Thu Apr 10, 2:18 pm)
[PATCH 2/2] net: check for underlength tap writes, Rusty Russell, (Sat Apr 5, 7:54 am)
Re: [PATCH 2/2] net: check for underlength tap writes, Max Krasnyanskiy, (Thu Apr 10, 2:19 pm)
Re: [PATCH 2/2] net: check for underlength tap writes, David Miller, (Sat Apr 12, 9:51 pm)
speck-geostationary