Commit Graph

3591 Commits

Author SHA1 Message Date
Jamie Liu 5e05950c1c Deflake exec test.
- Only use MAXSYMLINKS/2+1 symlinks for each of the interpreter and script
  paths in SymlinkLimitRefreshedForInterpreter to tolerate cases where the
  original paths (/tmp, /bin, or /bin/echo) themselves contain symlinks.

- Ensure that UnshareFiles performs execve immediately after clone(CLONE_VFORK)
  (no heap allocation for ExecveArray/RunfilesPath).

- Use lstat() rather than stat() for the existence check in fs_util's Exists;
  the latter will fail if the symlink target does not exist, even if the
  symlink does.

PiperOrigin-RevId: 320110156
2020-07-07 19:45:16 -07:00
Tony Gong 76c7bc51b7 Set IPv4 ID on all non-atomic datagrams
RFC 6864 imposes various restrictions on the uniqueness of the IPv4
Identification field for non-atomic datagrams, defined as an IP datagram that
either can be fragmented (DF=0) or is already a fragment (MF=1 or positive
fragment offset). In order to be compliant, the ID field is assigned for all
non-atomic datagrams.

Add a TCP unit test that induces retransmissions and checks that the IPv4
ID field is unique every time. Add basic handling of the IP_MTU_DISCOVER
socket option so that the option can be used to disable PMTU discovery,
effectively setting DF=0. Attempting to set the sockopt to anything other
than disabled will fail because PMTU discovery is currently not implemented,
and the default behavior matches that of disabled.

PiperOrigin-RevId: 320081842
2020-07-07 16:14:49 -07:00
Ting-Yu Wang 7e4d2d63ee icmp: When setting TransportHeader, remove from the Data portion.
The current convention is when a header is set to pkt.XxxHeader field, it
gets removed from pkt.Data. ICMP does not currently follow this convention.

PiperOrigin-RevId: 320078606
2020-07-07 15:56:46 -07:00
Ayush Ranjan 10930189c3 Fix mknod and inotify syscall test
This change fixes a few things:
- creating sockets using mknod(2) is supported via vfs2
- fsgofer can create regular files via mknod(2)
- mode = 0 for mknod(2) will be interpreted as regular file in vfs2 as well

Updates #2923

PiperOrigin-RevId: 320074267
2020-07-07 15:35:01 -07:00
gVisor bot c8aab5cbee Merge pull request #3149 from wietsevenema:patch-1
PiperOrigin-RevId: 320062822
2020-07-07 14:36:43 -07:00
Wietse Venema c0ea7d9e9e
README.md: Commpatibility > Compatibility 2020-07-07 16:32:15 +02:00
Jamie Liu e227450dc1 Call fdnotifier.UpdateFD() from fsimpl/gofer.specialFileFD.
The fdnotifier package provides an API to a thread that continually epolls
arbitrary host FDs. The set of events polled for each host FD is (intended to
be) all events for which a waiter.Entry has expressed interest, as returned by
waiter.Queue.Events() for the waiter.Queue registered to the given host FD.
When the set of events changes (due to a change in the set of registered
waiter.Entries), the mutator must call fdnotifier.UpdateFD() to recalculate the
new event set and propagate it to the epoll FD.

PiperOrigin-RevId: 319924719
2020-07-06 22:55:48 -07:00
Fabricio Voznika 937912a484 Ensure sync is called for readonly file
Calling sync on a readonly file flushes metadata that
may have been modified, like last access time.

Updates #1198

PiperOrigin-RevId: 319888290
2020-07-06 17:29:01 -07:00
Bhasker Hariharan b0f656184e Add support for SO_RCVBUF/SO_SNDBUF for AF_PACKET sockets.
Updates #2746

PiperOrigin-RevId: 319887810
2020-07-06 17:22:54 -07:00
Ting-Yu Wang 15c56d92d8 Fix NonBlockingWrite3 not writing b3 if b2 is zero-length.
PiperOrigin-RevId: 319882171
2020-07-06 16:47:37 -07:00
Fabricio Voznika bd43368f49 Add inode number to synthetic dentries
Reserve the MSB from ino for synthetic dentries to prevent
conflict with regular dentries. Log warning in case MSB is
set for regular dentries.

Updates #1487

PiperOrigin-RevId: 319869858
2020-07-06 15:40:03 -07:00
Ting-Yu Wang 1e5b0a9732 Shard some slow tests.
stack_x_test: 2m -> 20s
tcp_x_test: 80s -> 25s
PiperOrigin-RevId: 319828101
2020-07-06 12:14:08 -07:00
gVisor bot 47bffa544a Merge pull request #3110 from craig08:add-missing-ICRNL
PiperOrigin-RevId: 319827554
2020-07-06 12:08:03 -07:00
Tamir Duberstein 043e5dddde Remove dependency on pkg/binary
PiperOrigin-RevId: 319770124
2020-07-06 06:48:04 -07:00
Tamir Duberstein 0c13538664 Add wakers synchronously
Avoid a race where an arbitrary goroutine scheduling delay can cause the
processor to miss events and hang indefinitely.

Reduce allocations by storing processors by-value in the dispatcher, and
by using a single WaitGroup rather than one per processor.

PiperOrigin-RevId: 319665861
2020-07-05 06:10:21 -07:00
Tamir Duberstein 5ac34386a7 Improve failure message
Currently this test produces an error resembling

  tcp_zero_window_probe_retransmit_test.go:92: zero probe came sooner interval 3200179405 probe 4

which is approximately useless.

PiperOrigin-RevId: 319572263
2020-07-03 23:20:13 -07:00
Tamir Duberstein 418db67e2f Update build rule to appease deprecation
Before this change, running packetimpact tests produces:

  parameter 'direct' must contain a list of elements, and may no longer
  accept a depset. The deprecated behavior may be temporarily re-enabled
  by setting --incompatible_disable_depset_inputs=false

The positional parameter to depset has been changed to mean `direct`
rather than its previous meaning of `items`. The documentation[0]
explains:

  A positional parameter distinct from other parameters for legacy
  support.

  If --incompatible_disable_depset_items is false, this parameter
  serves as the value of items.

  If --incompatible_disable_depset_items is true, this parameter
  serves as the value of direct.

  See the documentation for these parameters for more details.

[0] https://docs.bazel.build/versions/master/skylark/lib/globals.html

PiperOrigin-RevId: 319555138
2020-07-03 17:43:09 -07:00
Dean Deng 6c099d8300 Update preadv2/pwritev2 flag handling in vfs2.
We do not support RWF_SYNC/RWF_DSYNC and probably shouldn't silently accept
them, since the user may incorrectly believe that we are synchronizing I/O.
Remove the pwritev2 test verifying that we support these flags.

gvisor.dev/issue/2601 is the tracking bug for deciding which RWF_.* flags
we need and supporting them.

Updates #2923, #2601.

PiperOrigin-RevId: 319351286
2020-07-01 22:04:42 -07:00
Ayush Ranjan 514955c1a8 [vfs2][gofer] Fix mmap syscall test.
We were not invalidating mappings when the file size changed in shared mode.
Enabled the syscall test for vfs2.

Updates #2923

PiperOrigin-RevId: 319346569
2020-07-01 21:05:53 -07:00
Ayush Ranjan 52b44719d6 [vfs2][gofer] Update file size to 0 on O_TRUNC
Some Open:TruncateXxx syscall tests were failing because the file size was
not being updated when the file was opened with O_TRUNC.

Fixes Truncate tests in test/syscalls:open_test_runsc_ptrace_vfs2.

Updates #2923

PiperOrigin-RevId: 319340127
2020-07-01 19:49:44 -07:00
Dean Deng 3b26d2121e Remove maxSendBufferSize from vfs2.
Complements cl/315991648.

PiperOrigin-RevId: 319327853
2020-07-01 17:40:19 -07:00
Dean Deng 65d9985558 Port vfs1 implementation of sync_file_range to vfs2.
Currently, we always perform a full-file sync which could be extremely
expensive for some applications. Although vfs1 did not fully support
sync_file_range, there were some optimizations that allowed us skip some
unnecessary write-outs.

Updates #2923, #1897.

PiperOrigin-RevId: 319324213
2020-07-01 17:11:26 -07:00
Mithun Iyer 31b27adf9b TCP receive should block when in SYN-SENT state.
The application can choose to initiate a non-blocking connect and
later block on a read, when the endpoint is still in SYN-SENT state.

PiperOrigin-RevId: 319311016
2020-07-01 15:47:50 -07:00
Dean Deng e4b2087602 Use directory fds in sticky test to avoid permission issues.
After we change credentials, it is possible that we no longer have access to
the sticky directory where we are trying to delete files. Use an open fd so
this is not an issue.

PiperOrigin-RevId: 319306255
2020-07-01 15:19:16 -07:00
Zach Koopmans 6a90c88b97 Port fallocate to VFS2.
PiperOrigin-RevId: 319283715
2020-07-01 13:14:44 -07:00
Jay Zhuang 68e1c870d3 Add test env variable "fuchsia"
... so that Fuchsia gets the same special cases applied to gVisor in tests when
this envrionment variable is set.

PiperOrigin-RevId: 319239064
2020-07-01 09:36:07 -07:00
Michael Pratt 068716ddf3 Fix FAQ URL
The existing gvisor.dev/faq link returns 404 because the full URL has
mistakenly been capitalized.

PiperOrigin-RevId: 319233173
2020-07-01 08:53:44 -07:00
Dean Deng cda2979b63 Complete async signal delivery support in vfs2.
- Support FIOASYNC, FIO{SET,GET}OWN, SIOC{G,S}PGRP (refactor getting/setting
  owner in the process).
- Unset signal recipient when setting owner with pid == 0 and
  valid owner type.

Updates #2923.

PiperOrigin-RevId: 319231420
2020-07-01 08:42:12 -07:00
Bhasker Hariharan b8f165ab1c Fix HTTPD benchmarks to correctly serve files from /tmp.
Fixes #3113

PiperOrigin-RevId: 319216671
2020-07-01 06:58:56 -07:00
Bhasker Hariharan c9446f0534 Fix two bugs in TCP sender.
a) When GSO is in use we should not cap the segment to maxPayloadSize in
   sender.maybeSendSegment as the GSO logic will cap the segment to the correct
   size. Without this the host GSO is not used as we end up breaking up large
   segments into small MSS sized segments before writing the packets to the
   host.

b) The check to not split a segment due to it not fitting in the receiver window
   when there are pending segments is incorrect as segments in writeList can be
   really large as we just take the write call's buffer size and create a single
   large segment. So a write of say 128KB will just be 1 segment in the
   writeList.

   The linux code checks if 1 MSS sized segments fits in the receiver's window
   and if not then does not split the current segment. gVisor's check was
   incorrect that it was checking if the whole segment which could be >>> 1 MSS
   would fit in the receiver's window. This was causing us to prematurely stop
   sending and falling back to retransmit timer/probe from the other end to send
   data.

This was seen when running HTTPD benchmarks where @ HEAD when sending large
files the benchmark was taking forever to run.

The tcp_splitseg_mss_test.go is being deleted as the test as written doesn't
test what is intended correctly. This is because GSO is enabled by default and
the reason the MSS+1 sized segment is sent is because GSO is in use. A proper
test will require disabling GSO on linux and netstack which is going to take a
bit of work in packetimpact to do it correctly.

Separately a new test probably should be written that verifies that a segment >
availableWindow is not split if the availableWindow is < 1 MSS.

Fixes #3107

PiperOrigin-RevId: 319172089
2020-06-30 23:56:34 -07:00
Dean Deng 43f5dd95a1 Fix index calculation for /proc/[pid]/cmdline.
We were truncating buf using a index relative to the middle of the slice (i.e.
where envv begins), but we need to calculate the index relative to the entire
slice.

Updates #2923.

PiperOrigin-RevId: 319154950
2020-06-30 21:00:49 -07:00
Dean Deng 20d571b0c1 Allow O_DIRECT on vfs2 tmpfs files.
Updates #2923.

PiperOrigin-RevId: 319153792
2020-06-30 20:48:59 -07:00
Bhasker Hariharan c4bdd0118f Add missing newline in /sys/devices/systen/cpu/onine
PiperOrigin-RevId: 319143410
2020-06-30 19:01:55 -07:00
Dean Deng 44071cc7fa Remove struct packing to fix compiler warning.
-Waddress-of-packed-member warns on inet_aton() being used with a packed struct
member. This was added in cl/291990716.

PiperOrigin-RevId: 319111253
2020-06-30 15:29:19 -07:00
Tamir Duberstein 4784ed46ef Avoid multiple atomic loads
...by calling (*tcp.endpoint).EndpointState only once when possible.

Avoid wrapping (*sleep.Waker).Assert in a useless func while I'm here.

PiperOrigin-RevId: 319074149
2020-06-30 12:25:03 -07:00
Dean Deng dce2dfae04 Add build target for the provisional style guide.
This includes the provisional style guide in the website and fixes the broken
link from CONTRIBUTING.md. The style guide will be located under the "Community"
category as it's related to contributing to the project.

Also, add missing includes that were causing some presubmits to fail.

PiperOrigin-RevId: 319061410
2020-06-30 11:25:55 -07:00
Craig Chi 09b7791e89 Add missing ICRNL flag in master termios test
Closes #2768
2020-06-30 09:31:28 -07:00
Zach Koopmans 5b0d8ff691 Refactor udp_socket_test
Bring udp_socket_test into complianc by:
- Eliminating IsRunningOnGvisor() invocations.
- Wrapping sockets in RAII FileDescriptor objects.
- Creating a Bind() method so that the first bind happens on port 0.

PiperOrigin-RevId: 318909396
2020-06-29 15:46:19 -07:00
Dean Deng e8f1a5c1f6 Port GETOWN, SETOWN fcntls to vfs2.
Also make some fixes to vfs1's F_SETOWN. The fcntl test now entirely passes
on vfs2.

Fixes #2920.

PiperOrigin-RevId: 318669529
2020-06-27 21:33:37 -07:00
Dean Deng 02d552d07c Support sticky bit in vfs2.
Updates #2923.

PiperOrigin-RevId: 318648128
2020-06-27 14:39:41 -07:00
Dean Deng 691c04278e Add documentation for vfs2 inotify.
Updates #1479.

PiperOrigin-RevId: 318631247
2020-06-27 09:20:04 -07:00
Ian Gudger bab3c36efb Add style guide.
PiperOrigin-RevId: 318591900
2020-06-26 21:10:37 -07:00
Dean Deng 85be13d9a3 Add tests for eventfd/timerfd/inotify operations that should return ESPIPE.
PiperOrigin-RevId: 318585377
2020-06-26 19:42:27 -07:00
Kevin Krakauer 66d1665441 IPv6 raw sockets. Needed for ip6tables.
IPv6 raw sockets never include the IPv6 header.

PiperOrigin-RevId: 318582989
2020-06-26 19:07:02 -07:00
gVisor bot 8dbeac53ce Implement SO_NO_CHECK socket option.
SO_NO_CHECK is used to skip the UDP checksum generation on a TX socket
(UDP checksum is optional on IPv4).

Test:
 - TestNoChecksum
 - SoNoCheckOffByDefault (UdpSocketTest)
 - SoNoCheck (UdpSocketTest)

Fixes #3055

PiperOrigin-RevId: 318575215
2020-06-26 17:51:04 -07:00
Zeling Feng aed7183976 Packetimpact test for IPv6 unknown options action
The Option Type identifiers are internally encoded such that their
highest-order two bits specify the action that must be taken if the
processing IPv6 node does not recognize the Option Type:

  00 - skip over this option and continue processing the header.
  01 - discard the packet.
  10 - discard the packet and, regardless of whether or not the
       packet's Destination Address was a multicast address, send an
       ICMP Parameter Problem, Code 2, message to the packet's
       Source Address, pointing to the unrecognized Option Type.
  11 - discard the packet and, only if the packet's Destination
       Address was not a multicast address, send an ICMP Parameter
       Problem, Code 2, message to the packet's Source Address,
       pointing to the unrecognized Option Type.

PiperOrigin-RevId: 318566613
2020-06-26 16:43:53 -07:00
Kevin Krakauer 9cfc154975 Require CAP_SYS_ADMIN in the root user namespace for TTY theft
PiperOrigin-RevId: 318563543
2020-06-26 16:24:39 -07:00
Zeling Feng e6a90baef1 Support IPv6 extension headers in packetimpact tests.
- IPv6 HopByHop Options Extension Header
- IPv6 Destination Options Extension Header

PiperOrigin-RevId: 318551425
2020-06-26 15:08:51 -07:00
Dean Deng 54a31e219c Support inotify IN_ONESHOT.
Also, while we're here, make sure that gofer inotify events are generated when
files are created in remote revalidating mode.

Updates #1479.

PiperOrigin-RevId: 318536354
2020-06-26 13:47:48 -07:00
gVisor bot cfd049da87 Merge pull request #2931 from ridwanmsharif:ridwanmsharif/fuse-char-device
PiperOrigin-RevId: 318511615
2020-06-26 11:37:23 -07:00