Skip to contentSkip to conversation

batman-adv: fix memory access by setting mac_header in DAT

PATCH Applied Antonio Quartulli 2 participants 4 messages Feb 11, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batman-adv: fix memory access by setting mac_header in DAT

In the TX path we now have functions that rely on the skb->mac_header field. DAT does not set such field when creating its own ARP packets thus leading to wrong memory access.

Fix it by always setting the mac_header after having forged the ARP packet.

---
 distributed-arp-table.c | 5 +++++
 1 file changed, 5 insertions(+)
distributed-arp-table.c +5 -0
index 6da587a..0b69b61 100644
@@ -1028,6 +1028,11 @@ bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
 	if (!skb_new)
 		goto out;
 
+	/* the rest of the TX path assumes that the mac_header offset pointing
+	 * to the inner Ethernet header has been set, therefore reset it now.
+	 */
+	skb_reset_mac_header(skb_new);
+
 	if (vid & BATADV_VLAN_HAS_TAG)
 		skb_new = vlan_insert_tag(skb_new, htons(ETH_P_8021Q),
 					  vid & VLAN_VID_MASK);
Signature · 1 line
1.8.5.3
#1 lore raw
Quoted 11 lines · Antonio Quartulli

In the TX path we now have functions that rely on the skb->mac_header field. DAT does not set such field when creating its own ARP packets thus leading to wrong memory access.

Fix it by always setting the mac_header after having forged the ARP packet.

This patch is supposed to be applied on maint.

Cheers,

Signature · 1 line
Antonio Quartulli
#2 lore raw
Quoted 6 lines · Antonio Quartulli
Quoted 5 lines · Antonio Quartulli

In the TX path we now have functions that rely on the skb->mac_header field. DAT does not set such field when creating its own ARP packets thus leading to wrong memory access.

Quoted 8 lines
Quoted 6 lines

Fix it by always setting the mac_header after having forged the ARP packet.

This patch is supposed to be applied on maint.

Introduced by 41b38727749a94c1a65cf0f4be9bfe1cbaf0adeb ("batman-adv: fix potential kernel paging error for unicast transmissions")

In this patch we have the introduction of eth_hdr() in batadv_send_skb_unicast() which creates the problem..

Cheers,

Signature · 1 line
Antonio Quartulli
#3 lore raw
Quoted 16 lines · On Tuesday 11 February 2014 11:58:26 Antonio Quartulli wrote:
Quoted 15 lines · Antonio Quartulli
Quoted 11 lines · Antonio Quartulli

In the TX path we now have functions that rely on the skb->mac_header field. DAT does not set such field when creating its own ARP packets thus leading to wrong memory access.

Fix it by always setting the mac_header after having forged the ARP packet.

Quoted 4 lines
Quoted 1 line

This patch is supposed to be applied on maint.

Introduced by 41b38727749a94c1a65cf0f4be9bfe1cbaf0adeb ("batman-adv: fix potential kernel paging error for unicast transmissions")

Applied in revision df99b07.

Thanks,
Marek