Commit 0e78a873 authored by Steffen Klassert's avatar Steffen Klassert

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.

Fixes: 67d349ed ("net/esp4: Fix invalid esph pointer crash")
Fixes: fca11ebd ("esp4: Reorganize esp_output")
Reported-by: default avatarDon Bowman <db@donbowman.ca>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent f411af68
...@@ -248,6 +248,7 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info * ...@@ -248,6 +248,7 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
u8 *tail; u8 *tail;
u8 *vaddr; u8 *vaddr;
int nfrags; int nfrags;
int esph_offset;
struct page *page; struct page *page;
struct sk_buff *trailer; struct sk_buff *trailer;
int tailen = esp->tailen; int tailen = esp->tailen;
...@@ -313,11 +314,13 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info * ...@@ -313,11 +314,13 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *
} }
cow: cow:
esph_offset = (unsigned char *)esp->esph - skb_transport_header(skb);
nfrags = skb_cow_data(skb, tailen, &trailer); nfrags = skb_cow_data(skb, tailen, &trailer);
if (nfrags < 0) if (nfrags < 0)
goto out; goto out;
tail = skb_tail_pointer(trailer); tail = skb_tail_pointer(trailer);
esp->esph = ip_esp_hdr(skb); esp->esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);
skip_cow: skip_cow:
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto); esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment