summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/task_exec.go
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2021-08-27 13:09:28 -0700
committergVisor bot <gvisor-bot@google.com>2021-08-27 13:18:49 -0700
commitf7281c6cb9bbf3e5757adf52a7820499b5a7483b (patch)
tree58bcf863ec15020cadfc87fd6157ac9b057b1a9a /pkg/sentry/kernel/task_exec.go
parent0db19ea910def9848d0f53f65f993270ed579a8f (diff)
Fix lock order violations: mm.mappingMu > Task.mu.
Document this ordering in mm/mm.go. PiperOrigin-RevId: 393413203
Diffstat (limited to 'pkg/sentry/kernel/task_exec.go')
-rw-r--r--pkg/sentry/kernel/task_exec.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/sentry/kernel/task_exec.go b/pkg/sentry/kernel/task_exec.go
index 9175b911c..db91fc4d8 100644
--- a/pkg/sentry/kernel/task_exec.go
+++ b/pkg/sentry/kernel/task_exec.go
@@ -222,9 +222,15 @@ func (r *runSyscallAfterExecStop) execute(t *Task) taskRunState {
// Update credentials to reflect the execve. This should precede switching
// MMs to ensure that dumpability has been reset first, if needed.
t.updateCredsForExecLocked()
- t.image.release()
+ oldImage := t.image
t.image = *r.image
t.mu.Unlock()
+
+ // Don't hold t.mu while calling t.image.release(), that may
+ // attempt to acquire TaskImage.MemoryManager.mappingMu, a lock order
+ // violation.
+ oldImage.release()
+
t.unstopVforkParent()
t.p.FullStateChanged()
// NOTE(b/30316266): All locks must be dropped prior to calling Activate.