Commit a5afcf85 authored by Steffen Klassert's avatar Steffen Klassert Committed by Greg Kroah-Hartman

esp4: Fix udpencap for local TCP packets.

[ Upstream commit 0e78a873 ]

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 0e78a873 ("esp4: Fix udpencap for local TCP packets.")

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>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b9a1254c
...@@ -212,6 +212,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -212,6 +212,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
u8 *iv; u8 *iv;
u8 *tail; u8 *tail;
u8 *vaddr; u8 *vaddr;
int esph_offset;
int blksize; int blksize;
int clen; int clen;
int alen; int alen;
...@@ -392,12 +393,14 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb) ...@@ -392,12 +393,14 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
} }
cow: cow:
esph_offset = (unsigned char *)esph - skb_transport_header(skb);
err = skb_cow_data(skb, tailen, &trailer); err = skb_cow_data(skb, tailen, &trailer);
if (err < 0) if (err < 0)
goto error; goto error;
nfrags = err; nfrags = err;
tail = skb_tail_pointer(trailer); tail = skb_tail_pointer(trailer);
esph = ip_esp_hdr(skb); esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);
skip_cow: skip_cow:
esp_output_fill_trailer(tail, tfclen, plen, proto); esp_output_fill_trailer(tail, tfclen, plen, 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