summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/proc
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2018-06-28 16:10:17 -0700
committerShentubot <shentubot@google.com>2018-06-28 16:11:19 -0700
commitf93bd2cbe66817c300114630bb52702466e52129 (patch)
tree31dcae4c3ea588c30468457adf1a144ee61862e9 /pkg/sentry/fs/proc
parent16d37973ebc8f36ef613c0885879648cceaf1c45 (diff)
Hold t.mu while calling t.FSContext().
PiperOrigin-RevId: 202562686 Change-Id: I0f5be7cc9098e86fa31d016251c127cb91084b05
Diffstat (limited to 'pkg/sentry/fs/proc')
-rw-r--r--pkg/sentry/fs/proc/mounts.go15
1 files changed, 14 insertions, 1 deletions
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 {