Skip to content

Commit b7f8fe2

Browse files
Jiri Bencdavem330
authored andcommitted
gre: do not pull header in ICMP error processing
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: bda7bb4 ("gre: Allow multiple protocol listener for gre protocol.") Signed-off-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2c94b53 commit b7f8fe2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

net/ipv4/ip_gre.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ static __be16 tnl_flags_to_gre_flags(__be16 tflags)
179179
return flags;
180180
}
181181

182+
/* Fills in tpi and returns header length to be pulled. */
182183
static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
183184
bool *csum_err)
184185
{
@@ -238,7 +239,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
238239
return -EINVAL;
239240
}
240241
}
241-
return iptunnel_pull_header(skb, hdr_len, tpi->proto, false);
242+
return hdr_len;
242243
}
243244

244245
static void ipgre_err(struct sk_buff *skb, u32 info,
@@ -341,7 +342,7 @@ static void gre_err(struct sk_buff *skb, u32 info)
341342
struct tnl_ptk_info tpi;
342343
bool csum_err = false;
343344

344-
if (parse_gre_header(skb, &tpi, &csum_err)) {
345+
if (parse_gre_header(skb, &tpi, &csum_err) < 0) {
345346
if (!csum_err) /* ignore csum errors. */
346347
return;
347348
}
@@ -419,6 +420,7 @@ static int gre_rcv(struct sk_buff *skb)
419420
{
420421
struct tnl_ptk_info tpi;
421422
bool csum_err = false;
423+
int hdr_len;
422424

423425
#ifdef CONFIG_NET_IPGRE_BROADCAST
424426
if (ipv4_is_multicast(ip_hdr(skb)->daddr)) {
@@ -428,7 +430,10 @@ static int gre_rcv(struct sk_buff *skb)
428430
}
429431
#endif
430432

431-
if (parse_gre_header(skb, &tpi, &csum_err) < 0)
433+
hdr_len = parse_gre_header(skb, &tpi, &csum_err);
434+
if (hdr_len < 0)
435+
goto drop;
436+
if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false) < 0)
432437
goto drop;
433438

434439
if (ipgre_rcv(skb, &tpi) == PACKET_RCVD)

0 commit comments

Comments
 (0)