[PATCH batadv v2 3/5] batman-adv: dat: acquire ARP hw source only after skb realloc
Sven Eckelmann <[email protected]> Sun, 28 Jun 2026 09:25:36 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
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.
Fixes: 1fd1ce2d383f ("batman-adv: Snoop DHCPACKs for DAT")
Signed-off-by: Sven Eckelmann <[email protected]>
---
net/batman-adv/distributed-arp-table.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 56400009..7221d569 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -1824,6 +1824,7 @@ void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
u8 chaddr[BATADV_DHCP_CHADDR_LEN];
struct ethhdr *ethhdr;
unsigned short vid;
+ int hdr_size_tmp;
__be32 ip_src;
__be32 yiaddr;
__be16 proto;
@@ -1842,8 +1843,10 @@ void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
if (!batadv_dat_check_dhcp_ack(skb, proto, &ip_src, chaddr, &yiaddr))
return;
+ hdr_size_tmp = hdr_size;
+ vid = batadv_dat_get_vid(skb, &hdr_size_tmp);
+ ethhdr = (struct ethhdr *)(skb->data + hdr_size);
hw_src = ethhdr->h_source;
- vid = batadv_dat_get_vid(skb, &hdr_size);
batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid);
batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
--
2.47.3