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 01/11] batman-adv: tp_meter: initialize last_recv_time during init
Date: Fri, 5 Jun 2026 09:19:55 +0200 [thread overview]
Message-ID: <20260605072005.490368-2-sw@simonwunderlich.de> (raw)
In-Reply-To: <20260605072005.490368-1-sw@simonwunderlich.de>
From: Sven Eckelmann <sven@narfation.org>
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")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
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 978e32d94e6c3..cc72468ca2abe 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -1511,8 +1511,10 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv,
tp_vars = batadv_tp_list_find_receiver_session(bat_priv, icmp->orig,
icmp->session);
- 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,
@@ -1539,6 +1541,8 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv,
kref_get(&tp_vars->common.refcount);
timer_setup(&tp_vars->common.timer, batadv_tp_receiver_shutdown, 0);
+ tp_vars->last_recv_time = jiffies;
+
kref_get(&tp_vars->common.refcount);
hlist_add_head_rcu(&tp_vars->common.list, &bat_priv->tp_receiver_list);
@@ -1587,9 +1591,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-05 7:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 7:19 [PATCH net-next 00/11] pull request for net-next: batman-adv 2026-06-05 Simon Wunderlich
2026-06-05 7:19 ` Simon Wunderlich [this message]
2026-06-05 7:19 ` [PATCH net-next 02/11] batman-adv: convert cancellation of work items to disable helper Simon Wunderlich
2026-06-05 7:19 ` [PATCH net-next 03/11] batman-adv: drop duplicated wifi_flags assignments Simon Wunderlich
2026-06-05 7:19 ` [PATCH net-next 04/11] batman-adv: use GFP_KERNEL allocations for the wifi detection cache Simon Wunderlich
2026-06-05 7:19 ` [PATCH net-next 05/11] batman-adv: document cleanup of batadv_wifi_net_devices entries Simon Wunderlich
2026-06-05 7:20 ` [PATCH net-next 06/11] batman-adv: correct batadv_wifi_* kernel-doc Simon Wunderlich
2026-06-05 7:20 ` [PATCH net-next 07/11] batman-adv: tp_meter: update stale kernel-doc after refactoring Simon Wunderlich
2026-06-05 7:20 ` [PATCH net-next 08/11] batman-adv: bla: update stale kernel-doc Simon Wunderlich
2026-06-05 7:20 ` [PATCH net-next 09/11] batman-adv: uapi: keep kernel-doc in struct member order Simon Wunderlich
2026-06-05 7:20 ` [PATCH net-next 10/11] batman-adv: fix batadv_v_ogm_packet_recv error handling kernel-doc Simon Wunderlich
2026-06-05 7:20 ` [PATCH net-next 11/11] batman-adv: fix kernel-doc typos and grammar errors 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=20260605072005.490368-2-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