diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-09-15 12:12:28 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-09-15 12:12:28 -0700 |
commit | 84d48c0fddc35e82bf8760acd366509581513274 (patch) | |
tree | 458495d2bfa1ae965932c0a1f2531fc957f63d10 /pkg/sentry/fsimpl | |
parent | d3880b76cbeaa1cadc38388d5684e00172566376 (diff) | |
parent | 1adedad81c0ddc68526d616ad31daf2af0135f47 (diff) |
Merge pull request #3895 from btw616:fix/issue-3894
PiperOrigin-RevId: 331824411
Diffstat (limited to 'pkg/sentry/fsimpl')
-rw-r--r-- | pkg/sentry/fsimpl/proc/task_fds.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/pkg/sentry/fsimpl/proc/task_fds.go b/pkg/sentry/fsimpl/proc/task_fds.go index 3f0d78461..94ec2ff69 100644 --- a/pkg/sentry/fsimpl/proc/task_fds.go +++ b/pkg/sentry/fsimpl/proc/task_fds.go @@ -86,14 +86,19 @@ func (i *fdDir) IterDirents(ctx context.Context, cb vfs.IterDirentsCallback, off Name: strconv.FormatUint(uint64(fd), 10), Type: typ, Ino: i.fs.NextIno(), - NextOff: offset + 1, + NextOff: int64(fd) + 3, } if err := cb.Handle(dirent); err != nil { - return offset, err + // Getdents should iterate correctly despite mutation + // of fds, so we return the next fd to serialize plus + // 2 (which accounts for the "." and ".." tracked by + // kernfs) as the offset. + return int64(fd) + 2, err } - offset++ } - return offset, nil + // We serialized them all. Next offset should be higher than last + // serialized fd. + return int64(fds[len(fds)-1]) + 3, nil } // fdDirInode represents the inode for /proc/[pid]/fd directory. |