diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-08-07 19:59:27 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-08-07 19:59:27 +0000 |
commit | 90071d4e7f86f9c452969ebc38a3a64c27e37bf0 (patch) | |
tree | 8cd860d3bb992e9e5e93fc72ddba232b55b7f8ac /pkg/sentry/vfs | |
parent | b70f9919d048a7ff29740fa652bf890660922543 (diff) | |
parent | 93cb66825bf098f8a19b3d7f34b33272ceed8cb3 (diff) |
Merge release-20200804.0-39-g93cb66825 (automated)
Diffstat (limited to 'pkg/sentry/vfs')
-rw-r--r-- | pkg/sentry/vfs/file_description.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/sentry/vfs/file_description.go b/pkg/sentry/vfs/file_description.go index 576ab3920..d3c1197e3 100644 --- a/pkg/sentry/vfs/file_description.go +++ b/pkg/sentry/vfs/file_description.go @@ -356,6 +356,8 @@ type FileDescriptionImpl interface { // Allocate grows the file to offset + length bytes. // Only mode == 0 is supported currently. + // + // Preconditions: The FileDescription was opened for writing. Allocate(ctx context.Context, mode, offset, length uint64) error // waiter.Waitable methods may be used to poll for I/O events. @@ -565,6 +567,9 @@ func (fd *FileDescription) StatFS(ctx context.Context) (linux.Statfs, error) { // Allocate grows file represented by FileDescription to offset + length bytes. func (fd *FileDescription) Allocate(ctx context.Context, mode, offset, length uint64) error { + if !fd.IsWritable() { + return syserror.EBADF + } return fd.impl.Allocate(ctx, mode, offset, length) } |