summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/fs')
-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 {