Commit af1c05e6 authored by Stefano Brivio's avatar Stefano Brivio Committed by Greg Kroah-Hartman

geneve: Don't assume linear buffers in error handler

[ Upstream commit eccc73a6 ]

In commit a0796644 ("geneve: ICMP error lookup handler") I wrongly
assumed buffers from icmp_socket_deliver() would be linear. This is not
the case: icmp_socket_deliver() only guarantees we have 8 bytes of linear
data.

Eric fixed this same issue for fou and fou6 in commits 26fc181e
("fou, fou6: do not assume linear skbs") and 5355ed63 ("fou, fou6:
avoid uninit-value in gue_err() and gue6_err()").

Use pskb_may_pull() instead of checking skb->len, and take into account
the fact we later access the GENEVE header with udp_hdr(), so we also
need to sum skb_transport_header() here.
Reported-by: default avatarGuillaume Nault <gnault@redhat.com>
Fixes: a0796644 ("geneve: ICMP error lookup handler")
Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0cb7d324
...@@ -396,7 +396,7 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb) ...@@ -396,7 +396,7 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)
u8 zero_vni[3] = { 0 }; u8 zero_vni[3] = { 0 };
u8 *vni = zero_vni; u8 *vni = zero_vni;
if (skb->len < GENEVE_BASE_HLEN) if (!pskb_may_pull(skb, skb_transport_offset(skb) + GENEVE_BASE_HLEN))
return -EINVAL; return -EINVAL;
geneveh = geneve_hdr(skb); geneveh = geneve_hdr(skb);
......
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