Skip to content

Commit 1dafdd0

Browse files
ecsvgregkh
authored andcommitted
batman-adv: tp_meter: annotate last_recv_time access with READ/WRITE_ONCE
commit d67c728 upstream. The last_recv_time field for batadv_tp_receiver tracks the jiffies value of the most recent activity and is used to detect timeouts. These accesses are not consistently protected by a lock, so READ_ONCE/WRITE_ONCE must be used to prevent data races caused by compiler optimizations. Cc: stable@kernel.org Fixes: 33a3bb4 ("batman-adv: throughput meter implementation") Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2233787 commit 1dafdd0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

net/batman-adv/tp_meter.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ static void batadv_tp_receiver_shutdown(struct timer_list *t)
11831183
bat_priv = tp_vars->bat_priv;
11841184

11851185
/* if there is recent activity rearm the timer */
1186-
if (!batadv_has_timed_out(tp_vars->last_recv_time,
1186+
if (!batadv_has_timed_out(READ_ONCE(tp_vars->last_recv_time),
11871187
BATADV_TP_RECV_TIMEOUT)) {
11881188
/* reset the receiver shutdown timer */
11891189
batadv_tp_reset_receiver_timer(tp_vars);
@@ -1424,7 +1424,7 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv,
14241424
tp_vars = batadv_tp_list_find_session(bat_priv, icmp->orig,
14251425
icmp->session, BATADV_TP_RECEIVER);
14261426
if (tp_vars) {
1427-
tp_vars->last_recv_time = jiffies;
1427+
WRITE_ONCE(tp_vars->last_recv_time, jiffies);
14281428
goto out_unlock;
14291429
}
14301430

@@ -1455,7 +1455,7 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv,
14551455
kref_get(&tp_vars->refcount);
14561456
timer_setup(&tp_vars->timer, batadv_tp_receiver_shutdown, 0);
14571457

1458-
tp_vars->last_recv_time = jiffies;
1458+
WRITE_ONCE(tp_vars->last_recv_time, jiffies);
14591459

14601460
kref_get(&tp_vars->refcount);
14611461
hlist_add_head_rcu(&tp_vars->list, &bat_priv->tp_list);
@@ -1506,7 +1506,7 @@ static void batadv_tp_recv_msg(struct batadv_priv *bat_priv,
15061506
goto out;
15071507
}
15081508

1509-
tp_vars->last_recv_time = jiffies;
1509+
WRITE_ONCE(tp_vars->last_recv_time, jiffies);
15101510
}
15111511

15121512
/* if the packet is a duplicate, it may be the case that an ACK has been

0 commit comments

Comments
 (0)