Commit 6d3ce108 authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Ben Hutchings

batman-adv: Fix ICMP RR ethernet access after skb_linearize

commit 3b55e442 upstream.

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: da6b8c20 ("batman-adv: generalize batman-adv icmp packet handling")
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarMarek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 51e37ea1
...@@ -344,6 +344,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb, ...@@ -344,6 +344,7 @@ int batadv_recv_icmp_packet(struct sk_buff *skb,
if (skb_cow(skb, ETH_HLEN) < 0) if (skb_cow(skb, ETH_HLEN) < 0)
goto out; goto out;
ethhdr = eth_hdr(skb);
icmph = (struct batadv_icmp_header *)skb->data; icmph = (struct batadv_icmp_header *)skb->data;
icmp_packet_rr = (struct batadv_icmp_packet_rr *)icmph; icmp_packet_rr = (struct batadv_icmp_packet_rr *)icmph;
if (icmp_packet_rr->rr_cur >= BATADV_RR_LEN) if (icmp_packet_rr->rr_cur >= BATADV_RR_LEN)
......
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