diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-03-16 23:04:55 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-03-16 23:04:55 +0000 |
commit | a30f38f72f1966a36eb138f2b5a5b5295012b58a (patch) | |
tree | ca36c55facc6d8418fa53c6cdd5872d3bfd2d20a /pkg/sentry/syscalls | |
parent | c78fcdc8af5ba8864c3161941115f5196a21a166 (diff) | |
parent | 2a6c4369be8d0522a1f439aa02bce0eb21d42ea2 (diff) |
Merge release-20200219.0-184-g2a6c436 (automated)
Diffstat (limited to 'pkg/sentry/syscalls')
-rwxr-xr-x | pkg/sentry/syscalls/linux/vfs2/setstat.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/pkg/sentry/syscalls/linux/vfs2/setstat.go b/pkg/sentry/syscalls/linux/vfs2/setstat.go index 9250659ff..136453ccc 100755 --- a/pkg/sentry/syscalls/linux/vfs2/setstat.go +++ b/pkg/sentry/syscalls/linux/vfs2/setstat.go @@ -173,12 +173,13 @@ func Truncate(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sysc return 0, nil, err } - return 0, nil, setstatat(t, linux.AT_FDCWD, path, disallowEmptyPath, followFinalSymlink, &vfs.SetStatOptions{ + err = setstatat(t, linux.AT_FDCWD, path, disallowEmptyPath, followFinalSymlink, &vfs.SetStatOptions{ Stat: linux.Statx{ Mask: linux.STATX_SIZE, Size: uint64(length), }, }) + return 0, nil, handleSetSizeError(t, err) } // Ftruncate implements Linux syscall ftruncate(2). @@ -196,12 +197,13 @@ func Ftruncate(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sys } defer file.DecRef() - return 0, nil, file.SetStat(t, vfs.SetStatOptions{ + err := file.SetStat(t, vfs.SetStatOptions{ Stat: linux.Statx{ Mask: linux.STATX_SIZE, Size: uint64(length), }, }) + return 0, nil, handleSetSizeError(t, err) } // Utime implements Linux syscall utime(2). @@ -378,3 +380,12 @@ func setstatat(t *kernel.Task, dirfd int32, path fspath.Path, shouldAllowEmptyPa FollowFinalSymlink: bool(shouldFollowFinalSymlink), }, opts) } + +func handleSetSizeError(t *kernel.Task, err error) error { + if err == syserror.ErrExceedsFileSizeLimit { + // Convert error to EFBIG and send a SIGXFSZ per setrlimit(2). + t.SendSignal(kernel.SignalInfoNoInfo(linux.SIGXFSZ, t, t)) + return syserror.EFBIG + } + return err +} |