]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: wait for and lock ipc operations during close
authorJames Tucker <jftucker@gmail.com>
Fri, 5 May 2023 23:11:38 +0000 (16:11 -0700)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 27 Jun 2023 15:43:35 +0000 (17:43 +0200)
If an IPC operation is in flight while close starts, it is possible for
both processes to deadlock. Prevent this by taking the IPC lock at the
start of close and for the duration.

Signed-off-by: James Tucker <jftucker@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
device/device.go

index 091c8d40a9b243437a3c3f3134686c38e2485684..1af9fe01770048114cc2260a5761663709d6df47 100644 (file)
@@ -368,6 +368,8 @@ func (device *Device) RemoveAllPeers() {
 }
 
 func (device *Device) Close() {
+       device.ipcMutex.Lock()
+       defer device.ipcMutex.Unlock()
        device.state.Lock()
        defer device.state.Unlock()
        if device.isClosed() {