aboutsummaryrefslogtreecommitdiffstats
path: root/device/device.go
diff options
context:
space:
mode:
authorJames Tucker <jftucker@gmail.com>2023-05-05 16:11:38 -0700
committerJason A. Donenfeld <Jason@zx2c4.com>2023-06-27 17:43:35 +0200
commitb7cd547315bed421a648d0a0f1ee5a0fc1b1151e (patch)
tree1fb25dfb160f065b54a036de6e8e111271571992 /device/device.go
parenttun: use correct IP header comparisons in tcpGRO() and tcpPacketsCanCoalesce() (diff)
downloadwireguard-go-b7cd547315bed421a648d0a0f1ee5a0fc1b1151e.tar.xz
wireguard-go-b7cd547315bed421a648d0a0f1ee5a0fc1b1151e.zip
device: wait for and lock ipc operations during close
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>
Diffstat (limited to '')
-rw-r--r--device/device.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/device/device.go b/device/device.go
index 091c8d4..1af9fe0 100644
--- a/device/device.go
+++ b/device/device.go
@@ -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() {