Skip to contentSkip to conversation

esp4: Fix udpencap for local TCP packets.

PATCH Applied Steffen Klassert 2 participants 2 messages Jun 9, 2017 – Jun 10, 2017

Subsystems (3)
lore
Share & tools
lore

Steffen Klassert

author maintainer
#0 lore raw

PATCH 1/1 esp4: Fix udpencap for local TCP packets.

Locally generated TCP packets are usually cloned, so we do skb_cow_data() on this packets. After that we need to reload the pointer to the esp header. On udpencap this header has an offset to skb_transport_header, so take this offset into account.

This is a backport of:
commit 0e78a87306a ("esp4: Fix udpencap for local TCP packets.")

Fixes 67d349ed603 ("net/esp4: Fix invalid esph pointer crash")
Fixes fca11ebde3f0 ("esp4: Reorganize esp_output")
---
 net/ipv4/esp4.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/esp4.c +4 -1
index b1e2444..9708a32 100644
@@ -212,6 +212,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 	u8 *iv;
 	u8 *tail;
 	u8 *vaddr;
+	int esph_offset;
 	int blksize;
 	int clen;
 	int alen;
@@ -392,12 +393,14 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
 	}
 
 cow:
+	esph_offset = (unsigned char *)esph - skb_transport_header(skb);
+
 	err = skb_cow_data(skb, tailen, &trailer);
 	if (err < 0)
 		goto error;
 	nfrags = err;
 	tail = skb_tail_pointer(trailer);
-	esph = ip_esp_hdr(skb);
+	esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);
 
 skip_cow:
 	esp_output_fill_trailer(tail, tfclen, plen, proto);
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

From: Steffen Klassert <[email protected]>
Date: Fri, 9 Jun 2017 11:35:46 +0200

Quoted 6 lines

Locally generated TCP packets are usually cloned, so we do skb_cow_data() on this packets. After that we need to reload the pointer to the esp header. On udpencap this header has an offset to skb_transport_header, so take this offset into account.

Quoted 7 lines

This is a backport of:
commit 0e78a87306a ("esp4: Fix udpencap for local TCP packets.")

Fixes 67d349ed603 ("net/esp4: Fix invalid esph pointer crash")
Fixes fca11ebde3f0 ("esp4: Reorganize esp_output")

Queued up for -stable, thanks Steffen.