diff options
author | Nicolas Lacasse <nlacasse@google.com> | 2018-07-13 13:45:13 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-07-13 13:46:14 -0700 |
commit | 9059983fdb2cf64a08152d2aab648b6660b9631b (patch) | |
tree | 99cc341f67e4baf6fa0496bb1f4638789c169c89 | |
parent | 6dce46d4c0c1795e8a00319a0e87f5f63260080b (diff) |
runsc: Fix map access race in boot.Loader.waitContainer.
PiperOrigin-RevId: 204522004
Change-Id: I4819dc025f0a1df03ceaaba7951b1902d44562b3
-rw-r--r-- | runsc/boot/loader.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go index 7de0a84cc..706910d8a 100644 --- a/runsc/boot/loader.go +++ b/runsc/boot/loader.go @@ -499,10 +499,12 @@ func (l *Loader) waitContainer(cid string, waitStatus *uint32) error { // multiple clients to wait on the same container. l.mu.Lock() tgid, ok := l.containerRootTGIDs[cid] - l.mu.Unlock() if !ok { + defer l.mu.Unlock() return fmt.Errorf("can't find process for container %q in %v", cid, l.containerRootTGIDs) } + l.mu.Unlock() + // If the thread either has already exited or exits during waiting, // consider the container exited. defer func() { |