]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: avoid deadlock when changing private key and removing self peers
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 27 Jan 2021 14:53:21 +0000 (15:53 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 27 Jan 2021 14:53:21 +0000 (15:53 +0100)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
device/device.go

index 47c49446b81d141a7bcf17842c7bbabc01307761..e769a2042f2f7bd57904067f0f866b642abd2c52 100644 (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()
                }
        }