summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2020-08-28 11:26:25 -0700
committergVisor bot <gvisor-bot@google.com>2020-08-28 11:28:28 -0700
commit8b9cb36d1c74f71da5bc70b73330291f1df298ad (patch)
tree625440af8f39cdbae95c119da0d28222d94d687c /pkg/sentry
parentb3ff31d041c9455614a2a9f2a7be10afb6613357 (diff)
Fix EOF handling for splice.
Also, add corresponding EOF tests for splice/sendfile. Discovered by syzkaller. PiperOrigin-RevId: 328975990
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/syscalls/linux/vfs2/splice.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/sentry/syscalls/linux/vfs2/splice.go b/pkg/sentry/syscalls/linux/vfs2/splice.go
index 192411393..68ce94778 100644
--- a/pkg/sentry/syscalls/linux/vfs2/splice.go
+++ b/pkg/sentry/syscalls/linux/vfs2/splice.go
@@ -141,9 +141,14 @@ func Splice(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Syscal
inOffset += n
}
default:
- panic("not possible")
+ panic("at least one end of splice must be a pipe")
}
+ if n == 0 && err == io.EOF {
+ // We reached the end of the file. Eat the error and exit the loop.
+ err = nil
+ break
+ }
if n != 0 || err != syserror.ErrWouldBlock || nonBlock {
break
}