From patchwork Wed Apr 24 15:14:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 239230 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6DDE52C00E2 for ; Thu, 25 Apr 2013 01:14:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756574Ab3DXPOI (ORCPT ); Wed, 24 Apr 2013 11:14:08 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:56139 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756436Ab3DXPOH (ORCPT ); Wed, 24 Apr 2013 11:14:07 -0400 Received: by mail-pd0-f171.google.com with SMTP id t12so1197131pdi.2 for ; Wed, 24 Apr 2013 08:14:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:x-mailer:content-transfer-encoding :mime-version; bh=/EyHXglGucK0/ltyrmfmoTX353PfOajHFzWxOH/v9FI=; b=DbwMT4uIln2EFtheKLtrKpBJrsOYfqtFvTaminEDGdrBYrDdEaF/KK3Zo3Hlc/cK+1 9im0Vs0Kf5RXVbxnHbQnqHasG3Vq+DaWtV3B3Q/jp0iQdSl+0LDlYa1iS0xyMwUMqlB6 clgMVAXnCulv60hewifsjAv2t8YJsaf/j+JcTmgKo9dHxHyvvN8IzLNZDQFoU/XXseKC 4JW+Q3B8884ecXiiVmn1OAut/y4R1FHO3y/nFJA04IM4tLL7KFG7uoyMafaxmDbv6EGc tvM42zdAKFmHc6NWmPkD3IcZBHkHbFWcNC5AtkLrBDxaPpRqm2X8wDbs6+IRhEkzoAkX WKCw== X-Received: by 10.66.148.97 with SMTP id tr1mr19846342pab.49.1366816446564; Wed, 24 Apr 2013 08:14:06 -0700 (PDT) Received: from [172.26.50.178] ([172.26.50.178]) by mx.google.com with ESMTPSA id ts3sm3414378pbc.12.2013.04.24.08.14.05 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Wed, 24 Apr 2013 08:14:05 -0700 (PDT) Message-ID: <1366816444.8964.72.camel@edumazet-glaptop> Subject: Re: gre: Support GRE over IPv6 From: Eric Dumazet To: Geert Uytterhoeven Cc: Dmitry Kozlov , "David S. Miller" , netdev@vger.kernel.org, Linux Kernel Development Date: Wed, 24 Apr 2013 08:14:04 -0700 In-Reply-To: References: <20121002205219.7C3BD340556@ra.kernel.org> X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 2013-04-24 at 14:23 +0200, Geert Uytterhoeven wrote: > On Tue, 2 Oct 2012, Linux Kernel Mailing List wrote: > > Gitweb: http://git.kernel.org/linus/;a=commit;h=c12b395a46646bab69089ce7016ac78177f6001f > > Commit: c12b395a46646bab69089ce7016ac78177f6001f > > Parent: b7bc2a5b5bd99b216c3e5fe68c7f45c684ab5745 > > Author: xeb@mail.ru > > AuthorDate: Fri Aug 10 00:51:50 2012 +0000 > > Committer: David S. Miller > > CommitDate: Tue Aug 14 14:28:32 2012 -0700 > > > > gre: Support GRE over IPv6 > > > > GRE over IPv6 implementation. > > > > Signed-off-by: Dmitry Kozlov > > Signed-off-by: David S. Miller > > > --- /dev/null > > +++ b/net/ipv6/ip6_gre.c > > > +static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, > > + struct net_device *dev, > > + __u8 dsfield, > > + struct flowi6 *fl6, > > + int encap_limit, > > + __u32 *pmtu) > > +{ > > + struct net *net = dev_net(dev); > > + 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 */ > > max_headroom is not initialized > > > + mtu = dst_mtu(dst) - sizeof(*ipv6h); > > + if (encap_limit >= 0) { > > + max_headroom += 8; > > Hence gcc (4.1.2) rightfully complains: > > net/ipv6/ip6_gre.c: In function ‘ip6gre_xmit2’: > net/ipv6/ip6_gre.c:713: warning: ‘max_headroom’ is used uninitialized in this function > > However, initializing max_headroom to zero at the top, or replacing the line > above by "max_headroom = 8" doesn't seem to be the right fix... > > > + mtu -= 8; > > + } > > + if (mtu < IPV6_MIN_MTU) > > + mtu = IPV6_MIN_MTU; > > + if (skb_dst(skb)) > > + skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu); > > + if (skb->len > mtu) { > > + *pmtu = mtu; > > + err = -EMSGSIZE; > > + goto tx_err_dst_release; > > + } > > + > > + if (tunnel->err_count > 0) { > > + if (time_before(jiffies, > > + tunnel->err_time + IP6TUNNEL_ERR_TIMEO)) { > > + tunnel->err_count--; > > + > > + dst_link_failure(skb); > > + } else > > + tunnel->err_count = 0; > > + } > > + > > + max_headroom = LL_RESERVED_SPACE(tdev) + gre_hlen + dst->header_len; > > ... as max_headroom is overwritten here anyway? > > So something is really wrong here. What is the right fix? > > This issue is present in current mainline as of v3.7. I would use following fix. Can you provide an official patch ? --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index d3ddd84..150d17d 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, 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, tunnel->err_count = 0; } - 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))) {