From: David Anderson Date: Wed, 11 Mar 2020 00:52:50 +0000 (-0700) Subject: device: remove racey read in session key rotation. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad256f0b739b835e8836f84571424cb4adc01b1e;p=thirdparty%2Fwireguard-go.git 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 --- 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 {