summaryrefslogtreecommitdiffhomepage
path: root/src/timers.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-25 14:49:32 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-25 14:49:32 +0200
commit18eebcca8234bcfd1176721e6adc5e63af675291 (patch)
treed2980d9ffa0ab66e94e4b5f7f6d910d97633f990 /src/timers.c
parenta79b6ac0060964f48ede730a23ad197125f565a3 (diff)
global: do not allow compiler to reorder is_valid or is_dead
Suggested-by: Jann Horn <jann@thejh.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/timers.c')
-rw-r--r--src/timers.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/timers.c b/src/timers.c
index 0312bd8..22eb1ee 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -39,7 +39,8 @@ static inline void mod_peer_timer(struct wg_peer *peer,
unsigned long expires)
{
rcu_read_lock_bh();
- if (likely(netif_running(peer->device->dev) && !peer->is_dead))
+ if (likely(netif_running(peer->device->dev) &&
+ !READ_ONCE(peer->is_dead)))
mod_timer(timer, expires);
rcu_read_unlock_bh();
}
@@ -48,7 +49,8 @@ static inline void del_peer_timer(struct wg_peer *peer,
struct timer_list *timer)
{
rcu_read_lock_bh();
- if (likely(netif_running(peer->device->dev) && !peer->is_dead))
+ if (likely(netif_running(peer->device->dev) &&
+ !READ_ONCE(peer->is_dead)))
del_timer(timer);
rcu_read_unlock_bh();
}
@@ -136,7 +138,7 @@ static void wg_expired_zero_key_material(struct timer_list *timer)
return;
rcu_read_lock_bh();
- if (!peer->is_dead) {
+ if (!READ_ONCE(peer->is_dead)) {
/* Should take our reference. */
if (!queue_work(peer->device->handshake_send_wq,
&peer->clear_peer_work))