diff options
author | David Anderson <danderson@tailscale.com> | 2020-03-10 17:52:50 -0700 |
---|---|---|
committer | David Crawshaw <david@zentus.com> | 2020-04-03 11:35:28 +1100 |
commit | ad256f0b739b835e8836f84571424cb4adc01b1e (patch) | |
tree | f5b74a1bdfb9b89716bf5fa5dee84931e874ff9f /device/noise-protocol.go | |
parent | d54f0a61aa623548ad5a6fc3deccf4beca9a0c5a (diff) | |
download | wireguard-go-ad256f0b739b835e8836f84571424cb4adc01b1e.tar.gz 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>
Diffstat (limited to '')
-rw-r--r-- | device/noise-protocol.go | 3 |
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 { |