summaryrefslogtreecommitdiff
path: root/drivers/net/wireguard/selftest
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-09-09 13:58:15 +0200
committerDavid S. Miller <davem@davemloft.net>2020-09-09 11:31:38 -0700
commit2e2976a339573a3184cfd731c38778b8b3f312dc (patch)
treef0d8b0e96d64dcd62e043afa85abc54e5f91dc73 /drivers/net/wireguard/selftest
parent0c0c0bc821e551f0e37ebf47eabc651645f33c94 (diff)
downloadwireguard-linux-trimmed-2e2976a339573a3184cfd731c38778b8b3f312dc.tar.gz
wireguard-linux-trimmed-2e2976a339573a3184cfd731c38778b8b3f312dc.zip
wireguard: peerlookup: take lock before checking hash in replace operation
Eric's suggested fix for the previous commit's mentioned race condition was to simply take the table->lock in wg_index_hashtable_replace(). The table->lock of the hash table is supposed to protect the bucket heads, not the entires, but actually, since all the mutator functions are already taking it, it makes sense to take it too for the test to hlist_unhashed, as a defense in depth measure, so that it no longer races with deletions, regardless of what other locks are protecting individual entries. This is sensible from a performance perspective because, as Eric pointed out, the case of being unhashed is already the unlikely case, so this won't add common contention. And comparing instructions, this basically doesn't make much of a difference other than pushing and popping %r13, used by the new `bool ret`. More generally, I like the idea of locking consistency across table mutator functions, and this might let me rest slightly easier at night. Suggested-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/wireguard/20200908145911.4090480-1-edumazet@google.com/ Fixes: a8f1bc7bdea3 ("net: WireGuard secure network tunnel") Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireguard/selftest')
0 files changed, 0 insertions, 0 deletions