Skip to content

Commit

Permalink
gre: refetch erspan header from skb->data after pskb_may_pull()
Browse files Browse the repository at this point in the history
After pskb_may_pull() we should always refetch the header
pointers from the skb->data in case it got reallocated.

In gre_parse_header(), the erspan header is still fetched
from the 'options' pointer which is fetched before
pskb_may_pull().

Found this during code review of a KMSAN bug report.

Fixes: cb73ee4 ("net: ip_gre: use erspan key field for tunnel lookup")
Cc: Lorenzo Bianconi <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Acked-by: Lorenzo Bianconi <[email protected]>
Acked-by: William Tu <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
congwang authored and davem330 committed Dec 7, 2019
1 parent 02a896c commit 0e49409
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/ipv4/gre_demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))
return -EINVAL;

ershdr = (struct erspan_base_hdr *)options;
ershdr = (struct erspan_base_hdr *)(skb->data + nhs + hdr_len);
tpi->key = cpu_to_be32(get_session_id(ershdr));
}

Expand Down

0 comments on commit 0e49409

Please sign in to comment.