Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: stable@vger.kernel.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [PATCH 5.15 08/25] batman-adv: tp_meter: add only finished tp_vars to lists
Date: Fri, 26 Jun 2026 18:10:47 +0200	[thread overview]
Message-ID: <20260626161105.124113-9-sven@narfation.org> (raw)
In-Reply-To: <20260626161105.124113-1-sven@narfation.org>

commit 15ccbf685222274f5add1387af58c2a41a95f81e upstream.

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>
---
 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 7385cd02abf9f..257f8d042d158 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-26 16:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 16:10 [PATCH 5.15 00/25] batman-adv: 7.2 merge window fixes backports Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 01/25] batman-adv: tp_meter: keep unacked list in ascending ordered Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 02/25] batman-adv: tp_meter: initialize dup_acks explicitly Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 03/25] batman-adv: tp_meter: initialize dec_cwnd explicitly Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 04/25] batman-adv: tp_meter: avoid window underflow Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 05/25] batman-adv: tp_meter: avoid divide-by-zero for dec_cwnd Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 06/25] batman-adv: tp_meter: fix fast recovery precondition Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 07/25] batman-adv: tp_meter: handle seqno wrap-around for fast recovery detection Sven Eckelmann
2026-06-26 16:10 ` Sven Eckelmann [this message]
2026-06-26 16:10 ` [PATCH 5.15 09/25] batman-adv: bla: annotate lasttime access with READ/WRITE_ONCE Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 10/25] batman-adv: prevent ELP transmission interval underflow Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 11/25] batman-adv: tp_meter: initialize last_recv_time during init Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 12/25] batman-adv: ensure bcast is writable before modifying TTL Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 13/25] batman-adv: fix (m|b)cast csum after decrementing TTL Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 14/25] batman-adv: frag: ensure fragment is writable before modifying TTL Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 15/25] batman-adv: frag: avoid underflow of TTL Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 16/25] batman-adv: v: prevent OGM aggregation on disabled hardif Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 17/25] batman-adv: tp_meter: restrict number of unacked list entries Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 18/25] batman-adv: tp_meter: annotate last_recv_time access with READ/WRITE_ONCE Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 19/25] batman-adv: tp_meter: prevent parallel modifications of last_recv Sven Eckelmann
2026-06-26 16:10 ` [PATCH 5.15 20/25] batman-adv: tp_meter: handle overlapping packets Sven Eckelmann
2026-06-26 16:11 ` [PATCH 5.15 21/25] batman-adv: tt: don't merge change entries with different VIDs Sven Eckelmann
2026-06-26 16:11 ` [PATCH 5.15 22/25] batman-adv: tt: track roam count per VID Sven Eckelmann
2026-06-26 16:11 ` [PATCH 5.15 23/25] batman-adv: dat: prevent false sharing between VLANs Sven Eckelmann
2026-06-26 16:11 ` [PATCH 5.15 24/25] batman-adv: tvlv: enforce 2-byte alignment Sven Eckelmann
2026-06-26 16:11 ` [PATCH 5.15 25/25] batman-adv: tvlv: avoid race of cifsnotfound handler state Sven Eckelmann
2026-06-28  3:33 ` [PATCH 5.15 00/25] batman-adv: 7.2 merge window fixes backports Sasha Levin

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=20260626161105.124113-9-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=stable@vger.kernel.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