ipv6: add defensive check for CHECKSUM_PARTIAL skbs in ip_fragment
authorHannes Frederic Sowa <hannes@stressinduktion.org>
Tue, 27 Oct 2015 21:40:42 +0000 (22:40 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Nov 2015 17:01:28 +0000 (12:01 -0500)
CHECKSUM_PARTIAL skbs should never arrive in ip_fragment. If we get one
of those warn about them once and handle them gracefully by recalculating
the checksum.

Fixes: commit 32dce968dd987 ("ipv6: Allow for partial checksums on non-ufo packets")
See-also: commit 72e843bb09d45 ("ipv6: ip6_fragment() should check CHECKSUM_PARTIAL")
Cc: Eric Dumazet <edumazet@google.com>
Cc: Vlad Yasevich <vyasevich@gmail.com>
Cc: Benjamin Coddington <bcodding@redhat.com>
Cc: Tom Herbert <tom@herbertland.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/ip6_output.c

index 81ac5a970e433f3acd86f8ce64f8e2f1b48e54e3..e6a7bd15b9b7115ce6a61e3157c637cdaf86ec18 100644 (file)
@@ -603,6 +603,10 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
        frag_id = ipv6_select_ident(net, &ipv6_hdr(skb)->daddr,
                                    &ipv6_hdr(skb)->saddr);
 
+       if (skb->ip_summed == CHECKSUM_PARTIAL &&
+           (err = skb_checksum_help(skb)))
+               goto fail;
+
        hroom = LL_RESERVED_SPACE(rt->dst.dev);
        if (skb_has_frag_list(skb)) {
                int first_len = skb_pagelen(skb);
@@ -731,10 +735,6 @@ slow_path_clean:
        }
 
 slow_path:
-       if ((skb->ip_summed == CHECKSUM_PARTIAL) &&
-           skb_checksum_help(skb))
-               goto fail;
-
        left = skb->len - hlen;         /* Space per frame */
        ptr = hlen;                     /* Where to start from */