pull request: batman-adv 2026-07-08
Subsystems (4)
Simon Wunderlich
maintainercover 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(-)
Simon Wunderlich
maintainerPATCH 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.
--- net/batman-adv/mesh-interface.c | 3 +++ 1 file changed, 3 insertions(+)
net/batman-adv/mesh-interface.c +3 -0
@@ -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
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 leastETH_HLENbytes 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
Simon Wunderlich
maintainerPATCH 2/9 batman-adv: fix VLAN priority offset
In reply to Simon WunderlichFrom: 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.
--- net/batman-adv/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/main.c +1 -1
@@ -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
Simon Wunderlich
maintainerPATCH 3/9 batman-adv: clean untagged VLAN on netdev registration failure
In reply to Simon WunderlichFrom: 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.
--- 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
@@ -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
@@ -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
@@ -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
Simon Wunderlich
maintainerPATCH 4/9 batman-adv: tt: avoid request storms during pending request
In reply to Simon WunderlichFrom: 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.
--- net/batman-adv/translation-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/translation-table.c +1 -1
@@ -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
Simon Wunderlich
maintainerPATCH 5/9 batman-adv: tt: prevent TVLV OOB check overflow
In reply to Simon WunderlichFrom: 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.
--- net/batman-adv/translation-table.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/batman-adv/translation-table.c +2 -1
@@ -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
Simon Wunderlich
maintainerPATCH 6/9 batman-adv: frag: free unfragmentable packet
In reply to Simon WunderlichFrom: 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.
--- net/batman-adv/fragmentation.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/batman-adv/fragmentation.c +4 -2
@@ -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
Simon Wunderlich
maintainerPATCH 7/9 batman-adv: frag: fix primary_if leak on failed linearization
In reply to Simon WunderlichFrom: 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.
--- net/batman-adv/fragmentation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/fragmentation.c +1 -1
@@ -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
Simon Wunderlich
maintainerPATCH 8/9 batman-adv: mcast: avoid OOB read of num_dests header
In reply to Simon WunderlichFrom: 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.
--- net/batman-adv/multicast_forw.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
net/batman-adv/multicast_forw.c +3 -4
@@ -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
Simon Wunderlich
maintainerPATCH 9/9 batman-adv: dat: fix tie-break for candidate selection
In reply to Simon WunderlichFrom: 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.
--- net/batman-adv/distributed-arp-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/distributed-arp-table.c +1 -1
@@ -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