]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
batman-adv: access unicast_ttvn skb->data only after skb realloc
authorSven Eckelmann <sven@narfation.org>
Sun, 28 Jun 2026 06:35:35 +0000 (08:35 +0200)
committerSven Eckelmann <sven@narfation.org>
Sun, 28 Jun 2026 07:58:13 +0000 (09:58 +0200)
The pskb_may_pull() called by batadv_get_vid() could reallocate the buffer
behind the skb. Variables which were pointing to the old buffer need to be
reassigned to avoid an use-after-free.

This was done correctly for the ethernet header but missed for the
unicast_packet pointer.

Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Fixes: c018ad3de61a ("batman-adv: add the VLAN ID attribute to the TT entry")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
net/batman-adv/routing.c

index c05fcc9241adda443eda9db809d8fcf85549543c..2cc2307a417024a2296bc3481656d1861a22d0a6 100644 (file)
@@ -855,8 +855,8 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv,
        if (skb_cow(skb, sizeof(*unicast_packet)) < 0)
                return false;
 
-       unicast_packet = (struct batadv_unicast_packet *)skb->data;
        vid = batadv_get_vid(skb, hdr_len);
+       unicast_packet = (struct batadv_unicast_packet *)skb->data;
        ethhdr = (struct ethhdr *)(skb->data + hdr_len);
 
        /* do not reroute multicast frames in a unicast header */