Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3da812d8 authored by Hannes Frederic Sowa's avatar Hannes Frederic Sowa Committed by David S. Miller
Browse files

ipv6: gre: correct calculation of max_headroom



gre_hlen already accounts for sizeof(struct ipv6_hdr) + gre header,
so initialize max_headroom to zero. Otherwise the

	if (encap_limit >= 0) {
		max_headroom += 8;
		mtu -= 8;
	}

increments an uninitialized variable before max_headroom was reset.

Found with coverity: 728539

Cc: Dmitry Kozlov <xeb@mail.ru>
Signed-off-by: default avatarHannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e58f6f4f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -618,7 +618,7 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb,
	struct ip6_tnl *tunnel = netdev_priv(dev);
	struct net_device *tdev;    /* Device to other host */
	struct ipv6hdr  *ipv6h;     /* Our new IP header */
	unsigned int max_headroom;  /* The extra header space needed */
	unsigned int max_headroom = 0; /* The extra header space needed */
	int    gre_hlen;
	struct ipv6_tel_txoption opt;
	int    mtu;
@@ -693,7 +693,7 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb,

	skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(dev)));

	max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen + dst->header_len;
	max_headroom += LL_RESERVED_SPACE(tdev) + gre_hlen + dst->header_len;

	if (skb_headroom(skb) < max_headroom || skb_shared(skb) ||
	    (skb_cloned(skb) && !skb_clone_writable(skb, 0))) {