aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Frederic Sowa <hannes@stressinduktion.org>2015-10-28 08:21:04 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-29 10:01:50 -0400
commit89bc7848a91bc99532f5c21b2885472ba710f249 (patch)
tree90181c41b4521baaac793ad38f57c51d3957a663
parent1e0d69a9cc9172d7896c2113f983a74f6e8ff303 (diff)
ipv6: protect mtu calculation of wrap-around and infinite loop by rounding issues
Raw sockets with hdrincl enabled can insert ipv6 extension headers right into the data stream. In case we need to fragment those packets, we reparse the options header to find the place where we can insert the fragment header. If the extension headers exceed the link's MTU we actually cannot make progress in such a case. Instead of ending up in broken arithmetic or rounding towards 0 and entering an endless loop in ip6_fragment, just prevent those cases by aborting early and signal -EMSGSIZE to user space. This is the second version of the patch which doesn't use the overflow_usub function, which got reverted for now. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Reported-by: Dmitry Vyukov <dvyukov@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv6/ip6_output.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index d03d6da772f3..f84ec4e9b2de 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -584,6 +584,8 @@ int ip6_fragment(struct sock *sk, struct sk_buff *skb,
584 if (np->frag_size) 584 if (np->frag_size)
585 mtu = np->frag_size; 585 mtu = np->frag_size;
586 } 586 }
587 if (mtu < hlen + sizeof(struct frag_hdr) + 8)
588 goto fail_toobig;
587 mtu -= hlen + sizeof(struct frag_hdr); 589 mtu -= hlen + sizeof(struct frag_hdr);
588 590
589 frag_id = ipv6_select_ident(net, &ipv6_hdr(skb)->daddr, 591 frag_id = ipv6_select_ident(net, &ipv6_hdr(skb)->daddr,