diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-05-02 01:30:23 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-05-02 01:56:48 -0600 |
commit | 28c4d043048e8bb7167e96df6558a6366306fc17 (patch) | |
tree | c98e39cd6ed75e23f54e6d1b72b6f5c70fa9ab8a /device/peer.go | |
parent | wintun: make remaining HWID comparisons case insensitive (diff) | |
download | wireguard-go-28c4d043048e8bb7167e96df6558a6366306fc17.tar.xz wireguard-go-28c4d043048e8bb7167e96df6558a6366306fc17.zip |
device: use atomic access for unlocked keypair.next
Go's GC semantics might not always guarantee the safety of this, and the
race detector gets upset too, so instead we wrap this all in atomic
accessors.
Reported-by: David Anderson <danderson@tailscale.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/peer.go')
-rw-r--r-- | device/peer.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/device/peer.go b/device/peer.go index 79d4981..899591b 100644 --- a/device/peer.go +++ b/device/peer.go @@ -223,10 +223,10 @@ func (peer *Peer) ZeroAndFlushAll() { keypairs.Lock() device.DeleteKeypair(keypairs.previous) device.DeleteKeypair(keypairs.current) - device.DeleteKeypair(keypairs.next) + device.DeleteKeypair(keypairs.loadNext()) keypairs.previous = nil keypairs.current = nil - keypairs.next = nil + keypairs.storeNext(nil) keypairs.Unlock() // clear handshake state @@ -254,7 +254,7 @@ func (peer *Peer) ExpireCurrentKeypairs() { keypairs.current.sendNonce = RejectAfterMessages } if keypairs.next != nil { - keypairs.next.sendNonce = RejectAfterMessages + keypairs.loadNext().sendNonce = RejectAfterMessages } keypairs.Unlock() } |