From 3131a6b131127e70b5e3941e3c4d292d99312fa5 Mon Sep 17 00:00:00 2001 From: Chanwit Kaewkasi Date: Wed, 16 May 2018 14:19:34 -0700 Subject: Verify that when offset address is not null, infile must be seekable Change-Id: Id247399baeac58f6cd774acabd5d1da05e5b5697 PiperOrigin-RevId: 196887768 --- pkg/sentry/syscalls/linux/sys_file.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/sentry/syscalls/linux/sys_file.go b/pkg/sentry/syscalls/linux/sys_file.go index 1d61ac9f0..9b8374ef6 100644 --- a/pkg/sentry/syscalls/linux/sys_file.go +++ b/pkg/sentry/syscalls/linux/sys_file.go @@ -1915,6 +1915,10 @@ func Sendfile(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sysc hasOffset := offsetAddr != 0 // If we have a provided offset. if hasOffset { + // Verify that when offset address is not null, infile must be seekable + if !inFile.Flags().Pread { + return 0, nil, syserror.ESPIPE + } // Copy in the offset. if _, err := t.CopyIn(offsetAddr, &offset); err != nil { return 0, nil, err -- cgit v1.2.3