diff options
author | Eric Dumazet <edumazet@google.com> | 2012-08-18 23:47:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-23 01:48:32 -0400 |
commit | b87fb39e399137257a6db3224ea854117e9486e9 (patch) | |
tree | a4373882fec7b443510d3c5a20c5c16839d71ae1 /net/ipv6/ip6_gre.c | |
parent | ef8531b64c3e2443da52e9f05d74a988230eedc5 (diff) |
ipv6: gre: fix ip6gre_err()
ip6gre_err() miscomputes grehlen (sizeof(ipv6h) is 4 or 8,
not 40 as expected), and should take into account 'offset' parameter.
Also uses pskb_may_pull() to cope with some fragged skbs
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Dmitry Kozlov <xeb@mail.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ip6_gre.c')
-rw-r--r-- | net/ipv6/ip6_gre.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index a84ad5dc4fcf..424d11a4e7ff 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c | |||
@@ -415,8 +415,8 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
415 | u8 type, u8 code, int offset, __be32 info) | 415 | u8 type, u8 code, int offset, __be32 info) |
416 | { | 416 | { |
417 | const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)skb->data; | 417 | const struct ipv6hdr *ipv6h = (const struct ipv6hdr *)skb->data; |
418 | __be16 *p = (__be16 *)(ipv6h + 1); | 418 | __be16 *p = (__be16 *)(skb->data + offset); |
419 | int grehlen = sizeof(ipv6h) + 4; | 419 | int grehlen = offset + 4; |
420 | struct ip6_tnl *t; | 420 | struct ip6_tnl *t; |
421 | __be16 flags; | 421 | __be16 flags; |
422 | 422 | ||
@@ -432,8 +432,10 @@ static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
432 | } | 432 | } |
433 | 433 | ||
434 | /* If only 8 bytes returned, keyed message will be dropped here */ | 434 | /* If only 8 bytes returned, keyed message will be dropped here */ |
435 | if (skb_headlen(skb) < grehlen) | 435 | if (!pskb_may_pull(skb, grehlen)) |
436 | return; | 436 | return; |
437 | ipv6h = (const struct ipv6hdr *)skb->data; | ||
438 | p = (__be16 *)(skb->data + offset); | ||
437 | 439 | ||
438 | rcu_read_lock(); | 440 | rcu_read_lock(); |
439 | 441 | ||