aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2017-03-13 11:24:28 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-22 07:43:34 -0400
commit683100ed45761d56a5d2b3d79919ecdd12f8cbba (patch)
treea666b73ab405f8bfdb2a340d566d451406e88935 /net
parent4a8d3bb73a821e1923ba7157b3bb364e5aeab0c9 (diff)
ipv6: avoid write to a possibly cloned skb
[ Upstream commit 79e49503efe53a8c51d8b695bedc8a346c5e4a87 ] ip6_fragment, in case skb has a fraglist, checks if the skb is cloned. If it is, it will move to the 'slow path' and allocates new skbs for each fragment. However, right before entering the slowpath loop, it updates the nexthdr value of the last ipv6 extension header to NEXTHDR_FRAGMENT, to account for the fragment header that will be inserted in the new ipv6-fragment skbs. In case original skb is cloned this munges nexthdr value of another skb. Avoid this by doing the nexthdr update for each of the new fragment skbs separately. This was observed with tcpdump on a bridge device where netfilter ipv6 reassembly is active: tcpdump shows malformed fragment headers as the l4 header (icmpv6, tcp, etc). is decoded as a fragment header. Cc: Hannes Frederic Sowa <hannes@stressinduktion.org> Reported-by: Andreas Karis <akaris@redhat.com> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv6/ip6_output.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 9a87bfb2ec16..e27b8fdba5d2 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -757,13 +757,14 @@ slow_path:
757 * Fragment the datagram. 757 * Fragment the datagram.
758 */ 758 */
759 759
760 *prevhdr = NEXTHDR_FRAGMENT;
761 troom = rt->dst.dev->needed_tailroom; 760 troom = rt->dst.dev->needed_tailroom;
762 761
763 /* 762 /*
764 * Keep copying data until we run out. 763 * Keep copying data until we run out.
765 */ 764 */
766 while (left > 0) { 765 while (left > 0) {
766 u8 *fragnexthdr_offset;
767
767 len = left; 768 len = left;
768 /* IF: it doesn't fit, use 'mtu' - the data space left */ 769 /* IF: it doesn't fit, use 'mtu' - the data space left */
769 if (len > mtu) 770 if (len > mtu)
@@ -808,6 +809,10 @@ slow_path:
808 */ 809 */
809 skb_copy_from_linear_data(skb, skb_network_header(frag), hlen); 810 skb_copy_from_linear_data(skb, skb_network_header(frag), hlen);
810 811
812 fragnexthdr_offset = skb_network_header(frag);
813 fragnexthdr_offset += prevhdr - skb_network_header(skb);
814 *fragnexthdr_offset = NEXTHDR_FRAGMENT;
815
811 /* 816 /*
812 * Build fragment header. 817 * Build fragment header.
813 */ 818 */