Netdev List
 help / color / mirror / Atom feed
From: Simon Wunderlich <sw@simonwunderlich.de>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	b.a.t.m.a.n@lists.open-mesh.org,
	Sven Eckelmann <sven@narfation.org>,
	stable@kernel.org, Simon Wunderlich <sw@simonwunderlich.de>
Subject: [PATCH net-next 08/15] batman-adv: tp_meter: add only finished tp_vars to lists
Date: Wed,  3 Jun 2026 09:25:19 +0200	[thread overview]
Message-ID: <20260603072527.174487-9-sw@simonwunderlich.de> (raw)
In-Reply-To: <20260603072527.174487-1-sw@simonwunderlich.de>

From: Sven Eckelmann <sven@narfation.org>

When the receiver variables (aka "session") are initialized, then they are
added to the list of sessions before the timer is set up. A RCU protected
reader could therefore find the entry and run mod_setup before
batadv_tp_init_recv() finished the timer initialization.

The same is true for batadv_tp_start(), which must first initialize the
finish_work and the test_length to avoid a similar problem.

Cc: stable@kernel.org
Fixes: 33a3bb4a3345 ("batman-adv: throughput meter implementation")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 net/batman-adv/tp_meter.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
index 3d3d06c88e1c9..5498cdc972e98 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -1096,21 +1096,21 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,
 	tp_vars->prerandom_offset = 0;
 	spin_lock_init(&tp_vars->prerandom_lock);
 
-	kref_get(&tp_vars->refcount);
-	hlist_add_head_rcu(&tp_vars->list, &bat_priv->tp_list);
-	spin_unlock_bh(&bat_priv->tp_list_lock);
-
 	tp_vars->test_length = test_length;
 	if (!tp_vars->test_length)
 		tp_vars->test_length = BATADV_TP_DEF_TEST_LENGTH;
 
+	/* init work item for finished tp tests */
+	INIT_DELAYED_WORK(&tp_vars->finish_work, batadv_tp_sender_finish);
+
+	kref_get(&tp_vars->refcount);
+	hlist_add_head_rcu(&tp_vars->list, &bat_priv->tp_list);
+	spin_unlock_bh(&bat_priv->tp_list_lock);
+
 	batadv_dbg(BATADV_DBG_TP_METER, bat_priv,
 		   "Meter: starting throughput meter towards %pM (length=%ums)\n",
 		   dst, test_length);
 
-	/* init work item for finished tp tests */
-	INIT_DELAYED_WORK(&tp_vars->finish_work, batadv_tp_sender_finish);
-
 	/* start tp kthread. This way the write() call issued from userspace can
 	 * happily return and avoid to block
 	 */
@@ -1430,10 +1430,10 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv,
 	INIT_LIST_HEAD(&tp_vars->unacked_list);
 
 	kref_get(&tp_vars->refcount);
-	hlist_add_head_rcu(&tp_vars->list, &bat_priv->tp_list);
+	timer_setup(&tp_vars->timer, batadv_tp_receiver_shutdown, 0);
 
 	kref_get(&tp_vars->refcount);
-	timer_setup(&tp_vars->timer, batadv_tp_receiver_shutdown, 0);
+	hlist_add_head_rcu(&tp_vars->list, &bat_priv->tp_list);
 
 	batadv_tp_reset_receiver_timer(tp_vars);
 
-- 
2.47.3


  parent reply	other threads:[~2026-06-03  7:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03  7:25 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-06-03 Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 01/15] batman-adv: tp_meter: keep unacked list in ascending ordered Simon Wunderlich
2026-06-05  2:20   ` patchwork-bot+netdevbpf
2026-06-03  7:25 ` [PATCH net-next 02/15] batman-adv: tp_meter: initialize dup_acks explicitly Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 03/15] batman-adv: tp_meter: initialize dec_cwnd explicitly Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 04/15] batman-adv: tp_meter: avoid window underflow Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 05/15] batman-adv: tp_meter: avoid divide-by-zero for dec_cwnd Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 06/15] batman-adv: tp_meter: fix fast recovery precondition Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 07/15] batman-adv: tp_meter: handle seqno wrap-around for fast recovery detection Simon Wunderlich
2026-06-03  7:25 ` Simon Wunderlich [this message]
2026-06-03  7:25 ` [PATCH net-next 09/15] batman-adv: tp_meter: split vars into sender and receiver types Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 10/15] batman-adv: tp_meter: use locking for all congestion control variables Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 11/15] batman-adv: tp_meter: consolidate " Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 12/15] batman-adv: bla: annotate lasttime access with READ/WRITE_ONCE Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 13/15] batman-adv: prevent ELP transmission interval underflow Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 14/15] batman-adv: tt: sync local and global tvlv preparation return values Simon Wunderlich
2026-06-03  7:25 ` [PATCH net-next 15/15] batman-adv: tt: directly retrieve wifi flags of net_device Simon Wunderlich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260603072527.174487-9-sw@simonwunderlich.de \
    --to=sw@simonwunderlich.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@kernel.org \
    --cc=sven@narfation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox