summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry/fs')
-rw-r--r--pkg/sentry/fs/tmpfs/inode_file.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/pkg/sentry/fs/tmpfs/inode_file.go b/pkg/sentry/fs/tmpfs/inode_file.go
index 66bc934ae..4e803c9ff 100644
--- a/pkg/sentry/fs/tmpfs/inode_file.go
+++ b/pkg/sentry/fs/tmpfs/inode_file.go
@@ -451,9 +451,12 @@ func (f *fileInodeOperations) Translate(ctx context.Context, required, optional
// Constrain translations to f.attr.Unstable.Size (rounded up) to prevent
// translation to pages that may be concurrently truncated.
pgend := fs.OffsetPageEnd(f.attr.Unstable.Size)
- var buserr error
+ var beyondEOF bool
if required.End > pgend {
- buserr = &memmap.BusError{io.EOF}
+ if required.Start >= pgend {
+ return nil, &memmap.BusError{io.EOF}
+ }
+ beyondEOF = true
required.End = pgend
}
if optional.End > pgend {
@@ -481,9 +484,12 @@ func (f *fileInodeOperations) Translate(ctx context.Context, required, optional
// Don't return the error returned by f.data.Fill if it occurred outside of
// required.
if translatedEnd < required.End && cerr != nil {
- return ts, cerr
+ return ts, &memmap.BusError{cerr}
+ }
+ if beyondEOF {
+ return ts, &memmap.BusError{io.EOF}
}
- return ts, buserr
+ return ts, nil
}
// InvalidateUnsavable implements memmap.Mappable.InvalidateUnsavable.