diff options
author | Hannes Frederic Sowa <hannes@stressinduktion.org> | 2013-09-28 23:40:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-10-13 19:08:30 -0400 |
commit | 102ce961c8d54d613eb49d6bc71ecec674505815 (patch) | |
tree | e7f6efe877f1477b8e81878dd06ba2f3f1880407 | |
parent | c9b391f6d166118c5543e9d1708e67977dbdbe1f (diff) |
ipv6: gre: correct calculation of max_headroom
[ Upstream commit 3da812d860755925da890e8c713f2d2e2d7b1bae ]
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: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/ipv6/ip6_gre.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index ecd60733e5e2..1f9a1a5b61f4 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c | |||
@@ -620,7 +620,7 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, | |||
620 | struct ip6_tnl *tunnel = netdev_priv(dev); | 620 | struct ip6_tnl *tunnel = netdev_priv(dev); |
621 | struct net_device *tdev; /* Device to other host */ | 621 | struct net_device *tdev; /* Device to other host */ |
622 | struct ipv6hdr *ipv6h; /* Our new IP header */ | 622 | struct ipv6hdr *ipv6h; /* Our new IP header */ |
623 | unsigned int max_headroom; /* The extra header space needed */ | 623 | unsigned int max_headroom = 0; /* The extra header space needed */ |
624 | int gre_hlen; | 624 | int gre_hlen; |
625 | struct ipv6_tel_txoption opt; | 625 | struct ipv6_tel_txoption opt; |
626 | int mtu; | 626 | int mtu; |
@@ -693,7 +693,7 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, | |||
693 | tunnel->err_count = 0; | 693 | tunnel->err_count = 0; |
694 | } | 694 | } |
695 | 695 | ||
696 | max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen + dst->header_len; | 696 | max_headroom += LL_RESERVED_SPACE(tdev) + gre_hlen + dst->header_len; |
697 | 697 | ||
698 | if (skb_headroom(skb) < max_headroom || skb_shared(skb) || | 698 | if (skb_headroom(skb) < max_headroom || skb_shared(skb) || |
699 | (skb_cloned(skb) && !skb_clone_writable(skb, 0))) { | 699 | (skb_cloned(skb) && !skb_clone_writable(skb, 0))) { |