aboutsummaryrefslogtreecommitdiffstats
path: root/device/device.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-01-27 15:53:21 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-27 15:53:21 +0100
commitace50a0529bdd69f32f637ee84845bde45de07b6 (patch)
tree4ed51afd93d3c2a60267ee2fd97a517f7120ca44 /device/device.go
parentdevice: use linked list for per-peer allowed-ip traversal (diff)
downloadwireguard-go-ace50a0529bdd69f32f637ee84845bde45de07b6.tar.xz
wireguard-go-ace50a0529bdd69f32f637ee84845bde45de07b6.zip
device: avoid deadlock when changing private key and removing self peers
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/device.go')
-rw-r--r--device/device.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/device/device.go b/device/device.go
index 47c4944..e769a20 100644
--- a/device/device.go
+++ b/device/device.go
@@ -268,7 +268,9 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) error {
publicKey := sk.publicKey()
for key, peer := range device.peers.keyMap {
if peer.handshake.remoteStatic.Equals(publicKey) {
+ peer.handshake.mutex.RUnlock()
unsafeRemovePeer(device, peer, key)
+ peer.handshake.mutex.RLock()
}
}