mirror of
https://github.com/amnezia-vpn/amneziawg-go.git
synced 2026-10-14 22:34:18 +03:00
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>
This commit is contained in:
1 parent
fdba6c183a
commit
28c4d04304
4 files changed
+23
-11
No files matched your search
+3
-3
@@ -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()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user