summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-08-01 05:17:58 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-08-01 05:53:31 +0200
commit8918d2950dec300b35fa470afbf089d8f3f0a906 (patch)
tree8948e76087132aa9ca28cfb8c1d29174d4fdf638 /src
parentafd339581cc169de843b9fd609e8d3a6176c29d3 (diff)
hashtables: document immediate zeroing semantics
Suggested-by: Jann Horn <jann@thejh.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r--src/hashtables.c6
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;