Skip to content

Commit

Permalink
batman-adv: Fix ICMP RR ethernet access after skb_linearize
Browse files Browse the repository at this point in the history
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: da6b8c2 ("batman-adv: generalize batman-adv icmp packet handling")
Signed-off-by: Sven Eckelmann <[email protected]>
Signed-off-by: Marek Lindner <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ecsv authored and davem330 committed Jun 29, 2016
1 parent baceced commit 3b55e44
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/batman-adv/routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b55e44

Please sign in to comment.