aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-04-14 05:09:43 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-14 05:09:43 -0400
commit0eca93bcf73e5939053a94f7c48f8d6fe6199e00 (patch)
treeb4a95f8442b99cea946bfc8a4767489c0107feca /drivers/net/tun.c
parent86bcebafc5e7f5163ccf828792fe694b112ed6fa (diff)
tun: Fix crash with non-GSO users
When I made the tun driver use non-linear packets as the preferred option, it broke non-GSO users because they would end up allocating a completely non-linear packet, which triggers a crash when we call eth_type_trans. This patch reverts non-GSO users to using linear packets and adds a check to ensure that GSO users can't cause crashes in the same way. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a1b0697340ba..16716aef184c 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -518,7 +518,7 @@ static inline struct sk_buff *tun_alloc_skb(struct tun_struct *tun,
518 int err; 518 int err;
519 519
520 /* Under a page? Don't bother with paged skb. */ 520 /* Under a page? Don't bother with paged skb. */
521 if (prepad + len < PAGE_SIZE) 521 if (prepad + len < PAGE_SIZE || !linear)
522 linear = len; 522 linear = len;
523 523
524 skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock, 524 skb = sock_alloc_send_pskb(sk, prepad + linear, len - linear, noblock,
@@ -565,7 +565,8 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun,
565 565
566 if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) { 566 if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
567 align = NET_IP_ALIGN; 567 align = NET_IP_ALIGN;
568 if (unlikely(len < ETH_HLEN)) 568 if (unlikely(len < ETH_HLEN ||
569 (gso.hdr_len && gso.hdr_len < ETH_HLEN)))
569 return -EINVAL; 570 return -EINVAL;
570 } 571 }
571 572