From 028cf757bbefa0851bd1f01c8e2e8e000dea0f43 Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Sun, 19 Feb 2023 10:41:50 -0800 Subject: [PATCH] Clarify comment about copying Task.image in Task.Clone(). PiperOrigin-RevId: 510829046 --- pkg/sentry/kernel/task_clone.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/sentry/kernel/task_clone.go b/pkg/sentry/kernel/task_clone.go index 3fe8ff193..04049c8f9 100644 --- a/pkg/sentry/kernel/task_clone.go +++ b/pkg/sentry/kernel/task_clone.go @@ -136,8 +136,9 @@ func (t *Task) Clone(args *linux.CloneArgs) (ThreadID, *SyscallControl, error) { }) } - // We must hold t.mu to access t.image, but want to avoid holding the lock - // during Fork() call, so we make a copy. + // We must hold t.mu to access t.image, but we can't hold it during Fork(), + // since TaskImage.Fork()=>mm.Fork() takes mm.addressSpaceMu, which is ordered + // above Task.mu. So we copy t.image with t.mu held and call Fork() on the copy. t.mu.Lock() curImage := t.image t.mu.Unlock()