Skip to contentSkip to conversation

GTP tunneling fixes for net

PATCH In review Pablo Neira Ayuso 2 participants 5 messages Dec 15, 2016 – Dec 17, 2016

Subsystems (4)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

cover GTP tunneling fixes for net

Hi David,

The following patchset contains two GTP tunneling fixes for your net tree, they are:

1) Offset to IPv4 header in gtp_check_src_ms_ipv4() is incorrect, thus this function always succeeds and therefore this defeats this sanity check. This allows packets that have no PDP to go though, patch from Lionel Gauthier.

2) According to Note 0 of Figure 2 in Section 6 of 3GPP TS 29.060 v13.5.0 Release 13, always set GTPv1 reserved bit to zero. This may cause interoperability problems, patch from Harald Welte.

Please, apply, thanks a lot!

Harald Welte (1):
gtp: Fix initialization of Flags octet in GTPv1 header

Lionel Gauthier (1):
gtp: gtp_check_src_ms_ipv4() always return success

 drivers/net/gtp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.4
author maintainer
#1 lore raw

PATCH 1/2 gtp: gtp_check_src_ms_ipv4() always return success

From: Lionel Gauthier <[email protected]>

gtp_check_src_ms_ipv4() did not find the PDP context matching with the UE IP address because the memory location is not right, but the result is inverted by the Boolean "not" operator. So whatever is the PDP context, any call to this function is successful.

---
 drivers/net/gtp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/gtp.c +2 -2
index 98f10c216521..6031d499f2be 100644
@@ -158,9 +158,9 @@ static bool gtp_check_src_ms_ipv4(struct sk_buff *skb, struct pdp_ctx *pctx,
 	if (!pskb_may_pull(skb, hdrlen + sizeof(struct iphdr)))
 		return false;
 
-	iph = (struct iphdr *)(skb->data + hdrlen + sizeof(struct iphdr));
+	iph = (struct iphdr *)(skb->data + hdrlen);
 
-	return iph->saddr != pctx->ms_addr_ip4.s_addr;
+	return iph->saddr == pctx->ms_addr_ip4.s_addr;
 }
 
 /* Check if the inner IP source address in this packet is assigned to any
Signature · 1 line
2.1.4
author maintainer
#2 lore raw

PATCH 2/2 gtp: Fix initialization of Flags octet in GTPv1 header

In reply to Pablo Neira Ayuso

From: Harald Welte <[email protected]>

When generating a GTPv1 header in gtp1_push_header(), initialize the 'reserved' bit to zero. All 3GPP specifications for GTPv1 from Release 99 through Release 13 agree that a transmitter shall set this bit to zero, see e.g. Note 0 of Figure 2 in Section 6 of 3GPP TS 29.060 v13.5.0 Release 13, available from
http://www.etsi.org/deliver/etsi_ts/129000_129099/129060/13.05.00_60/ts_129060v130500p.pdf

---
 drivers/net/gtp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/gtp.c +2 -2
index 6031d499f2be..8b6810bad54b 100644
@@ -423,11 +423,11 @@ static inline void gtp1_push_header(struct sk_buff *skb, struct pdp_ctx *pctx)
 
 	/* Bits    8  7  6  5  4  3  2	1
 	 *	  +--+--+--+--+--+--+--+--+
-	 *	  |version |PT| 1| E| S|PN|
+	 *	  |version |PT| 0| E| S|PN|
 	 *	  +--+--+--+--+--+--+--+--+
 	 *	    0  0  1  1	1  0  0  0
 	 */
-	gtp1->flags	= 0x38; /* v1, GTP-non-prime. */
+	gtp1->flags	= 0x30; /* v1, GTP-non-prime. */
 	gtp1->type	= GTP_TPDU;
 	gtp1->length	= htons(payload_len);
 	gtp1->tid	= htonl(pctx->u.v1.o_tei);
Signature · 1 line
2.1.4
author maintainer
#3 lore raw
In reply to Pablo Neira Ayuso

Sorry for the noise, this is not Netfilter related, my robot has tricked me, I have fixed it now.

Quoted 28 lines · Pablo Neira Ayuso

Hi David,

The following patchset contains two GTP tunneling fixes for your net tree, they are:

1) Offset to IPv4 header in gtp_check_src_ms_ipv4() is incorrect, thus this function always succeeds and therefore this defeats this sanity check. This allows packets that have no PDP to go though, patch from Lionel Gauthier.

2) According to Note 0 of Figure 2 in Section 6 of 3GPP TS 29.060 v13.5.0 Release 13, always set GTPv1 reserved bit to zero. This may cause interoperability problems, patch from Harald Welte.

Please, apply, thanks a lot!

Harald Welte (1):
gtp: Fix initialization of Flags octet in GTPv1 header

Lionel Gauthier (1):
gtp: gtp_check_src_ms_ipv4() always return success

 drivers/net/gtp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.4
maintainer
#4 lore raw
In reply to Pablo Neira Ayuso

From: Pablo Neira Ayuso <[email protected]>
Date: Thu, 15 Dec 2016 22:35:51 +0100

Quoted 8 lines

The following patchset contains two GTP tunneling fixes for your net tree, they are:

1) Offset to IPv4 header in gtp_check_src_ms_ipv4() is incorrect, thus this function always succeeds and therefore this defeats this sanity check. This allows packets that have no PDP to go though, patch from Lionel Gauthier.

Quoted 5 lines

2) According to Note 0 of Figure 2 in Section 6 of 3GPP TS 29.060 v13.5.0 Release 13, always set GTPv1 reserved bit to zero. This may cause interoperability problems, patch from Harald Welte.

Please, apply, thanks a lot!

Series applied, thanks Pablo.