diff mbox

[net] ip6_gre: fix endianness errors in ip6gre_err

Message ID 1423059909-15606-1-git-send-email-sd@queasysnail.net
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Sabrina Dubroca Feb. 4, 2015, 2:25 p.m. UTC
info is in network byte order, change it back to host byte order
before use. In particular, the current code sets the MTU of the tunnel
to a wrong (too big) value.

Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 net/ipv6/ip6_gre.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Eric Dumazet Feb. 4, 2015, 3:44 p.m. UTC | #1
On Wed, 2015-02-04 at 15:25 +0100, Sabrina Dubroca wrote:
> info is in network byte order, change it back to host byte order
> before use. In particular, the current code sets the MTU of the tunnel
> to a wrong (too big) value.
> 
> Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> ---

Acked-by: Eric Dumazet <edumazet@google.com>


--
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
Eric Dumazet Feb. 4, 2015, 3:50 p.m. UTC | #2
On Wed, 2015-02-04 at 07:44 -0800, Eric Dumazet wrote:
> On Wed, 2015-02-04 at 15:25 +0100, Sabrina Dubroca wrote:
> > info is in network byte order, change it back to host byte order
> > before use. In particular, the current code sets the MTU of the tunnel
> > to a wrong (too big) value.
> > 
> > Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
> > Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> > ---
> 
> Acked-by: Eric Dumazet <edumazet@google.com>
> 


BTW, "fl6.flowi6_proto = skb->protocol; " in ip6gre_xmit_other()
looks suspicious...


--
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
Sabrina Dubroca Feb. 4, 2015, 11:38 p.m. UTC | #3
2015-02-04, 07:50:12 -0800, Eric Dumazet wrote:
> On Wed, 2015-02-04 at 07:44 -0800, Eric Dumazet wrote:
> > On Wed, 2015-02-04 at 15:25 +0100, Sabrina Dubroca wrote:
> > > info is in network byte order, change it back to host byte order
> > > before use. In particular, the current code sets the MTU of the tunnel
> > > to a wrong (too big) value.
> > > 
> > > Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
> > > Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> > > ---
> > 
> > Acked-by: Eric Dumazet <edumazet@google.com>
> > 
> 
> 
> BTW, "fl6.flowi6_proto = skb->protocol; " in ip6gre_xmit_other()
> looks suspicious...

Yes, I know that sparse complains about it.  I don't know how to
handle that for now.  ntohs would silence the sparse warning, but we
would still have u8 vs u16.  I'll need to have a closer look.
David Miller Feb. 5, 2015, 8:34 a.m. UTC | #4
From: Sabrina Dubroca <sd@queasysnail.net>
Date: Wed,  4 Feb 2015 15:25:09 +0100

> info is in network byte order, change it back to host byte order
> before use. In particular, the current code sets the MTU of the tunnel
> to a wrong (too big) value.
> 
> Fixes: c12b395a4664 ("gre: Support GRE over IPv6")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>

Applied.
--
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 mbox

Patch

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 13cda4c6313b..01ccc28a686f 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -417,7 +417,7 @@  static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 		if (code == ICMPV6_HDR_FIELD)
 			teli = ip6_tnl_parse_tlv_enc_lim(skb, skb->data);
 
-		if (teli && teli == info - 2) {
+		if (teli && teli == be32_to_cpu(info) - 2) {
 			tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];
 			if (tel->encap_limit == 0) {
 				net_warn_ratelimited("%s: Too small encapsulation limit or routing loop in tunnel!\n",
@@ -429,7 +429,7 @@  static void ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 		}
 		break;
 	case ICMPV6_PKT_TOOBIG:
-		mtu = info - offset;
+		mtu = be32_to_cpu(info) - offset;
 		if (mtu < IPV6_MIN_MTU)
 			mtu = IPV6_MIN_MTU;
 		t->dev->mtu = mtu;