diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-08-01 05:17:58 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-08-01 05:53:31 +0200 |
commit | 913e2d895e77e56ba4ba4b823d4ef99dd07cc64c (patch) | |
tree | cf680838f0d40596c6c1b0096b5e96aec713a28a /src/hashtables.c | |
parent | allowedips: avoid window of disappeared peer (diff) | |
download | wireguard-monolithic-historical-913e2d895e77e56ba4ba4b823d4ef99dd07cc64c.tar.xz wireguard-monolithic-historical-913e2d895e77e56ba4ba4b823d4ef99dd07cc64c.zip |
hashtables: document immediate zeroing semantics
Suggested-by: Jann Horn <jann@thejh.net>
Diffstat (limited to 'src/hashtables.c')
-rw-r--r-- | src/hashtables.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/hashtables.c b/src/hashtables.c index ab0f622..03b9e21 100644 --- a/src/hashtables.c +++ b/src/hashtables.c @@ -133,6 +133,12 @@ bool index_hashtable_replace(struct index_hashtable *table, struct index_hashtab spin_lock_bh(&table->lock); new->index = old->index; hlist_replace_rcu(&old->index_hash, &new->index_hash); + + /* Calling init here NULLs out index_hash, and in fact after this function returns, + * it's theoretically possible for this to get reinserted elsewhere. That means + * the RCU lookup below might either terminate early or jump between buckets, in which + * case the packet simply gets dropped, which isn't terrible. + */ INIT_HLIST_NODE(&old->index_hash); spin_unlock_bh(&table->lock); return true; |