Commit Graph

806 Commits

Author SHA1 Message Date
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
Ridwan Sharif 2828806fb0 Test that the fuse device can be opened 2020-06-25 15:46:30 -04:00
Ridwan Sharif a63db7d903 Moved FUSE device under the fuse directory 2020-06-25 14:22:21 -04:00
Ridwan Sharif bd5f0e2dc4 Add FUSE character device
This change adds a FUSE character device backed by devtmpfs. This
device will be used to establish a connection between the FUSE
server daemon and fusefs. The FileDescriptionImpl methods will
be implemented as we flesh out fusefs some more. The tests assert
that the device can be opened and used.
2020-06-25 14:22:21 -04:00
Dean Deng b5e814445a Fix procfs bugs in vfs2.
- Support writing on proc/[pid]/{uid,gid}map
- Return EIO for writing to static files.

Updates #2923.

PiperOrigin-RevId: 318188503
2020-06-24 19:22:12 -07:00
gVisor bot ac6f7b600b Internal change.
PiperOrigin-RevId: 318180382
2020-06-24 18:14:07 -07:00
Nicolas Lacasse 58880bf551 Port /dev/net/tun device to VFS2.
Updates #2912 #1035

PiperOrigin-RevId: 318162565
2020-06-24 16:23:44 -07:00
Ian Gudger 2141013dce Add support for SO_REUSEADDR to TCP sockets/endpoints.
For TCP sockets, SO_REUSEADDR relaxes the rules for binding addresses.

gVisor/netstack already supported a behavior similar to SO_REUSEADDR, but did
not allow disabling it. This change brings the SO_REUSEADDR behavior closer to
the behavior implemented by Linux and adds a new SO_REUSEADDR disabled
behavior. Like Linux, SO_REUSEADDR is now disabled by default.

PiperOrigin-RevId: 317984380
2020-06-23 19:15:38 -07:00
Nicolas Lacasse 0f328beb0d Port /dev/tty device to VFS2.
Support is limited to the functionality that exists in VFS1.

Updates #2923 #1035

PiperOrigin-RevId: 317981417
2020-06-23 18:48:37 -07:00
Dean Deng 65a587dedf Complete inotify IN_EXCL_UNLINK implementation in VFS2.
Events were only skipped on parent directories after their children were
unlinked; events on the unlinked file itself need to be skipped as well.

As a result, all Watches.Notify() calls need to know whether the dentry where
the call came from was unlinked.

Updates #1479.

PiperOrigin-RevId: 317979476
2020-06-23 18:33:04 -07:00
Ting-Yu Wang acf519a77b Nit fix: Create and use a std::string object for `const char*`.
PiperOrigin-RevId: 317973144
2020-06-23 17:44:34 -07:00
Dean Deng 0c628c3152 Support inotify in vfs2 gofer fs.
Because there is no inode structure stored in the sandbox, inotify watches
must be held on the dentry. This would be an issue in the presence of hard
links, where multiple dentries would need to share the same set of watches,
but in VFS2, we do not support the internal creation of hard links on gofer
fs. As a result, we make the assumption that every dentry corresponds to a
unique inode.

Furthermore, dentries can be cached and then evicted, even if the underlying
file has not be deleted. We must prevent this from occurring if there are any
watches that would be lost. Note that if the dentry was deleted or invalidated
(d.vfsd.IsDead()), we should still destroy it along with its watches.

Additionally, when a dentry’s last watch is removed, we cache it if it also
has zero references. This way, the dentry can eventually be evicted from
memory if it is no longer needed. This is accomplished with a new dentry
method, OnZeroWatches(), which is called by Inotify.RmWatch and
Inotify.Release. Note that it must be called after all inotify locks are
released to avoid violating lock order. Stress tests are added to make sure
that inotify operations don't deadlock with gofer.OnZeroWatches.

Updates #1479.

PiperOrigin-RevId: 317958034
2020-06-23 16:14:56 -07:00
Ting-Yu Wang 793edf4cb4 Deflake proc test: Don't fail on DT_UNKNOWN.
Per manual page:
"All applications must properly handle a return of DT_UNKNOWN."

PiperOrigin-RevId: 317957013
2020-06-23 16:07:26 -07:00
Nicolas Lacasse edea9a8d02 Port readahead to VFS2.
It preserves the same functionality (almost none) as in VFS1.

Updates #2923 #1035

PiperOrigin-RevId: 317943522
2020-06-23 14:53:33 -07:00
gVisor bot ca1bc46f15 Internal change.
PiperOrigin-RevId: 317941748
2020-06-23 14:42:15 -07:00
Dean Deng 4573e7d863 Check for invalid trailing / when traversing path in gofer OpenAt.
Updates #2923.

PiperOrigin-RevId: 317700049
2020-06-22 11:39:41 -07:00
Nicolas Lacasse a480b4faf4 Allow readdir(/proc/[tid]/net) to return EINVAL on a zombie task.
Despite what the man page says, linux will return EINVAL when calling
getdents() an a /proc/[tid]/net file corresponding to a zombie task. This
causes readdir() to return a null pointer AND errno=EINVAL.

See fs/proc/proc_net.c:proc_tgid_net_readdir() for where this occurs.

We have tests that recursively read /proc, and are likely to hit this when
running natively, so we must catch and handle this case.

PiperOrigin-RevId: 317674168
2020-06-22 09:54:22 -07:00
Dean Deng f46f4a2af9 Enable passing vfs2 tests.
I forgot to update getdents earlier. Several thousand runs of the fsync and
proc_net_unix tests all passed as well.

Updates #2923.

PiperOrigin-RevId: 317415488
2020-06-19 18:27:29 -07:00
Nicolas Lacasse f0feada89c Use internal tmpfs in test runner, even when running with overlay.
PiperOrigin-RevId: 317377571
2020-06-19 14:14:21 -07:00
Dean Deng 7db196c4db Port fadvise64 to vfs2.
Like vfs1, we have a trivial implementation that ignores all valid advice.

Updates #2923.

PiperOrigin-RevId: 317349505
2020-06-19 11:50:09 -07:00
Dean Deng a609fff9d1 Fix vfs2 handling of preadv2/pwritev2 flags.
Check for unsupported flags, and silently support RWF_HIPRI by doing nothing.
From pkg/abi/linux/file.go: "gVisor does not implement the RWF_HIPRI feature,
but the flag is accepted as a valid flag argument for preadv2/pwritev2."

Updates #2923.

PiperOrigin-RevId: 317330631
2020-06-19 10:19:46 -07:00
Dean Deng f40d023ad6 Don't adjust parent link count if we replace a child dir with another.
Updates #2923.

PiperOrigin-RevId: 317314460
2020-06-19 08:45:40 -07:00
Dean Deng 46957ed24f Fix synthetic file bugs in gofer fs.
Always check if a synthetic file already exists at a location before creating a
file there, and do not try to delete synthetic gofer files from the remote fs.

This fixes runsc_ptrace socket tests that create/unlink synthetic, named socket
files.

Updates #2923.

PiperOrigin-RevId: 317293648
2020-06-19 05:57:15 -07:00
Dean Deng 408f3d2cd6 Fix vfs2 tmpfs link permission checks.
Updates #2923.

PiperOrigin-RevId: 317246916
2020-06-18 22:02:07 -07:00
Fabricio Voznika 878050b5cf Enable more VFS2 syscall tests
Updates #2923

PiperOrigin-RevId: 317185798
2020-06-18 14:52:54 -07:00
Michael Pratt 3970c12743 Remove various uses of 'whitelist'
Updates #2972

PiperOrigin-RevId: 317113059
2020-06-18 09:03:39 -07:00
Bhasker Hariharan 07ff909e76 Support setsockopt SO_SNDBUF/SO_RCVBUF for raw/udp sockets.
Updates #173,#6
Fixes #2888

PiperOrigin-RevId: 317087652
2020-06-18 06:07:20 -07:00
Fabricio Voznika 22b0bb2138 Add TempTmpMount test
This currently doesn't work with VSF2. Add test to ensure
it's not missed.

Updates #1487

PiperOrigin-RevId: 317013792
2020-06-17 19:09:37 -07:00
Fabricio Voznika 97f6b20e89 Move mount configutation to RunOpts
Separate mount configuration from links and move it to
RunOpts, like the other options.

PiperOrigin-RevId: 317010158
2020-06-17 18:43:26 -07:00
Ian Gudger 02072fd243 Add test for stat("/proc/net/snmp").
PiperOrigin-RevId: 316974863
2020-06-17 15:15:57 -07:00
Nicolas Lacasse 28a5c55bb6 Proc test: Allow root mount pathname to be non-root.
The test was expecting that the root mount pathname was "/", but it doesn't
need to be. Only the mount point actually should be "/" (otherwise it is not
the root).

PiperOrigin-RevId: 316968025
2020-06-17 14:42:41 -07:00
Bhasker Hariharan 505e8f4e3d Fix TtlDefault test on linux.
Different flavors of linux seem to use different defaults we accept 64
or 127 as the TtlDefault in the test.

PiperOrigin-RevId: 316961150
2020-06-17 14:08:48 -07:00
Michael Pratt 6d806ee719 Remove various uses of 'blacklist'
Updates #2972

PiperOrigin-RevId: 316942245
2020-06-17 12:34:33 -07:00
Fabricio Voznika 96519e2c9d Implement POSIX locks
- Change FileDescriptionImpl Lock/UnlockPOSIX signature to
  take {start,length,whence}, so the correct offset can be
  calculated in the implementations.
- Create PosixLocker interface to make it possible to share
  the same locking code from different implementations.

Closes #1480

PiperOrigin-RevId: 316910286
2020-06-17 10:04:26 -07:00
Nicolas Lacasse 6d64028c94 Fix typos in test/README.md.
Closes #2996.

PiperOrigin-RevId: 316900535
2020-06-17 09:13:09 -07:00
Mithun Iyer 67f261a87d TCP to honor updated window size during handshake.
In passive open cases, we transition to Established state after
initializing endpoint's sender and receiver. With this we lose out
on any updates coming from the ACK that completes the handshake.
This change ensures that we uniformly transition to Established in all
cases and does minor cleanups.

Fixes #2938

PiperOrigin-RevId: 316567014
2020-06-15 16:19:53 -07:00
Michael Pratt 885605c5e4 Remove blacklist from //test/runtimes
Updates #2972

PiperOrigin-RevId: 316534165
2020-06-15 13:36:24 -07:00
Martijn Vels eb6d3d7710 Internal change.
PiperOrigin-RevId: 316492839
2020-06-15 10:27:16 -07:00
Rahat Mahmood f23f62c2c2 Correctly set the test VFS environment variable.
Also fix test bugs uncovered now that they aren't silently skipped on
VFS2.

Updates #1487.

PiperOrigin-RevId: 316415807
2020-06-15 01:09:38 -07:00
Ian Gudger 3b5eaad3c8 Allow reading IP_MULTICAST_LOOP and IP_MULTICAST_TTL on TCP sockets.
I am not really sure what the point of this is, but someone filed a bug about
it, so I assume something relies on it.

PiperOrigin-RevId: 316225127
2020-06-12 20:49:02 -07:00
Tony Gong 82313667ea Make GenerateRandomPayload available to all tests
Moved the function for generating a payload of random byets of a specified
length into the testbench package so that it's availbale for all tests to use.

Added a test case to the IPv4 ID uniqueness test which uses a payload length
of 512 bytes. This test case passes for gVisor currently, whereas the test case
with a small payload of 11 bytes fails because gVisor only assigns the ID field
if the IP payload is sufficiently large.

PiperOrigin-RevId: 316185097
2020-06-12 15:07:17 -07:00
Andrei Vagin 6ec9d60403 vfs2: implement fcntl(fd, F_SETFL, flags)
PiperOrigin-RevId: 316148074
2020-06-12 11:58:15 -07:00
Mithun Iyer 61d6c059ac Replace use of %v in packetimpact tests
PiperOrigin-RevId: 316027588
2020-06-11 19:46:49 -07:00
Ian Lewis 8ea99d58ff Set the HOME environment variable for sub-containers.
Fixes #701

PiperOrigin-RevId: 316025635
2020-06-11 19:31:24 -07:00
Adin Scannell 5a894e35a0 Remove generated logs when test succeeds.
PiperOrigin-RevId: 316022884
2020-06-11 19:05:18 -07:00
Ian Gudger dc4e0157ef Add test for reordering.
Tests the effect of reordering on retransmission and window size.

Test covers the expected behavior of both Linux and netstack, however, netstack
does not behave as expected. Further, the current expected behavior of netstack
is not ideal and should be adjusted in the future.

PiperOrigin-RevId: 316015184
2020-06-11 18:04:43 -07:00
gVisor bot 11dc95e6c5 Merge pull request #2705 from lubinszARM:pr_sigfp_nested
PiperOrigin-RevId: 315979564
2020-06-11 14:35:46 -07:00