Commit c9857807 authored by Jiri Benc's avatar Jiri Benc Committed by Greg Kroah-Hartman

gre: do not pull header in ICMP error processing

[ Upstream commit b7f8fe25 ]

iptunnel_pull_header expects that IP header was already pulled; with this
expectation, it pulls the tunnel header. This is not true in gre_err.
Furthermore, ipv4_update_pmtu and ipv4_redirect expect that skb->data points
to the IP header.

We cannot pull the tunnel header in this path. It's just a matter of not
calling iptunnel_pull_header - we don't need any of its effects.

Fixes: bda7bb46 ("gre: Allow multiple protocol listener for gre protocol.")
Signed-off-by: default avatarJiri Benc <jbenc@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 390d4b3e
...@@ -180,6 +180,7 @@ static __be16 tnl_flags_to_gre_flags(__be16 tflags) ...@@ -180,6 +180,7 @@ static __be16 tnl_flags_to_gre_flags(__be16 tflags)
return flags; return flags;
} }
/* Fills in tpi and returns header length to be pulled. */
static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
bool *csum_err) bool *csum_err)
{ {
...@@ -239,7 +240,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, ...@@ -239,7 +240,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
return -EINVAL; return -EINVAL;
} }
} }
return iptunnel_pull_header(skb, hdr_len, tpi->proto); return hdr_len;
} }
static void ipgre_err(struct sk_buff *skb, u32 info, static void ipgre_err(struct sk_buff *skb, u32 info,
...@@ -342,7 +343,7 @@ static void gre_err(struct sk_buff *skb, u32 info) ...@@ -342,7 +343,7 @@ static void gre_err(struct sk_buff *skb, u32 info)
struct tnl_ptk_info tpi; struct tnl_ptk_info tpi;
bool csum_err = false; bool csum_err = false;
if (parse_gre_header(skb, &tpi, &csum_err)) { if (parse_gre_header(skb, &tpi, &csum_err) < 0) {
if (!csum_err) /* ignore csum errors. */ if (!csum_err) /* ignore csum errors. */
return; return;
} }
...@@ -420,6 +421,7 @@ static int gre_rcv(struct sk_buff *skb) ...@@ -420,6 +421,7 @@ static int gre_rcv(struct sk_buff *skb)
{ {
struct tnl_ptk_info tpi; struct tnl_ptk_info tpi;
bool csum_err = false; bool csum_err = false;
int hdr_len;
#ifdef CONFIG_NET_IPGRE_BROADCAST #ifdef CONFIG_NET_IPGRE_BROADCAST
if (ipv4_is_multicast(ip_hdr(skb)->daddr)) { if (ipv4_is_multicast(ip_hdr(skb)->daddr)) {
...@@ -429,7 +431,10 @@ static int gre_rcv(struct sk_buff *skb) ...@@ -429,7 +431,10 @@ static int gre_rcv(struct sk_buff *skb)
} }
#endif #endif
if (parse_gre_header(skb, &tpi, &csum_err) < 0) hdr_len = parse_gre_header(skb, &tpi, &csum_err);
if (hdr_len < 0)
goto drop;
if (iptunnel_pull_header(skb, hdr_len, tpi.proto) < 0)
goto drop; goto drop;
if (ipgre_rcv(skb, &tpi) == PACKET_RCVD) if (ipgre_rcv(skb, &tpi) == PACKET_RCVD)
......
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