From: Sven Eckelmann <sven@narfation.org>
To: stable@vger.kernel.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [PATCH 5.10 11/23] batman-adv: tp_meter: initialize last_recv_time during init
Date: Fri, 26 Jun 2026 18:09:40 +0200 [thread overview]
Message-ID: <20260626160952.123713-12-sven@narfation.org> (raw)
In-Reply-To: <20260626160952.123713-1-sven@narfation.org>
commit 811cb00fa8cdc3f0a7f6eefc000a6888367c8c8f upstream.
The last_recv_time is the most important indicator for a receiver session
to figure out whether a session timed out or not. But this information was
only initialized after the session was added to the tp_receiver_list and
after the timer was started.
In the worst case, the timer (function) could have tried to access this
information before the actual initialization was reached. Like rest of the
variables of the tp_meter receiver session, this field has to be filled out
before any other (parallel running) context has the chance to access it.
Cc: stable@kernel.org
Fixes: 33a3bb4a3345 ("batman-adv: throughput meter implementation")
[ Context ]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
net/batman-adv/tp_meter.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
index a015ff73812f5..ea5640242ddc2 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -1412,8 +1412,10 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv,
tp_vars = batadv_tp_list_find_session(bat_priv, icmp->orig,
icmp->session, BATADV_TP_RECEIVER);
- if (tp_vars)
+ if (tp_vars) {
+ tp_vars->last_recv_time = jiffies;
goto out_unlock;
+ }
if (!atomic_add_unless(&bat_priv->tp_num, 1, BATADV_TP_MAX_NUM)) {
batadv_dbg(BATADV_DBG_TP_METER, bat_priv,
@@ -1440,6 +1442,8 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv,
kref_get(&tp_vars->refcount);
timer_setup(&tp_vars->timer, batadv_tp_receiver_shutdown, 0);
+ tp_vars->last_recv_time = jiffies;
+
kref_get(&tp_vars->refcount);
hlist_add_head_rcu(&tp_vars->list, &bat_priv->tp_list);
@@ -1488,9 +1492,9 @@ static void batadv_tp_recv_msg(struct batadv_priv *bat_priv,
icmp->orig);
goto out;
}
- }
- tp_vars->last_recv_time = jiffies;
+ tp_vars->last_recv_time = jiffies;
+ }
/* if the packet is a duplicate, it may be the case that an ACK has been
* lost. Resend the ACK
--
2.47.3
next prev parent reply other threads:[~2026-06-26 16:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 16:09 [PATCH 5.10 00/23] batman-adv: 7.2 merge window fixes backports Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 01/23] batman-adv: tp_meter: keep unacked list in ascending ordered Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 02/23] batman-adv: tp_meter: initialize dup_acks explicitly Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 03/23] batman-adv: tp_meter: initialize dec_cwnd explicitly Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 04/23] batman-adv: tp_meter: avoid window underflow Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 05/23] batman-adv: tp_meter: avoid divide-by-zero for dec_cwnd Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 06/23] batman-adv: tp_meter: fix fast recovery precondition Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 07/23] batman-adv: tp_meter: handle seqno wrap-around for fast recovery detection Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 08/23] batman-adv: tp_meter: add only finished tp_vars to lists Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 09/23] batman-adv: bla: annotate lasttime access with READ/WRITE_ONCE Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 10/23] batman-adv: prevent ELP transmission interval underflow Sven Eckelmann
2026-06-27 11:26 ` Sasha Levin
2026-06-27 12:05 ` Sven Eckelmann
2026-06-26 16:09 ` Sven Eckelmann [this message]
2026-06-26 16:09 ` [PATCH 5.10 12/23] batman-adv: frag: ensure fragment is writable before modifying TTL Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 13/23] batman-adv: frag: avoid underflow of TTL Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 14/23] batman-adv: v: prevent OGM aggregation on disabled hardif Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 15/23] batman-adv: tp_meter: restrict number of unacked list entries Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 16/23] batman-adv: tp_meter: annotate last_recv_time access with READ/WRITE_ONCE Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 17/23] batman-adv: tp_meter: prevent parallel modifications of last_recv Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 18/23] batman-adv: tp_meter: handle overlapping packets Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 19/23] batman-adv: tt: don't merge change entries with different VIDs Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 20/23] batman-adv: tt: track roam count per VID Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 21/23] batman-adv: dat: prevent false sharing between VLANs Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 22/23] batman-adv: tvlv: enforce 2-byte alignment Sven Eckelmann
2026-06-26 16:09 ` [PATCH 5.10 23/23] batman-adv: tvlv: avoid race of cifsnotfound handler state Sven Eckelmann
2026-06-28 3:33 ` [PATCH 5.10 00/23] 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=20260626160952.123713-12-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