]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
geneve: Don't assume linear buffers in error handler
authorStefano Brivio <sbrivio@redhat.com>
Mon, 10 Jun 2019 22:27:06 +0000 (00:27 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 11 Jun 2019 19:07:33 +0000 (12:07 -0700)
In commit a07966447f39 ("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 26fc181e6cac
("fou, fou6: do not assume linear skbs") and 5355ed6388e2 ("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: Guillaume Nault <gnault@redhat.com>
Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/geneve.c

index 98d1a45c06067d7aeaae5a31465a3cb036c7e080..25770122c2197298512a82af4ea94237bc44ad0a 100644 (file)
@@ -395,7 +395,7 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)
        u8 zero_vni[3] = { 0 };
        u8 *vni = zero_vni;
 
-       if (skb->len < GENEVE_BASE_HLEN)
+       if (!pskb_may_pull(skb, skb_transport_offset(skb) + GENEVE_BASE_HLEN))
                return -EINVAL;
 
        geneveh = geneve_hdr(skb);