batman-adv: Fix ICMP RR ethernet access after skb_linearize
authorSven Eckelmann <sven@narfation.org>
Sun, 26 Jun 2016 09:16:12 +0000 (11:16 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Jun 2016 08:01:48 +0000 (04:01 -0400)
The skb_linearize may reallocate the skb. This makes the calculated pointer
for ethhdr invalid. But it the pointer is used later to fill in the RR
field of the batadv_icmp_packet_rr packet.

Instead re-evaluate eth_hdr after the skb_linearize+skb_cow to fix the
pointer and avoid the invalid read.

Fixes: da6b8c20a5b8 ("batman-adv: generalize batman-adv icmp packet handling")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/batman-adv/routing.c

index e3857ed4057f55d2f90ff72ed7cb8a14532d6fe2..6c2901a86230ec231a1ee5338c6282da9e20276d 100644 (file)
@@ -374,6 +374,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
                if (skb_cow(skb, ETH_HLEN) < 0)
                        goto out;
 
+               ethhdr = eth_hdr(skb);
                icmph = (struct batadv_icmp_header *)skb->data;
                icmp_packet_rr = (struct batadv_icmp_packet_rr *)icmph;
                if (icmp_packet_rr->rr_cur >= BATADV_RR_LEN)