From 757e15ce22ab84bf4385a9d6c6e7cff8bc9c0651 Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Fri, 16 Sep 2022 13:13:06 -0700 Subject: [PATCH] Replace ESRCH error with panic in procfs Readlink methods. Use of RootFromContext(ctx) should always return a valid root in these cases. The comment about "racing with process deletion" and ESRCH return value was erroniously copy-pastad from the task.FSContext().RootDirectory() usage, where such a race is possible. PiperOrigin-RevId: 474885394 --- pkg/sentry/fsimpl/proc/task_files.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/sentry/fsimpl/proc/task_files.go b/pkg/sentry/fsimpl/proc/task_files.go index b94a37636..fff830f85 100644 --- a/pkg/sentry/fsimpl/proc/task_files.go +++ b/pkg/sentry/fsimpl/proc/task_files.go @@ -935,8 +935,7 @@ func (s *exeSymlink) Readlink(ctx context.Context, _ *vfs.Mount) (string, error) root := vfs.RootFromContext(ctx) if !root.Ok() { - // It could have raced with process deletion. - return "", linuxerr.ESRCH + panic("procfs Readlink requires context with root value") } defer s.fs.SafeDecRef(ctx, root) @@ -1008,8 +1007,7 @@ func (s *cwdSymlink) Readlink(ctx context.Context, _ *vfs.Mount) (string, error) root := vfs.RootFromContext(ctx) if !root.Ok() { - // It could have raced with process deletion. - return "", linuxerr.ESRCH + panic("procfs Readlink requires context with root value") } defer s.fs.SafeDecRef(ctx, root) @@ -1070,8 +1068,7 @@ func (s *rootSymlink) Readlink(ctx context.Context, _ *vfs.Mount) (string, error vfsRoot := vfs.RootFromContext(ctx) if !vfsRoot.Ok() { - // It could have raced with process deletion. - return "", linuxerr.ESRCH + panic("procfs Readlink requires context with root value") } defer s.fs.SafeDecRef(ctx, vfsRoot)