aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Anderson <danderson@tailscale.com>2020-03-10 17:52:50 -0700
committerDavid Crawshaw <david@zentus.com>2020-04-03 11:35:28 +1100
commitad256f0b739b835e8836f84571424cb4adc01b1e (patch)
treef5b74a1bdfb9b89716bf5fa5dee84931e874ff9f
parentdevice: add debug logs describing handshake rejection (diff)
downloadwireguard-go-ad256f0b739b835e8836f84571424cb4adc01b1e.tar.xz
wireguard-go-ad256f0b739b835e8836f84571424cb4adc01b1e.zip
device: remove racey read in session key rotation.
This code was attempting to use the "compare racily, then lock and compare again" idiom to try and reduce lock contention. However, that idiom is not safe to use unless the comparison uses atomic operations, which this does not. This change simply deletes the racy read. This makes the code correct, but potentially increases lock contention. Signed-off-by: David Anderson <danderson@tailscale.com>
-rw-r--r--device/noise-protocol.go3
1 files changed, 0 insertions, 3 deletions
diff --git a/device/noise-protocol.go b/device/noise-protocol.go
index dbb6f93..3ce7839 100644
--- a/device/noise-protocol.go
+++ b/device/noise-protocol.go
@@ -609,9 +609,6 @@ func (peer *Peer) BeginSymmetricSession() error {
func (peer *Peer) ReceivedWithKeypair(receivedKeypair *Keypair) bool {
keypairs := &peer.keypairs
- if keypairs.next != receivedKeypair {
- return false
- }
keypairs.Lock()
defer keypairs.Unlock()
if keypairs.next != receivedKeypair {