Skip to contentSkip to conversation

batman-adv: fix potential kernel paging error for unicast transmissions

PATCH Applied Linus Lüssing 3 participants 3 messages Jan 20, 2014 – Jan 27, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 batman-adv: fix potential kernel paging error for unicast transmissions

batadv_send_skb_prepare_unicast(_4addr) might reallocate the skb's data. If it does then our ethhdr pointer is not valid anymore in batadv_send_skb_unicast(), resulting in a kernel paging error.

Fixing this by refetching the ethhdr pointer after the potential reallocation.

Introduced by b46c60b9e1ee7a1909c542413a85875a750955d6 ("batman-adv: improve unicast packet (re)routing")

---
Changes v4:
* "s/Introduced-by:/Introduced by/" to make checkpatch happy

 send.c |    4 ++++
 1 file changed, 4 insertions(+)
send.c +4 -0
index b0a3d76..50df184 100644
@@ -281,6 +281,10 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
 		goto out;
 	}
 
+	/* skb->data might have been reallocated by
+	 * batadv_send_skb_prepare_unicast*
+	 */
+	ethhdr = eth_hdr(skb);
 	unicast_packet = (struct batadv_unicast_packet *)skb->data;
 
 	/* inform the destination node that we are still missing a correct route
Signature · 1 line
1.7.10.4
Acked-by on v4 1/1
#1 lore raw
Quoted 11 lines · Linus Lüssing

batadv_send_skb_prepare_unicast(_4addr) might reallocate the skb's data. If it does then our ethhdr pointer is not valid anymore in batadv_send_skb_unicast(), resulting in a kernel paging error.

Fixing this by refetching the ethhdr pointer after the potential reallocation.

Introduced by b46c60b9e1ee7a1909c542413a85875a750955d6 ("batman-adv: improve unicast packet (re)routing")

Quoted 23 lines

---
Changes v4:
* "s/Introduced-by:/Introduced by/" to make checkpatch happy

 send.c |    4 ++++
 1 file changed, 4 insertions(+)
send.c +4 -0
index b0a3d76..50df184 100644
@@ -281,6 +281,10 @@ static int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
 		goto out;
 	}
 
+	/* skb->data might have been reallocated by
+	 * batadv_send_skb_prepare_unicast*
+	 */
+	ethhdr = eth_hdr(skb);
 	unicast_packet = (struct batadv_unicast_packet *)skb->data;
 
 	/* inform the destination node that we are still missing a correct route
Signature · 1 line
Antonio Quartulli
#2 lore raw
Quoted 12 lines · On Monday 20 January 2014 16:07:53 Antonio Quartulli wrote:
Quoted 11 lines · Linus Lüssing

batadv_send_skb_prepare_unicast(_4addr) might reallocate the skb's data. If it does then our ethhdr pointer is not valid anymore in batadv_send_skb_unicast(), resulting in a kernel paging error.

Fixing this by refetching the ethhdr pointer after the potential reallocation.

Quoted 8 lines
Quoted 6 lines

Introduced by b46c60b9e1ee7a1909c542413a85875a750955d6 ("batman-adv: improve unicast packet (re)routing")

Applied in revision 41b3872.

Thanks,
Marek