From b660830fe8d5da03363e6d02e6e91076696964a8 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 3 Dec 2021 15:57:28 -0800 Subject: [PATCH] vfs/splice: limit a size of an intermediate buffer to pipe.DefaultPipeSize --- pkg/sentry/syscalls/linux/vfs2/splice.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/sentry/syscalls/linux/vfs2/splice.go b/pkg/sentry/syscalls/linux/vfs2/splice.go index aee74c0e1..658ecd2d3 100644 --- a/pkg/sentry/syscalls/linux/vfs2/splice.go +++ b/pkg/sentry/syscalls/linux/vfs2/splice.go @@ -380,7 +380,11 @@ func Sendfile(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sysc } } else { // Read inFile to buffer, then write the contents to outFile. - buf := make([]byte, count) + bufSize := count + if count > pipe.DefaultPipeSize { + bufSize = count + } + buf := make([]byte, bufSize) for { var readN int64 if offset != -1 {