Skip to contentSkip to conversation

pull request: batman-adv 2026-07-08

PATCH Applied Simon Wunderlich 2 participants 11 messages Jul 8 – Jul 9

Subsystems (4)
lore
Share & tools
lore

Simon Wunderlich

author maintainer
#0 lore raw

cover pull request: batman-adv 2026-07-08

Dear net maintainers,

here are some more smaller bugfixes for batman-adv which we would like to have integrated into net.

Please pull or let me know of any problem!

Thank you,
Simon

The following changes since commit 26560c4a03dc4d607331600c187f59ab2df5f341:

batman-adv: dat: ensure accessible eth_hdr proto field (2026-06-28 11:49:04 +0200)

are available in the Git repository at:

https://git.open-mesh.org/batadv.git tags/batadv-net-pullrequest-20260708

for you to fetch changes up to 98052bdaf6ac1639a63ffc10244eeeab1f62ed2b:

batman-adv: dat: fix tie-break for candidate selection (2026-07-06 07:18:59 +0200)

----------------------------------------------------------------
Here are some batman-adv bugfixes, all by Sven Eckelmann:

- ensure minimal ethernet header on TX

- fix VLAN priority offset

- clean untagged VLAN on netdev registration failure

- tt: avoid request storms during pending request

- tt: prevent TVLV OOB check overflow

- frag: free unfragmentable packet

- frag: fix primary_if leak on failed linearization

- mcast: avoid OOB read of num_dests header

- dat: fix tie-break for candidate selection

----------------------------------------------------------------
Sven Eckelmann (9):
batman-adv: ensure minimal ethernet header on TX
batman-adv: fix VLAN priority offset
batman-adv: clean untagged VLAN on netdev registration failure
batman-adv: tt: avoid request storms during pending request
batman-adv: tt: prevent TVLV OOB check overflow
batman-adv: frag: free unfragmentable packet
batman-adv: frag: fix primary_if leak on failed linearization
batman-adv: mcast: avoid OOB read of num_dests header
batman-adv: dat: fix tie-break for candidate selection

 net/batman-adv/distributed-arp-table.c |  2 +-
 net/batman-adv/fragmentation.c         |  8 +++++---
 net/batman-adv/main.c                  | 10 +++++++++-
 net/batman-adv/mesh-interface.c        | 16 +++++-----------
 net/batman-adv/mesh-interface.h        |  2 ++
 net/batman-adv/multicast_forw.c        |  7 +++----
 net/batman-adv/translation-table.c     |  5 +++--
 7 files changed, 28 insertions(+), 22 deletions(-)
author maintainer
#1 lore raw

PATCH 1/9 batman-adv: ensure minimal ethernet header on TX

From: Sven Eckelmann <[email protected]>

As documented in commit 8bd67ebb50c0 ("net: bridge: xmit: make sure we have at least eth header len bytes"), it is possible by for a local user with eBPF TC hook access to attach a tc filter which truncates the packet and redirects to an batadv interface. But the code assumes that at least ETH_HLEN bytes are available and thus might read outside of the available buffer.

The batadv_interface_tx() must therefore always check itself if enough data is available for the ethernet header and don't rely on min_header_len.

Fixes c6c8fea29769 ("net: Add batman-adv meshing protocol")
---
 net/batman-adv/mesh-interface.c | 3 +++
 1 file changed, 3 insertions(+)
net/batman-adv/mesh-interface.c +3 -0
index 511f70e0706a7..0b75234521b63 100644
@@ -195,6 +195,9 @@ static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
 	if (READ_ONCE(bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
 		goto dropped;
 
+	if (!pskb_may_pull(skb, ETH_HLEN))
+		goto dropped;
+
 	/* reset control block to avoid left overs from previous users */
 	memset(skb->cb, 0, sizeof(struct batadv_skb_cb));
 
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH net 1/9] batman-adv: ensure minimal ethernet header on TX

This series was applied to netdev/net.git (main) by Sven Eckelmann <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Sven Eckelmann <[email protected]>:

Quoted 10 lines · On Wed, 8 Jul 2026 11:18:13 +0200 you wrote:

From: Sven Eckelmann <[email protected]>

As documented in commit 8bd67ebb50c0 ("net: bridge: xmit: make sure we have at least eth header len bytes"), it is possible by for a local user with eBPF TC hook access to attach a tc filter which truncates the packet and redirects to an batadv interface. But the code assumes that at least ETH_HLEN bytes are available and thus might read outside of the available buffer.

[...]

Here is the summary with links:
- [net,1/9] batman-adv: ensure minimal ethernet header on TX

    https://git.kernel.org/netdev/net/c/49df66b7993c
  - [net,2/9] batman-adv: fix VLAN priority offset
    https://git.kernel.org/netdev/net/c/fdb3be00ba4d
  - [net,3/9] batman-adv: clean untagged VLAN on netdev registration failure
    https://git.kernel.org/netdev/net/c/8669a550c752
  - [net,4/9] batman-adv: tt: avoid request storms during pending request
    https://git.kernel.org/netdev/net/c/27c7d4000823
  - [net,5/9] batman-adv: tt: prevent TVLV OOB check overflow
    https://git.kernel.org/netdev/net/c/7a581d9aaba8
  - [net,6/9] batman-adv: frag: free unfragmentable packet
    https://git.kernel.org/netdev/net/c/6b628425aed4
  - [net,7/9] batman-adv: frag: fix primary_if leak on failed linearization
    https://git.kernel.org/netdev/net/c/353d2c1d5492
  - [net,8/9] batman-adv: mcast: avoid OOB read of num_dests header
    https://git.kernel.org/netdev/net/c/38eaed28e250
  - [net,9/9] batman-adv: dat: fix tie-break for candidate selection
    https://git.kernel.org/netdev/net/c/98052bdaf6ac

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
author maintainer
#3 lore raw

PATCH 2/9 batman-adv: fix VLAN priority offset

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The batadv_skb_set_priority() receives an SKB with the inner ethernet header at position "offset". When it tries to extract the IPv4 and IPv6 header, it needs to skip the ethernet header to get access to the IP header.

But for VLAN header, it performs the access with the struct vlan_ethhdr. This struct contains both both the ethernet header and the VLAN header. It is therefore incorrect to skip over the whole vlan_ethhdr size to get access to the vlan_ethhdr.

Fixes c54f38c9aa22 ("batman-adv: set skb priority according to content")
---
 net/batman-adv/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/main.c +1 -1
index 4d3807a645b78..8844e40e6a803 100644
@@ -368,7 +368,7 @@ void batadv_skb_set_priority(struct sk_buff *skb, int offset)
 
 	switch (ethhdr->h_proto) {
 	case htons(ETH_P_8021Q):
-		vhdr = skb_header_pointer(skb, offset + sizeof(*vhdr),
+		vhdr = skb_header_pointer(skb, offset,
 					  sizeof(*vhdr), &vhdr_tmp);
 		if (!vhdr)
 			return;
Signature · 1 line
2.47.3
author maintainer
#4 lore raw

PATCH 3/9 batman-adv: clean untagged VLAN on netdev registration failure

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

When an mesh interface is registered, it creates an untagged struct batadv_meshif_vlan on top of it via the NETDEV_REGISTER notifier. But in this process, another receiver of this notification can veto the registration. The netdev registration will be aborted because of this veto.

The register_netdevice() call will try to clean up the net_device using unregister_netdevice_queue() - which only uses the .priv_destructor to free private resources. In this situation, .dellink will not be called.

The cleanup of the untagged batadv_meshif_vlan must thefore be done in the destructor to avoid a leak of this object.

Fixes 5d2c05b21337 ("batman-adv: add per VLAN interface attribute framework")
---
 net/batman-adv/main.c           |  8 ++++++++
 net/batman-adv/mesh-interface.c | 13 ++-----------
 net/batman-adv/mesh-interface.h |  2 ++
 3 files changed, 12 insertions(+), 11 deletions(-)
net/batman-adv/main.c +8 -0
index 8844e40e6a803..67bed3ee77e7e 100644
@@ -259,6 +259,7 @@ int batadv_mesh_init(struct net_device *mesh_iface)
 void batadv_mesh_free(struct net_device *mesh_iface)
 {
 	struct batadv_priv *bat_priv = netdev_priv(mesh_iface);
+	struct batadv_meshif_vlan *vlan;
 
 	WRITE_ONCE(bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
 
@@ -273,6 +274,13 @@ void batadv_mesh_free(struct net_device *mesh_iface)
 
 	batadv_mcast_free(bat_priv);
 
+	/* destroy the "untagged" VLAN */
+	vlan = batadv_meshif_vlan_get(bat_priv, BATADV_NO_FLAGS);
+	if (vlan) {
+		batadv_meshif_destroy_vlan(bat_priv, vlan);
+		batadv_meshif_vlan_put(vlan);
+	}
+
 	/* Free the TT and the originator tables only after having terminated
 	 * all the other depending components which may use these structures for
 	 * their purposes.
net/batman-adv/mesh-interface.c +2 -11
index 0b75234521b63..fbfd99268de47 100644
@@ -595,8 +595,8 @@ int batadv_meshif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
  * @bat_priv: the bat priv with all the mesh interface information
  * @vlan: the object to remove
  */
-static void batadv_meshif_destroy_vlan(struct batadv_priv *bat_priv,
-				       struct batadv_meshif_vlan *vlan)
+void batadv_meshif_destroy_vlan(struct batadv_priv *bat_priv,
+				struct batadv_meshif_vlan *vlan)
 {
 	/* explicitly remove the associated TT local entry because it is marked
 	 * with the NOPURGE flag
@@ -1091,22 +1091,13 @@ static int batadv_meshif_newlink(struct net_device *dev,
 static void batadv_meshif_destroy_netlink(struct net_device *mesh_iface,
 					  struct list_head *head)
 {
-	struct batadv_priv *bat_priv = netdev_priv(mesh_iface);
 	struct batadv_hard_iface *hard_iface;
-	struct batadv_meshif_vlan *vlan;
 
 	while (!list_empty(&mesh_iface->adj_list.lower)) {
 		hard_iface = netdev_adjacent_get_private(mesh_iface->adj_list.lower.next);
 		batadv_hardif_disable_interface(hard_iface);
 	}
 
-	/* destroy the "untagged" VLAN */
-	vlan = batadv_meshif_vlan_get(bat_priv, BATADV_NO_FLAGS);
-	if (vlan) {
-		batadv_meshif_destroy_vlan(bat_priv, vlan);
-		batadv_meshif_vlan_put(vlan);
-	}
-
 	unregister_netdevice_queue(mesh_iface, head);
 }
 
net/batman-adv/mesh-interface.h +2 -0
index 53756c5a45e04..5e1e83e04ffbc 100644
@@ -21,6 +21,8 @@ void batadv_interface_rx(struct net_device *mesh_iface,
 bool batadv_meshif_is_valid(const struct net_device *net_dev);
 extern struct rtnl_link_ops batadv_link_ops;
 int batadv_meshif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid);
+void batadv_meshif_destroy_vlan(struct batadv_priv *bat_priv,
+				struct batadv_meshif_vlan *vlan);
 void batadv_meshif_vlan_release(struct kref *ref);
 struct batadv_meshif_vlan *batadv_meshif_vlan_get(struct batadv_priv *bat_priv,
 						  unsigned short vid);
Signature · 1 line
2.47.3
author maintainer
#5 lore raw

PATCH 4/9 batman-adv: tt: avoid request storms during pending request

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

batadv_send_tt_request() allocates a tt_req_node when none exists for the destination originator node. This should prevent that a multiple TT requests are send at the same time to an originator.

But if allocation of the send buffer failed, this request must be cleaned up again. But indicator for such a failure is "ret == false". But the actual implementation is checking for "ret == true".

The check must be inverted to not loose the information about the TT request directly after it was attempted to be sent out. This should avoid potential request storms.

Fixes 335fbe0f5d25 ("batman-adv: tvlv - convert tt query packet to use tvlv unicast packets")
---
 net/batman-adv/translation-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/translation-table.c +1 -1
index 4bfad36a4b704..aae72015645a4 100644
@@ -2971,7 +2971,7 @@ static bool batadv_send_tt_request(struct batadv_priv *bat_priv,
 out:
 	batadv_hardif_put(primary_if);
 
-	if (ret && tt_req_node) {
+	if (!ret && tt_req_node) {
 		spin_lock_bh(&bat_priv->tt.req_list_lock);
 		if (!hlist_unhashed(&tt_req_node->list)) {
 			hlist_del_init(&tt_req_node->list);
Signature · 1 line
2.47.3
author maintainer
#6 lore raw

PATCH 5/9 batman-adv: tt: prevent TVLV OOB check overflow

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

A TT unicast TVLV contains the number of VLANs stored in it. This number is an u16 and gets multiplied by the size of the struct batadv_tvlv_tt_vlan_data (8 bytes). The size can therefore overflow the u16 used to store the tt_vlan_len. All additional safety checks to prevent out-of-bounds access of the TVLV buffer are invalid due to this overflow.

Using size_t prevents this overflow and ensures that the safety checks compare against the actual buffer requirements.

Fixes 7ea7b4a14275 ("batman-adv: make the TT CRC logic VLAN specific")
---
 net/batman-adv/translation-table.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/batman-adv/translation-table.c +2 -1
index aae72015645a4..dae5e1d8c0385 100644
@@ -4033,7 +4033,8 @@ static int batadv_tt_tvlv_unicast_handler_v1(struct batadv_priv *bat_priv,
 					     u16 tvlv_value_len)
 {
 	struct batadv_tvlv_tt_data *tt_data;
-	u16 tt_vlan_len, tt_num_entries;
+	u16 tt_num_entries;
+	size_t tt_vlan_len;
 	char tt_flag;
 	bool ret;
 
Signature · 1 line
2.47.3
author maintainer
#7 lore raw

PATCH 6/9 batman-adv: frag: free unfragmentable packet

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The caller of batadv_frag_send_packet() assume that the skb provided to the function are always consumed. But the pre-check for an empty payload or the zero fragment size returned an error without any further actions.

A failed pre-check must use the same error handling code as the rest of the function.

Fixes ee75ed88879a ("batman-adv: Fragment and send skbs larger than mtu")
---
 net/batman-adv/fragmentation.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/batman-adv/fragmentation.c +4 -2
index 8a006a0473a87..13d4689d332dc 100644
@@ -518,8 +518,10 @@ int batadv_frag_send_packet(struct sk_buff *skb,
 	mtu = min_t(unsigned int, mtu, BATADV_FRAG_MAX_FRAG_SIZE);
 	max_fragment_size = mtu - header_size;
 
-	if (skb->len == 0 || max_fragment_size == 0)
-		return -EINVAL;
+	if (skb->len == 0 || max_fragment_size == 0) {
+		ret = -EINVAL;
+		goto free_skb;
+	}
 
 	num_fragments = (skb->len - 1) / max_fragment_size + 1;
 	max_fragment_size = (skb->len - 1) / num_fragments + 1;
Signature · 1 line
2.47.3
author maintainer
#8 lore raw

PATCH 7/9 batman-adv: frag: fix primary_if leak on failed linearization

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

If the skb has a frag_list, it must be linearized before it can be split using skb_split(). But when this step failed, it must not only free the skb but also take care of the reference to the already found primary_if.

Fixes a063f2fba3fa ("batman-adv: Don't skb_split skbuffs with frag_list")
---
 net/batman-adv/fragmentation.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/fragmentation.c +1 -1
index 13d4689d332dc..2e20a2cb64cbf 100644
@@ -547,7 +547,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
 	 */
 	if (skb_has_frag_list(skb) && __skb_linearize(skb)) {
 		ret = -ENOMEM;
-		goto free_skb;
+		goto put_primary_if;
 	}
 
 	/* Create one header to be copied to all fragments */
Signature · 1 line
2.47.3
author maintainer
#9 lore raw

PATCH 8/9 batman-adv: mcast: avoid OOB read of num_dests header

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

Before the access to struct batadv_tvlv_mcast_tracker's num_dests, it is attempted to check whether enough space is actually in the network header. But instead of using offsetofend() to check for the whole size (2) which must be accessible, offsetof() of is called. The latter is always returning
0. The comparison with the network header length will always return that enough data is available - even when only 1 or 0 bytes are accessible.

Instead of using offsetofend(), use the more common check for the whole header.

Fixes 07afe1ba288c ("batman-adv: mcast: implement multicast packet reception and forwarding")
---
 net/batman-adv/multicast_forw.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
net/batman-adv/multicast_forw.c +3 -4
index b8668a80b94a1..1404a3b7adfb1 100644
@@ -927,11 +927,11 @@ static int batadv_mcast_forw_packet(struct batadv_priv *bat_priv,
 {
 	struct batadv_tvlv_mcast_tracker *mcast_tracker;
 	struct batadv_neigh_node *neigh_node;
-	unsigned long offset, num_dests_off;
 	struct sk_buff *nexthop_skb;
 	unsigned char *skb_net_hdr;
 	bool local_recv = false;
 	unsigned int tvlv_len;
+	unsigned long offset;
 	bool xmitted = false;
 	u8 *dest, *next_dest;
 	u16 num_dests;
@@ -940,9 +940,8 @@ static int batadv_mcast_forw_packet(struct batadv_priv *bat_priv,
 	/* (at least) TVLV part needs to be linearized */
 	SKB_LINEAR_ASSERT(skb);
 
-	/* check if num_dests is within skb length */
-	num_dests_off = offsetof(struct batadv_tvlv_mcast_tracker, num_dests);
-	if (num_dests_off > skb_network_header_len(skb))
+	/* check if batadv_tvlv_mcast_tracker header is within skb length */
+	if (sizeof(*mcast_tracker) > skb_network_header_len(skb))
 		return -EINVAL;
 
 	skb_net_hdr = skb_network_header(skb);
Signature · 1 line
2.47.3
author maintainer
#10 lore raw

PATCH 9/9 batman-adv: dat: fix tie-break for candidate selection

In reply to Simon Wunderlich

From: Sven Eckelmann <[email protected]>

The original version of the candidate selection for DAT attempted to compare both candidate and max_orig_node to identify which has the smaller MAC address. This comparison is required as tie-break when a hash collision happened.

But the used function returned 0 when the function was not equal and a non-zero value when it was equal. As result, the actually selected node was dependent on the order of entries in the orig_hash and not actually on the mac addresses. The last originator in the hash collision would always win.

To have a proper ordering, it must diff the actual MAC address bytes and reject the candidate when the diff is not smaller than 0.

Fixes 785ea1144182 ("batman-adv: Distributed ARP Table - create DHT helper functions")
---
 net/batman-adv/distributed-arp-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/distributed-arp-table.c +1 -1
index c40c9e02391be..a6fe4820f65b9 100644
@@ -546,7 +546,7 @@ static bool batadv_is_orig_node_eligible(struct batadv_dat_candidate *res,
 	 * the one with the lowest address
 	 */
 	if (tmp_max == max && max_orig_node &&
-	    batadv_compare_eth(candidate->orig, max_orig_node->orig))
+	    memcmp(candidate->orig, max_orig_node->orig, ETH_ALEN) >= 0)
 		goto out;
 
 	ret = true;
Signature · 1 line
2.47.3