aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/allowedips.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-11-22 23:47:02 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-11-26 11:33:33 +0100
commitc686043b3a504208fb36ee935055c68ff210eac6 (patch)
tree90d80160f653f6f58958638c60bb65c30fd7d49f /src/allowedips.c
parentmessages: recalculate rekey max based on a one minute flood (diff)
downloadwireguard-linux-compat-c686043b3a504208fb36ee935055c68ff210eac6.tar.xz
wireguard-linux-compat-c686043b3a504208fb36ee935055c68ff210eac6.zip
allowedips: safely dereference rcu roots
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--src/allowedips.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/allowedips.c b/src/allowedips.c
index 610aab0..72667d5 100644
--- a/src/allowedips.c
+++ b/src/allowedips.c
@@ -299,14 +299,18 @@ void wg_allowedips_free(struct allowedips *table, struct mutex *lock)
RCU_INIT_POINTER(table->root4, NULL);
RCU_INIT_POINTER(table->root6, NULL);
if (rcu_access_pointer(old4)) {
- root_remove_peer_lists(old4);
- call_rcu(&rcu_dereference_protected(old4,
- lockdep_is_held(lock))->rcu, root_free_rcu);
+ struct allowedips_node *node = rcu_dereference_protected(old4,
+ lockdep_is_held(lock));
+
+ root_remove_peer_lists(node);
+ call_rcu(&node->rcu, root_free_rcu);
}
if (rcu_access_pointer(old6)) {
- root_remove_peer_lists(old6);
- call_rcu(&rcu_dereference_protected(old6,
- lockdep_is_held(lock))->rcu, root_free_rcu);
+ struct allowedips_node *node = rcu_dereference_protected(old6,
+ lockdep_is_held(lock));
+
+ root_remove_peer_lists(node);
+ call_rcu(&node->rcu, root_free_rcu);
}
}