Commit b0350d51 authored by Haishuang Yan's avatar Haishuang Yan Committed by David S. Miller

ip_gre: fix parsing gre header in ipgre_err

gre_parse_header stops parsing when csum_err is encountered, which means
tpi->key is undefined and ip_tunnel_lookup will return NULL improperly.

This patch introduce a NULL pointer as csum_err parameter. Even when
csum_err is encountered, it won't return error and continue parsing gre
header as expected.

Fixes: 9f57c67c ("gre: Remove support for sharing GRE protocol hook.")
Reported-by: default avatarJiri Benc <jbenc@redhat.com>
Signed-off-by: default avatarHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 21e65923
...@@ -86,13 +86,14 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi, ...@@ -86,13 +86,14 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
options = (__be32 *)(greh + 1); options = (__be32 *)(greh + 1);
if (greh->flags & GRE_CSUM) { if (greh->flags & GRE_CSUM) {
if (skb_checksum_simple_validate(skb)) { if (!skb_checksum_simple_validate(skb)) {
skb_checksum_try_convert(skb, IPPROTO_GRE, 0,
null_compute_pseudo);
} else if (csum_err) {
*csum_err = true; *csum_err = true;
return -EINVAL; return -EINVAL;
} }
skb_checksum_try_convert(skb, IPPROTO_GRE, 0,
null_compute_pseudo);
options++; options++;
} }
......
...@@ -232,13 +232,10 @@ static void gre_err(struct sk_buff *skb, u32 info) ...@@ -232,13 +232,10 @@ static void gre_err(struct sk_buff *skb, u32 info)
const int type = icmp_hdr(skb)->type; const int type = icmp_hdr(skb)->type;
const int code = icmp_hdr(skb)->code; const int code = icmp_hdr(skb)->code;
struct tnl_ptk_info tpi; struct tnl_ptk_info tpi;
bool csum_err = false;
if (gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP), if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IP),
iph->ihl * 4) < 0) { iph->ihl * 4) < 0)
if (!csum_err) /* ignore csum errors. */ return;
return;
}
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
ipv4_update_pmtu(skb, dev_net(skb->dev), info, ipv4_update_pmtu(skb, dev_net(skb->dev), info,
......
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