summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/proc/task.go
diff options
context:
space:
mode:
authorRahat Mahmood <rahat@google.com>2020-08-21 16:03:38 -0700
committerAndrei Vagin <avagin@gmail.com>2020-09-09 17:53:10 -0700
commit3810a62b3a2e6bb55c3d030e15ba09665f2f91b3 (patch)
treed170ef4a82e88e94143f89b7c5583dee840308f1 /pkg/sentry/fsimpl/proc/task.go
parentedf3d6c9e6730d246fd7f26925fbfec8823638d2 (diff)
Clarify seek behaviour for kernfs.GenericDirectoryFD.
- Remove comment about GenericDirectoryFD not being compatible with dynamic directories. It is currently being used to implement dynamic directories. - Try to handle SEEK_END better than setting the offset to infinity. SEEK_END is poorly defined for dynamic directories anyways, so at least try make it work correctly for the static entries. Updates #1193. PiperOrigin-RevId: 327890128
Diffstat (limited to 'pkg/sentry/fsimpl/proc/task.go')
-rw-r--r--pkg/sentry/fsimpl/proc/task.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/pkg/sentry/fsimpl/proc/task.go b/pkg/sentry/fsimpl/proc/task.go
index a5c7aa470..109b31b4c 100644
--- a/pkg/sentry/fsimpl/proc/task.go
+++ b/pkg/sentry/fsimpl/proc/task.go
@@ -105,7 +105,9 @@ func (i *taskInode) Valid(ctx context.Context) bool {
// Open implements kernfs.Inode.
func (i *taskInode) Open(ctx context.Context, rp *vfs.ResolvingPath, vfsd *vfs.Dentry, opts vfs.OpenOptions) (*vfs.FileDescription, error) {
- fd, err := kernfs.NewGenericDirectoryFD(rp.Mount(), vfsd, &i.OrderedChildren, &i.locks, &opts)
+ fd, err := kernfs.NewGenericDirectoryFD(rp.Mount(), vfsd, &i.OrderedChildren, &i.locks, &opts, kernfs.GenericDirectoryFDOptions{
+ SeekEnd: kernfs.SeekEndZero,
+ })
if err != nil {
return nil, err
}
@@ -142,7 +144,9 @@ func (fs *filesystem) newTaskOwnedDir(task *kernel.Task, ino uint64, perm linux.
dir := &kernfs.StaticDirectory{}
// Note: credentials are overridden by taskOwnedInode.
- dir.Init(task.Credentials(), linux.UNNAMED_MAJOR, fs.devMinor, ino, perm)
+ dir.Init(task.Credentials(), linux.UNNAMED_MAJOR, fs.devMinor, ino, perm, kernfs.GenericDirectoryFDOptions{
+ SeekEnd: kernfs.SeekEndZero,
+ })
inode := &taskOwnedInode{Inode: dir, owner: task}
d := &kernfs.Dentry{}