20 Commits

Author SHA1 Message Date
gVisor bot 7e77479d8a Internal change.
PiperOrigin-RevId: 523447770
2023-04-11 10:56:40 -07:00
Fabricio Voznika 03e92949e5 Force sendfile(2) to copy data in test
PiperOrigin-RevId: 490324920
2022-11-22 13:40:33 -08:00
Ayush Ranjan dba08ba26f LISAFS client file read must return io.EOF when appropriate.
This is consistent with POSIX semantics and with 9P client file.
Some VFS callers like splice really depend on such a non-nil
error being returned from FD.Read(). Otherwise, sendfile will
hang forever, spaming FD.Read() for more data.

Added a regression test. This test reproduces the issue when:
- LISAFS is enabled.
- sendfile(2) called with input file for which we don't have
  cached mapping (so will need to read from gofer). Can be
  simulated with shared gofer mode.
- Host FD is not available for input file to perform read. Tested
  internally.
Hence this test will be more meaningful when lisafs is enabled
by default in all tests.

PiperOrigin-RevId: 458340830
2022-06-30 16:44:27 -07:00
Ayush Ranjan fbf44721a1 Unblock buildkite tests.
- Excludes a failing java runtime test. This is a known issue being tracked
  in b/228068134. Disable it to unblock submits. Should be unexcluded when the
  bug is fixed.
- In upstream Linux, 6c25449e1a32 ("net: udp: fix alignment problem in
  udp4_seq_show()") updated the /pro/net/udp header to add another whitespace.
  But the other protocols (TCP, Raw, Ping) were not updated. gVisor produces
  this header in pkg/sentry/fsimpl/proc/task_net.go for all protocols. Instead
  of specially handling UDP in gVisor, just weaken the test for now.
- It seems like there is Linux sendfile bug. A nonblocking pipe blocks on
  sendfile(2). Excluded the test from running natively for now.

PiperOrigin-RevId: 442042678
2022-04-15 10:19:01 -07:00
Jamie Liu c5cc6a6566 Remove splice-to/from-weird-files tests.
These tests are permanently broken on Linux after 36e2c7421f02 "fs: don't allow
splice read/write without explicit ops".

PiperOrigin-RevId: 394161079
2021-08-31 23:12:24 -07:00
Adin Scannell e83cc06f1b Remove _NoRandomSave tests.
We do not currently run random save tests.

PiperOrigin-RevId: 368309921
2021-04-13 15:42:41 -07:00
Andrei Vagin d6dbe6e5ca pipe: writeLocked has to return ErrWouldBlock if the pipe is full
PiperOrigin-RevId: 356450303
2021-02-09 01:34:45 -08:00
Jamie Liu 267560d159 Reset watchdog timer between sendfile() iterations.
As part of this, change Task.interrupted() to not drain Task.interruptChan, and
do so explicitly using new function Task.unsetInterrupted() instead.

PiperOrigin-RevId: 342768365
2020-11-16 18:55:24 -08:00
Nicolas Lacasse 53eeb06ef1 Fix infinite loop when splicing to pipes/eventfds.
Writes to pipes of size < PIPE_BUF are guaranteed to be atomic, so writes
larger than that will return EAGAIN if the pipe has capacity < PIPE_BUF.

Writes to eventfds will return EAGAIN if the write would cause the eventfd
value to go over the max.

In both such cases, calling Ready() on the FD will return true (because it is
possible to write), but specific kinds of writes will in fact return EAGAIN.

This CL fixes an infinite loop in splice and sendfile (VFS1 and VFS2) by
forcing skipping the readiness check for the outfile in send, splice, and tee.

PiperOrigin-RevId: 341102260
2020-11-06 12:55:29 -08:00
Dean Deng 8b9cb36d1c Fix EOF handling for splice.
Also, add corresponding EOF tests for splice/sendfile.

Discovered by syzkaller.

PiperOrigin-RevId: 328975990
2020-08-28 11:28:28 -07:00
Dean Deng 84f04909c2 Fix vfs2 pipe behavior when splicing to a non-pipe.
Fixes *.sh Java runtime tests, where splice()-ing from a pipe to /dev/zero
would not actually empty the pipe.

There was no guarantee that the data would actually be consumed on a splice
operation unless the output file's implementation of Write/PWrite actually
called VFSPipeFD.CopyIn. Now, whatever bytes are "written" are consumed
regardless of whether CopyIn is called or not.

Furthermore, the number of bytes in the IOSequence for reads is now capped at
the amount of data actually available. Before, splicing to /dev/zero would
always return the requested splice size without taking the actual available
data into account.

This change also refactors the case where an input file is spliced into an
output pipe so that it follows a similar pattern, which is arguably cleaner
anyway.

Updates #3576.

PiperOrigin-RevId: 328843954
2020-08-27 16:57:40 -07:00
Nicolas Lacasse 71e6ac3e1f Don't allow read/write when offset+size overflows.
PiperOrigin-RevId: 306348346
2020-04-13 18:00:17 -07:00
Adin Scannell a94309628e Ensure EOF is handled propertly during splice.
PiperOrigin-RevId: 304684417
2020-04-03 13:40:51 -07:00
Andrei Vagin db218fdfcf Don't report partialResult errors from sendfile
The input file descriptor is always a regular file, so sendfile can't lose any
data if it will not be able to write them to the output file descriptor.

Reported-by: syzbot+22d22330a35fa1c02155@syzkaller.appspotmail.com
PiperOrigin-RevId: 272730357
2019-10-03 13:38:30 -07:00
Adin Scannell 7c6ab6a219 Implement splice methods for pipes and sockets.
This also allows the tee(2) implementation to be enabled, since dup can now be
properly supported via WriteTo.

Note that this change necessitated some minor restructoring with the
fs.FileOperations splice methods. If the *fs.File is passed through directly,
then only public API methods are accessible, which will deadlock immediately
since the locking is already done by fs.Splice. Instead, we pass through an
abstract io.Reader or io.Writer, which elide locks and use the underlying
fs.FileOperations directly.

PiperOrigin-RevId: 268805207
2019-09-12 17:43:27 -07:00
Fabricio Voznika 8fd89fd7a2 Fix sendfile(2) error code
When output file is in append mode, sendfile(2) should fail
with EINVAL and not EBADF.

Closes #721

PiperOrigin-RevId: 265718958
2019-08-27 10:52:46 -07:00
Nicolas Lacasse cf51e77d6d Fix suggestions from clang.
PiperOrigin-RevId: 255679603
2019-06-28 15:32:29 -07:00
Michael Pratt 4d52a55201 Change copyright notice to "The gVisor Authors"
Based on the guidelines at
https://opensource.google.com/docs/releasing/authors/.

1. $ rg -l "Google LLC" | xargs sed -i 's/Google LLC.*/The gVisor Authors./'
2. Manual fixup of "Google Inc" references.
3. Add AUTHORS file. Authors may request to be added to this file.
4. Point netstack AUTHORS to gVisor AUTHORS. Drop CONTRIBUTORS.

Fixes #209

PiperOrigin-RevId: 245823212
Change-Id: I64530b24ad021a7d683137459cafc510f5ee1de9
2019-04-29 14:26:23 -07:00
Fabricio Voznika 10426e0f31 Handle invalid offset in sendfile(2)
PiperOrigin-RevId: 235578698
Change-Id: I608ff5e25eac97f6e1bda058511c1f82b0e3b736
2019-02-25 12:17:46 -08:00
Brian Geffon d3bc79bc84 Open source system call tests.
PiperOrigin-RevId: 224886231
Change-Id: I0fccb4d994601739d8b16b1d4e6b31f40297fb22
2018-12-10 14:42:34 -08:00