1
0
mirror of https://git.zx2c4.com/wireguard-go synced 2024-11-15 01:05:15 +01:00

device: avoid deadlock when changing private key and removing self peers

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-01-27 15:53:21 +01:00
parent 8cc99631d0
commit ace50a0529

View File

@ -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()
}
}