diff options
author | Fabricio Voznika <fvoznika@google.com> | 2021-05-03 13:47:45 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-05-03 13:50:37 -0700 |
commit | 1947c873423cabcaf5e67b667542421ade7414ff (patch) | |
tree | b54dd4f68aa20b95367594b8941fcca4cb766636 /pkg/sentry/fsimpl/proc | |
parent | 7cafac9f42a8355e7192b57fcc8d41e31d836c53 (diff) |
Fix deadlock in /proc/[pid]/fd/[num]
In order to resolve path names, fsSymlink.Readlink() may need to reenter
kernfs. Change the code so that kernfs.Inode.Readlink() is called without
locks and document the new contract.
PiperOrigin-RevId: 371770222
Diffstat (limited to 'pkg/sentry/fsimpl/proc')
-rw-r--r-- | pkg/sentry/fsimpl/proc/task_fds.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/pkg/sentry/fsimpl/proc/task_fds.go b/pkg/sentry/fsimpl/proc/task_fds.go index 02bf74dbc..4718fac7a 100644 --- a/pkg/sentry/fsimpl/proc/task_fds.go +++ b/pkg/sentry/fsimpl/proc/task_fds.go @@ -221,6 +221,8 @@ func (s *fdSymlink) Readlink(ctx context.Context, _ *vfs.Mount) (string, error) defer file.DecRef(ctx) root := vfs.RootFromContext(ctx) defer root.DecRef(ctx) + + // Note: it's safe to reenter kernfs from Readlink if needed to resolve path. return s.task.Kernel().VFS().PathnameWithDeleted(ctx, root, file.VirtualDentry()) } |