From f93bd2cbe66817c300114630bb52702466e52129 Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Thu, 28 Jun 2018 16:10:17 -0700 Subject: Hold t.mu while calling t.FSContext(). PiperOrigin-RevId: 202562686 Change-Id: I0f5be7cc9098e86fa31d016251c127cb91084b05 --- pkg/sentry/fs/proc/mounts.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'pkg/sentry/fs/proc/mounts.go') diff --git a/pkg/sentry/fs/proc/mounts.go b/pkg/sentry/fs/proc/mounts.go index b9988625e..108432f4e 100644 --- a/pkg/sentry/fs/proc/mounts.go +++ b/pkg/sentry/fs/proc/mounts.go @@ -28,9 +28,22 @@ import ( // forEachMountSource runs f for the process root mount and each mount that is a // descendant of the root. func forEachMountSource(t *kernel.Task, fn func(string, *fs.MountSource)) { + var fsctx *kernel.FSContext + t.WithMuLocked(func(t *kernel.Task) { + fsctx = t.FSContext() + }) + if fsctx == nil { + // The task has been destroyed. Nothing to show here. + return + } + // All mount points must be relative to the rootDir, and mounts outside // will be excluded. - rootDir := t.FSContext().RootDirectory() + rootDir := fsctx.RootDirectory() + if rootDir == nil { + // The task has been destroyed. Nothing to show here. + return + } defer rootDir.DecRef() if rootDir.Inode == nil { -- cgit v1.2.3