ipv6: fix headroom calculation in udp6_ufo_fragment

This change “ipv6: fix headroom calculation in udp6_ufo_fragment” (commit 0e033e0) in Linux kernel is authored by Hannes Frederic Sowa <hannes [at] stressinduktion.org> on Tue Nov 5 02:41:27 2013 +0100.

Description of "ipv6: fix headroom calculation in udp6_ufo_fragment"

The change “ipv6: fix headroom calculation in udp6_ufo_fragment” introduces changes as follows.

ipv6: fix headroom calculation in udp6_ufo_fragment

Commit 1e2bd517c108816220f262d7954b697af03b5f9c ("udp6: Fix udp
fragmentation for tunnel traffic.") changed the calculation if
there is enough space to include a fragment header in the skb from a
skb->mac_header dervived one to skb_headroom. Because we already peeled
off the skb to transport_header this is wrong. Change this back to check
if we have enough room before the mac_header.

This fixes a panic Saran Neti reported. He used the tbf scheduler which
skb_gso_segments the skb. The offsets get negative and we panic in memcpy
because the skb was erroneously not expanded at the head.

Reported-by: Saran Neti <Saran.Neti@telus.com>
Cc: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

Linux kernel releases containing commit 0e033e0

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "ipv6: fix headroom calculation in udp6_ufo_fragment"

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/ipv6/udp_offload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 
diff --git a/net/ipv6/udp_offload.c b/net/ipv6/udp_offload.c
index 08e23b0bf302..e7359f9eaa8d 100644
--- a/net/ipv6/udp_offload.c
+++ b/net/ipv6/udp_offload.c
@@ -90,7 +90,7 @@ static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,
 
 		/* Check if there is enough headroom to insert fragment header. */
 		tnl_hlen = skb_tnl_header_len(skb);
-		if (skb_headroom(skb) < (tnl_hlen + frag_hdr_sz)) {
+		if (skb->mac_header < (tnl_hlen + frag_hdr_sz)) {
 			if (gso_pskb_expand_head(skb, tnl_hlen + frag_hdr_sz))
 				goto out;
 		}

The commit for this change in Linux stable tree is 0e033e0 (patch).

Last modified: 2020/02/10