From ad256f0b739b835e8836f84571424cb4adc01b1e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 10 Mar 2020 17:52:50 -0700 Subject: 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 --- device/noise-protocol.go | 3 --- 1 file changed, 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 { -- cgit v1.2.3