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
This commit is contained in:
Nicolas Lacasse
2022-09-16 13:15:53 -07:00
committed by gVisor bot
parent 8e0dc959b4
commit 757e15ce22
+3 -6
View File
@@ -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)