diff options
author | Li Qiang <pangpei.lq@antfin.com> | 2019-04-09 14:56:04 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-04-09 14:57:05 -0700 |
commit | b3b140ea4f9e1b632463cbf83c97f58464eceeac (patch) | |
tree | 71dbeb07f58aba6b9494ad6e67765f75f2a294bd /pkg/sentry/syscalls | |
parent | 93b3c9b76c16104cbb5cc55b6f2339cb43c356b5 (diff) |
syscalls: sendfile: limit the count to MAX_RW_COUNT
From sendfile spec and also the linux kernel code, we should
limit the count arg to 'MAX_RW_COUNT'. This patch export
'MAX_RW_COUNT' in kernel pkg and use it in the implementation
of sendfile syscall.
Signed-off-by: Li Qiang <pangpei.lq@antfin.com>
Change-Id: I1086fec0685587116984555abd22b07ac233fbd2
PiperOrigin-RevId: 242745831
Diffstat (limited to 'pkg/sentry/syscalls')
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_file.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_file.go b/pkg/sentry/syscalls/linux/sys_file.go index 5a874d935..d2d351449 100644 --- a/pkg/sentry/syscalls/linux/sys_file.go +++ b/pkg/sentry/syscalls/linux/sys_file.go @@ -2002,6 +2002,10 @@ func Sendfile(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sysc return 0, nil, syserror.EINVAL } + if count > int64(kernel.MAX_RW_COUNT) { + count = int64(kernel.MAX_RW_COUNT) + } + // Get files. outFile := t.FDMap().GetFile(outFD) if outFile == nil { |