Skip to contentSkip to conversation

ip6_gre: fix endianness errors in ip6gre_err

PATCH Applied Sabrina Dubroca 3 participants 5 messages Feb 4, 2015 – Feb 5, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip6_gre: fix endianness errors in ip6gre_err

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")
---
 net/ipv6/ip6_gre.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ip6_gre.c +2 -2
index 13cda4c6313b..01ccc28a686f 100644
@@ -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;
Signature · 1 line
2.2.2
#2 lore raw
Quoted 11 lines · Eric Dumazet
Quoted 7 lines · Sabrina Dubroca

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")

---

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

#3 lore raw
Quoted 10 lines · Eric Dumazet
Quoted 9 lines · Eric Dumazet
Quoted 7 lines · Sabrina Dubroca

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")

---

Quoted 6 lines
Quoted 2 lines

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.

Signature · 1 line
Sabrina