]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: serialize access to IpcSetOperation
authorJosh Bleecher Snyder <josh@tailscale.com>
Mon, 25 Jan 2021 17:35:35 +0000 (09:35 -0800)
committerJosh Bleecher Snyder <josh@tailscale.com>
Mon, 25 Jan 2021 17:38:09 +0000 (09:38 -0800)
Interleaves IpcSetOperations would spell trouble.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
device/device.go
device/uapi.go

index 58e996f9501967eab61be4e2118f7221d1101a55..5d11766601e60662321fd6c0012ede31ab2fc735 100644 (file)
@@ -23,6 +23,7 @@ type Device struct {
        isUp     AtomicBool // device is (going) up
        isClosed AtomicBool // device is closed? (acting as guard)
        log      *Logger
+       ipcSetMu sync.Mutex // serializes UAPI set operations
 
        // synchronized resources (locks acquired in order)
 
index bf3845921b444b42abef6dcbb19f256f46a1d56b..c1ddb3857509b46cc1aceaeae2c22f4b2322028e 100644 (file)
@@ -121,6 +121,9 @@ func (device *Device) IpcGetOperation(w io.Writer) error {
 // IpcSetOperation implements the WireGuard configuration protocol "set" operation.
 // See https://www.wireguard.com/xplatform/#configuration-protocol for details.
 func (device *Device) IpcSetOperation(r io.Reader) (err error) {
+       device.ipcSetMu.Lock()
+       defer device.ipcSetMu.Unlock()
+
        defer func() {
                if err != nil {
                        device.log.Error.Println(err)