]> git.hungrycats.org Git - linux/commitdiff
batman-adv: update data pointers after skb_cow()
authorMatthias Schiffer <mschiffer@universe-factory.net>
Fri, 16 Mar 2018 10:29:09 +0000 (11:29 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 16 Jun 2018 21:22:42 +0000 (22:22 +0100)
commit bc44b78157f621ff2a2618fe287a827bcb094ac4 upstream.

batadv_check_unicast_ttvn() calls skb_cow(), so pointers into the SKB data
must be (re)set after calling it. The ethhdr variable is dropped
altogether.

Fixes: 7cdcf6dddc42 ("batman-adv: add UNICAST_4ADDR packet type")
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
[bwh: Backported to 3.16:
 - There's no ethhdr variable here
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/batman-adv/routing.c

index 7a1032348ea9f90bf8d5d213128ff524c35f3db6..5015430a95490936838999bc312a2f86a7a31c2e 100644 (file)
@@ -886,8 +886,6 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
        bool is4addr;
 
        unicast_packet = (struct batadv_unicast_packet *)skb->data;
-       unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
-
        is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
        /* the caller function should have already pulled 2 bytes */
        if (is4addr)
@@ -907,9 +905,13 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
        if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
                return NET_RX_DROP;
 
+       unicast_packet = (struct batadv_unicast_packet *)skb->data;
+
        /* packet for me */
        if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
                if (is4addr) {
+                       unicast_4addr_packet =
+                               (struct batadv_unicast_4addr_packet *)skb->data;
                        batadv_dat_inc_counter(bat_priv,
                                               unicast_4addr_packet->subtype);
                        orig_addr = unicast_4addr_packet->src;