Skip to content

Commit 76c9339

Browse files
Merge pull request #1177 from ecsv/batadv-for-25.12
[25.12] batman-adv: merge bugfixes from 2026.2
2 parents 3d7d0dc + 0ab2353 commit 76c9339

68 files changed

Lines changed: 4805 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

batman-adv/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
44

55
PKG_NAME:=batman-adv
66
PKG_VERSION:=2025.4
7-
PKG_RELEASE:=4
7+
PKG_RELEASE:=5
88

99
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
1010
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From: Lyes Bourennani <lbourennani@fuzzinglabs.com>
2+
Date: Wed, 22 Apr 2026 00:20:22 +0200
3+
Subject: batman-adv: fix integer overflow on buff_pos
4+
5+
Fixing an integer overflow present in batadv_iv_ogm_send_to_if. The size
6+
check is done using the int type in batadv_iv_ogm_aggr_packet whereas the
7+
buff_pos variable uses the s16 type. This could lead to an out-of-bound
8+
read.
9+
10+
Fixes: b780db96954a ("add packet aggregation add jitter for rebroadcast of packets if aggregation is disabled")
11+
Signed-off-by: Lyes Bourennani <lbourennani@fuzzinglabs.com>
12+
Signed-off-by: Alexis Pinson <apinson@fuzzinglabs.com>
13+
Signed-off-by: Sven Eckelmann <sven@narfation.org>
14+
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/?id=bacf50d6dab4d833a27b9e2603e0c51d9916665e
15+
16+
--- a/net/batman-adv/bat_iv_ogm.c
17+
+++ b/net/batman-adv/bat_iv_ogm.c
18+
@@ -335,7 +335,7 @@ static void batadv_iv_ogm_send_to_if(str
19+
struct batadv_priv *bat_priv = netdev_priv(hard_iface->mesh_iface);
20+
const char *fwd_str;
21+
u8 packet_num;
22+
- s16 buff_pos;
23+
+ int buff_pos;
24+
struct batadv_ogm_packet *batadv_ogm_packet;
25+
struct sk_buff *skb;
26+
u8 *packet_pos;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
From: Jiexun Wang <wangjiexun2025@gmail.com>
2+
Date: Mon, 27 Apr 2026 14:43:33 +0800
3+
Subject: batman-adv: reject new tp_meter sessions during teardown
4+
5+
Prevent tp_meter from starting new sender or receiver sessions after
6+
mesh_state has left BATADV_MESH_ACTIVE.
7+
8+
Fixes: 98d7a766b645 ("batman-adv: throughput meter implementation")
9+
Reported-by: Yuan Tan <yuantan098@gmail.com>
10+
Reported-by: Yifan Wu <yifanwucs@gmail.com>
11+
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
12+
Reported-by: Xin Liu <bird@lzu.edu.cn>
13+
Co-developed-by: Luxing Yin <tr0jan@lzu.edu.cn>
14+
Signed-off-by: Luxing Yin <tr0jan@lzu.edu.cn>
15+
Signed-off-by: Jiexun Wang <wangjiexun2025@gmail.com>
16+
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
17+
Signed-off-by: Sven Eckelmann <sven@narfation.org>
18+
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/?id=856073145b4fc0dfa92dcc70adb1fd7b852484e8
19+
20+
--- a/net/batman-adv/tp_meter.c
21+
+++ b/net/batman-adv/tp_meter.c
22+
@@ -947,6 +947,13 @@ void batadv_tp_start(struct batadv_priv
23+
24+
/* look for an already existing test towards this node */
25+
spin_lock_bh(&bat_priv->tp_list_lock);
26+
+ if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) {
27+
+ spin_unlock_bh(&bat_priv->tp_list_lock);
28+
+ batadv_tp_batctl_error_notify(BATADV_TP_REASON_DST_UNREACHABLE,
29+
+ dst, bat_priv, session_cookie);
30+
+ return;
31+
+ }
32+
+
33+
tp_vars = batadv_tp_list_find(bat_priv, dst);
34+
if (tp_vars) {
35+
spin_unlock_bh(&bat_priv->tp_list_lock);
36+
@@ -1329,9 +1336,12 @@ static struct batadv_tp_vars *
37+
batadv_tp_init_recv(struct batadv_priv *bat_priv,
38+
const struct batadv_icmp_tp_packet *icmp)
39+
{
40+
- struct batadv_tp_vars *tp_vars;
41+
+ struct batadv_tp_vars *tp_vars = NULL;
42+
43+
spin_lock_bh(&bat_priv->tp_list_lock);
44+
+ if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
45+
+ goto out_unlock;
46+
+
47+
tp_vars = batadv_tp_list_find_session(bat_priv, icmp->orig,
48+
icmp->session);
49+
if (tp_vars)
50+
@@ -1464,6 +1474,9 @@ void batadv_tp_meter_recv(struct batadv_
51+
{
52+
struct batadv_icmp_tp_packet *icmp;
53+
54+
+ if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
55+
+ goto out;
56+
+
57+
icmp = (struct batadv_icmp_tp_packet *)skb->data;
58+
59+
switch (icmp->subtype) {
60+
@@ -1478,6 +1491,8 @@ void batadv_tp_meter_recv(struct batadv_
61+
"Received unknown TP Metric packet type %u\n",
62+
icmp->subtype);
63+
}
64+
+
65+
+out:
66+
consume_skb(skb);
67+
}
68+
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
From: Jiexun Wang <wangjiexun2025@gmail.com>
2+
Date: Mon, 27 Apr 2026 14:43:34 +0800
3+
Subject: batman-adv: stop tp_meter sessions during mesh teardown
4+
5+
TP meter sessions remain linked on bat_priv->tp_list after the netlink
6+
request has already finished. When the mesh interface is removed,
7+
batadv_mesh_free() currently tears down the mesh without first draining
8+
these sessions.
9+
10+
A running sender thread or a late incoming tp_meter packet can then keep
11+
processing against a mesh instance which is already shutting down.
12+
Synchronize tp_meter with the mesh lifetime by stopping all active
13+
sessions from batadv_mesh_free() and waiting for sender threads to exit
14+
before teardown continues.
15+
16+
Fixes: 98d7a766b645 ("batman-adv: throughput meter implementation")
17+
Reported-by: Yuan Tan <yuantan098@gmail.com>
18+
Reported-by: Yifan Wu <yifanwucs@gmail.com>
19+
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
20+
Reported-by: Xin Liu <bird@lzu.edu.cn>
21+
Co-developed-by: Luxing Yin <tr0jan@lzu.edu.cn>
22+
Signed-off-by: Luxing Yin <tr0jan@lzu.edu.cn>
23+
Signed-off-by: Jiexun Wang <wangjiexun2025@gmail.com>
24+
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
25+
Signed-off-by: Sven Eckelmann <sven@narfation.org>
26+
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/?id=13f49ae8972583ae9142b548a2789ade7dd1411f
27+
28+
--- a/compat-include/linux/timer.h
29+
+++ b/compat-include/linux/timer.h
30+
@@ -18,6 +18,11 @@
31+
#define timer_delete_sync(_timer) del_timer_sync(_timer)
32+
#define timer_delete(_timer) del_timer(_timer)
33+
34+
+static inline int timer_shutdown_sync(struct timer_list *timer)
35+
+{
36+
+ return del_timer_sync(timer);
37+
+}
38+
+
39+
#endif /* LINUX_VERSION_IS_LESS(6, 2, 0) */
40+
41+
#if LINUX_VERSION_IS_LESS(6, 16, 0)
42+
--- a/net/batman-adv/main.c
43+
+++ b/net/batman-adv/main.c
44+
@@ -249,6 +249,7 @@ void batadv_mesh_free(struct net_device
45+
atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
46+
47+
batadv_purge_outstanding_packets(bat_priv, NULL);
48+
+ batadv_tp_stop_all(bat_priv);
49+
50+
batadv_gw_node_free(bat_priv);
51+
52+
--- a/net/batman-adv/tp_meter.c
53+
+++ b/net/batman-adv/tp_meter.c
54+
@@ -365,23 +365,38 @@ static void batadv_tp_vars_put(struct ba
55+
}
56+
57+
/**
58+
- * batadv_tp_sender_cleanup() - cleanup sender data and drop and timer
59+
- * @bat_priv: the bat priv with all the mesh interface information
60+
- * @tp_vars: the private data of the current TP meter session to cleanup
61+
+ * batadv_tp_list_detach() - remove tp session from mesh session list once
62+
+ * @tp_vars: the private data of the current TP meter session
63+
*/
64+
-static void batadv_tp_sender_cleanup(struct batadv_priv *bat_priv,
65+
- struct batadv_tp_vars *tp_vars)
66+
+static void batadv_tp_list_detach(struct batadv_tp_vars *tp_vars)
67+
{
68+
- cancel_delayed_work(&tp_vars->finish_work);
69+
+ bool detached = false;
70+
71+
spin_lock_bh(&tp_vars->bat_priv->tp_list_lock);
72+
- hlist_del_rcu(&tp_vars->list);
73+
+ if (!hlist_unhashed(&tp_vars->list)) {
74+
+ hlist_del_init_rcu(&tp_vars->list);
75+
+ detached = true;
76+
+ }
77+
spin_unlock_bh(&tp_vars->bat_priv->tp_list_lock);
78+
79+
+ if (!detached)
80+
+ return;
81+
+
82+
+ atomic_dec(&tp_vars->bat_priv->tp_num);
83+
+
84+
/* drop list reference */
85+
batadv_tp_vars_put(tp_vars);
86+
+}
87+
88+
- atomic_dec(&tp_vars->bat_priv->tp_num);
89+
+/**
90+
+ * batadv_tp_sender_cleanup() - cleanup sender data and drop and timer
91+
+ * @tp_vars: the private data of the current TP meter session to cleanup
92+
+ */
93+
+static void batadv_tp_sender_cleanup(struct batadv_tp_vars *tp_vars)
94+
+{
95+
+ cancel_delayed_work_sync(&tp_vars->finish_work);
96+
+
97+
+ batadv_tp_list_detach(tp_vars);
98+
99+
/* kill the timer and remove its reference */
100+
timer_delete_sync(&tp_vars->timer);
101+
@@ -886,7 +901,8 @@ out:
102+
batadv_orig_node_put(orig_node);
103+
104+
batadv_tp_sender_end(bat_priv, tp_vars);
105+
- batadv_tp_sender_cleanup(bat_priv, tp_vars);
106+
+ batadv_tp_sender_cleanup(tp_vars);
107+
+ complete(&tp_vars->finished);
108+
109+
batadv_tp_vars_put(tp_vars);
110+
111+
@@ -918,7 +934,8 @@ static void batadv_tp_start_kthread(stru
112+
batadv_tp_vars_put(tp_vars);
113+
114+
/* cleanup of failed tp meter variables */
115+
- batadv_tp_sender_cleanup(bat_priv, tp_vars);
116+
+ batadv_tp_sender_cleanup(tp_vars);
117+
+ complete(&tp_vars->finished);
118+
return;
119+
}
120+
121+
@@ -1024,6 +1041,7 @@ void batadv_tp_start(struct batadv_priv
122+
tp_vars->start_time = jiffies;
123+
124+
init_waitqueue_head(&tp_vars->more_bytes);
125+
+ init_completion(&tp_vars->finished);
126+
127+
spin_lock_init(&tp_vars->unacked_lock);
128+
INIT_LIST_HEAD(&tp_vars->unacked_list);
129+
@@ -1126,14 +1144,7 @@ static void batadv_tp_receiver_shutdown(
130+
"Shutting down for inactivity (more than %dms) from %pM\n",
131+
BATADV_TP_RECV_TIMEOUT, tp_vars->other_end);
132+
133+
- spin_lock_bh(&tp_vars->bat_priv->tp_list_lock);
134+
- hlist_del_rcu(&tp_vars->list);
135+
- spin_unlock_bh(&tp_vars->bat_priv->tp_list_lock);
136+
-
137+
- /* drop list reference */
138+
- batadv_tp_vars_put(tp_vars);
139+
-
140+
- atomic_dec(&bat_priv->tp_num);
141+
+ batadv_tp_list_detach(tp_vars);
142+
143+
spin_lock_bh(&tp_vars->unacked_lock);
144+
list_for_each_entry_safe(un, safe, &tp_vars->unacked_list, list) {
145+
@@ -1497,6 +1508,52 @@ out:
146+
}
147+
148+
/**
149+
+ * batadv_tp_stop_all() - stop all currently running tp meter sessions
150+
+ * @bat_priv: the bat priv with all the mesh interface information
151+
+ */
152+
+void batadv_tp_stop_all(struct batadv_priv *bat_priv)
153+
+{
154+
+ struct batadv_tp_vars *tp_vars[BATADV_TP_MAX_NUM];
155+
+ struct batadv_tp_vars *tp_var;
156+
+ size_t count = 0;
157+
+ size_t i;
158+
+
159+
+ spin_lock_bh(&bat_priv->tp_list_lock);
160+
+ hlist_for_each_entry(tp_var, &bat_priv->tp_list, list) {
161+
+ if (WARN_ON_ONCE(count >= BATADV_TP_MAX_NUM))
162+
+ break;
163+
+
164+
+ if (!kref_get_unless_zero(&tp_var->refcount))
165+
+ continue;
166+
+
167+
+ tp_vars[count++] = tp_var;
168+
+ }
169+
+ spin_unlock_bh(&bat_priv->tp_list_lock);
170+
+
171+
+ for (i = 0; i < count; i++) {
172+
+ tp_var = tp_vars[i];
173+
+
174+
+ switch (tp_var->role) {
175+
+ case BATADV_TP_SENDER:
176+
+ batadv_tp_sender_shutdown(tp_var,
177+
+ BATADV_TP_REASON_CANCEL);
178+
+ wake_up(&tp_var->more_bytes);
179+
+ wait_for_completion(&tp_var->finished);
180+
+ break;
181+
+ case BATADV_TP_RECEIVER:
182+
+ batadv_tp_list_detach(tp_var);
183+
+ if (timer_shutdown_sync(&tp_var->timer))
184+
+ batadv_tp_vars_put(tp_var);
185+
+ break;
186+
+ }
187+
+
188+
+ batadv_tp_vars_put(tp_var);
189+
+ }
190+
+
191+
+ synchronize_net();
192+
+}
193+
+
194+
+/**
195+
* batadv_tp_meter_init() - initialize global tp_meter structures
196+
*/
197+
void __init batadv_tp_meter_init(void)
198+
--- a/net/batman-adv/tp_meter.h
199+
+++ b/net/batman-adv/tp_meter.h
200+
@@ -17,6 +17,7 @@ void batadv_tp_start(struct batadv_priv
201+
u32 test_length, u32 *cookie);
202+
void batadv_tp_stop(struct batadv_priv *bat_priv, const u8 *dst,
203+
u8 return_value);
204+
+void batadv_tp_stop_all(struct batadv_priv *bat_priv);
205+
void batadv_tp_meter_recv(struct batadv_priv *bat_priv, struct sk_buff *skb);
206+
207+
#endif /* _NET_BATMAN_ADV_TP_METER_H_ */
208+
--- a/net/batman-adv/types.h
209+
+++ b/net/batman-adv/types.h
210+
@@ -14,6 +14,7 @@
211+
#include <linux/average.h>
212+
#include <linux/bitops.h>
213+
#include <linux/compiler.h>
214+
+#include <linux/completion.h>
215+
#include <linux/if.h>
216+
#include <linux/if_ether.h>
217+
#include <linux/kref.h>
218+
@@ -1328,6 +1329,9 @@ struct batadv_tp_vars {
219+
/** @finish_work: work item for the finishing procedure */
220+
struct delayed_work finish_work;
221+
222+
+ /** @finished: completion signaled when a sender thread exits */
223+
+ struct completion finished;
224+
+
225+
/** @test_length: test length in milliseconds */
226+
u32 test_length;
227+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
From: Sven Eckelmann <sven@narfation.org>
2+
Date: Sat, 2 May 2026 22:00:20 +0200
3+
Subject: batman-adv: tp_meter: add missing completion header
4+
5+
Fixes: 13f49ae89725 ("batman-adv: stop tp_meter sessions during mesh teardown")
6+
Signed-off-by: Sven Eckelmann <sven@narfation.org>
7+
Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/?id=f77931495fadb1b5a1d8f0c863153f9db7e01207
8+
9+
--- a/net/batman-adv/tp_meter.c
10+
+++ b/net/batman-adv/tp_meter.c
11+
@@ -12,6 +12,7 @@
12+
#include <linux/byteorder/generic.h>
13+
#include <linux/cache.h>
14+
#include <linux/compiler.h>
15+
+#include <linux/completion.h>
16+
#include <linux/container_of.h>
17+
#include <linux/err.h>
18+
#include <linux/etherdevice.h>

0 commit comments

Comments
 (0)