Skip to content

Commit 338ac29

Browse files
congwanggregkh
authored andcommitted
gre: refetch erspan header from skb->data after pskb_may_pull()
[ Upstream commit 0e49409 ] 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 <lorenzo.bianconi@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Acked-by: William Tu <u9012063@gmail.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d317809 commit 338ac29

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎net/ipv4/gre_demux.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
127127
if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))
128128
return -EINVAL;
129129

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

0 commit comments

Comments
 (0)