summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/platform/kvm
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2019-07-22 13:27:13 -0700
committergVisor bot <gvisor-bot@google.com>2019-07-22 13:28:16 -0700
commitec906e46c0f99ab4d134c1d7bd84b48ea0a78488 (patch)
tree87566b60696581390e2064994c9ef72668d162a0 /pkg/sentry/platform/kvm
parenta0a86bbb8250311211161337c0f9530b945450a3 (diff)
kvm: fix race between machine.Put and machine.Get
m.available.Signal() has to be called under m.mu.RLock, otherwise it can race with machine.Get: m.Get | m.Put ------------------------------------- m.mu.Lock() | Seatching available vcpu| | m.available.Signal() m.available.Wait | PiperOrigin-RevId: 259394051
Diffstat (limited to 'pkg/sentry/platform/kvm')
-rw-r--r--pkg/sentry/platform/kvm/machine.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/sentry/platform/kvm/machine.go b/pkg/sentry/platform/kvm/machine.go
index 679087e25..cc6c138b2 100644
--- a/pkg/sentry/platform/kvm/machine.go
+++ b/pkg/sentry/platform/kvm/machine.go
@@ -388,7 +388,10 @@ func (m *machine) Get() *vCPU {
func (m *machine) Put(c *vCPU) {
c.unlock()
runtime.UnlockOSThread()
+
+ m.mu.RLock()
m.available.Signal()
+ m.mu.RUnlock()
}
// newDirtySet returns a new dirty set.