* [PATCH net] gre: do not pull header in ICMP error processing
@ 2016-04-29 21:31 Jiri Benc
2016-05-02 4:20 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Benc @ 2016-04-29 21:31 UTC (permalink / raw)
To: netdev; +Cc: Pravin B Shelar
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: bda7bb463436 ("gre: Allow multiple protocol listener for gre protocol.")
Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
net/ipv4/ip_gre.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index f502d34bcb40..205a2b8a5a84 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -179,6 +179,7 @@ static __be16 tnl_flags_to_gre_flags(__be16 tflags)
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,
bool *csum_err)
{
@@ -238,7 +239,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
return -EINVAL;
}
}
- return iptunnel_pull_header(skb, hdr_len, tpi->proto, false);
+ return hdr_len;
}
static void ipgre_err(struct sk_buff *skb, u32 info,
@@ -341,7 +342,7 @@ static void gre_err(struct sk_buff *skb, u32 info)
struct tnl_ptk_info tpi;
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. */
return;
}
@@ -419,6 +420,7 @@ static int gre_rcv(struct sk_buff *skb)
{
struct tnl_ptk_info tpi;
bool csum_err = false;
+ int hdr_len;
#ifdef CONFIG_NET_IPGRE_BROADCAST
if (ipv4_is_multicast(ip_hdr(skb)->daddr)) {
@@ -428,7 +430,10 @@ static int gre_rcv(struct sk_buff *skb)
}
#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, false) < 0)
goto drop;
if (ipgre_rcv(skb, &tpi) == PACKET_RCVD)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] gre: do not pull header in ICMP error processing
2016-04-29 21:31 [PATCH net] gre: do not pull header in ICMP error processing Jiri Benc
@ 2016-05-02 4:20 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-05-02 4:20 UTC (permalink / raw)
To: jbenc; +Cc: netdev, pshelar
From: Jiri Benc <jbenc@redhat.com>
Date: Fri, 29 Apr 2016 23:31:32 +0200
> 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: bda7bb463436 ("gre: Allow multiple protocol listener for gre protocol.")
> Signed-off-by: Jiri Benc <jbenc@redhat.com>
Applied and queued up for -stable, thanks Jiri.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-02 4:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-29 21:31 [PATCH net] gre: do not pull header in ICMP error processing Jiri Benc
2016-05-02 4:20 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).