From: Cong Wang Date: Fri, 6 Dec 2019 03:39:02 +0000 (-0800) Subject: gre: refetch erspan header from skb->data after pskb_may_pull() X-Git-Tag: v5.15~4919^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e4940928c26527ce8f97237fef4c8a91cd34207;p=platform%2Fkernel%2Flinux-starfive.git gre: refetch erspan header from skb->data after pskb_may_pull() 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: cb73ee40b1b3 ("net: ip_gre: use erspan key field for tunnel lookup") Cc: Lorenzo Bianconi Signed-off-by: Cong Wang Acked-by: Lorenzo Bianconi Acked-by: William Tu Reviewed-by: Simon Horman Signed-off-by: David S. Miller --- diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c index 44bfeec..5fd6e8e 100644 --- a/net/ipv4/gre_demux.c +++ b/net/ipv4/gre_demux.c @@ -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)); }