pull request: batman-adv 2025-10-24
Subsystems (4)
Simon Wunderlich
maintainercover pull request: batman-adv 2025-10-24
Hi David, hi Jakub,
here is a bugfix 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 d69eb204c255c35abd9e8cb621484e8074c75eaa:
Merge tag 'net-6.17-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2025-09-04 09:59:15 -0700)
are available in the Git repository at:
https://git.open-mesh.org/linux-merge.git tags/batadv-net-pullrequest-20251024
for you to fetch changes up to f12b69d8f22824a07f17c1399c99757072de73e0:
batman-adv: Release references to inactive interfaces (2025-09-27 19:59:49 +0200)
----------------------------------------------------------------
Here is a batman-adv bugfix:
- release references to inactive interfaces, by Sven Eckelmann
----------------------------------------------------------------
Sven Eckelmann (1):
batman-adv: Release references to inactive interfaces
net/batman-adv/originator.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
Simon Wunderlich
maintainerPATCH 1/1 batman-adv: Release references to inactive interfaces
From: Sven Eckelmann <[email protected]>
Trying to dump the originators or the neighbors via netlink for a meshif with an inactive primary interface is not allowed. The dump functions were checking this correctly but they didn't handle non-existing primary interfaces and existing _inactive_ interfaces differently.
(Primary) batadv_hard_ifaces hold a references to a net_device. And accessing them is only allowed when either being in a RCU/spinlock protected section or when holding a valid reference to them. The netlink dump functions use the latter.
But because the missing specific error handling for inactive primary interfaces, the reference was never dropped. This reference counting error was only detected when the interface should have been removed from the system:
unregister_netdevice: waiting for batadv_slave_0 to become free. Usage count = 2
--- net/batman-adv/originator.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/batman-adv/originator.c +12 -2
@@ -764,11 +764,16 @@ int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb) bat_priv =netdev_priv (mesh_iface); primary_if =batadv_primary_if_get_selected (bat_priv); -if (!primary_if || primary_if->if_status !=BATADV_IF_ACTIVE ) { +if (!primary_if) { ret = -ENOENT ; goto out_put_mesh_iface; } +if (primary_if->if_status !=BATADV_IF_ACTIVE ) { + ret = -ENOENT ; + goto out_put_primary_if; + } + hard_iface =batadv_netlink_get_hardif (bat_priv, cb);if (IS_ERR (hard_iface) &&PTR_ERR (hard_iface) != -ENONET ) { ret =PTR_ERR (hard_iface);
@@ -1333,11 +1338,16 @@ int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb) bat_priv =netdev_priv (mesh_iface); primary_if =batadv_primary_if_get_selected (bat_priv); -if (!primary_if || primary_if->if_status !=BATADV_IF_ACTIVE ) { +if (!primary_if) { ret = -ENOENT ; goto out_put_mesh_iface; } +if (primary_if->if_status !=BATADV_IF_ACTIVE ) { + ret = -ENOENT ; + goto out_put_primary_if; + } + hard_iface =batadv_netlink_get_hardif (bat_priv, cb);if (IS_ERR (hard_iface) &&PTR_ERR (hard_iface) != -ENONET ) { ret =PTR_ERR (hard_iface);
Signature · 1 line
2.47.3
Re: [PATCH net 1/1] batman-adv: Release references to inactive interfaces
This patch was applied to netdev/net.git (main) by Simon Wunderlich <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Simon Wunderlich <[email protected]>:
Quoted 8 lines · On Fri, 24 Oct 2025 11:11:50 +0200 you wrote:
From: Sven Eckelmann <[email protected]>
Trying to dump the originators or the neighbors via netlink for a meshif with an inactive primary interface is not allowed. The dump functions were checking this correctly but they didn't handle non-existing primary interfaces and existing _inactive_ interfaces differently.
[...]
Here is the summary with links:
- [net,1/1] batman-adv: Release references to inactive interfaces
https://git.kernel.org/netdev/net/c/f12b69d8f228
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html