Commit Graph

4157 Commits

Author SHA1 Message Date
Fabricio Voznika be76c7ce6e Move boot.Config to its own package
Updates #3494

PiperOrigin-RevId: 327548511
2020-08-19 18:37:42 -07:00
Fabricio Voznika 6335704625 Remove path walk from localFile.Mknod
Replace mknod call with mknodat equivalent to protect
against symlink attacks. Also added Mknod tests.

Remove goferfs reliance on gofer to check for file
existence before creating a synthetic entry.

Updates #2923

PiperOrigin-RevId: 327544516
2020-08-19 18:05:54 -07:00
Fabricio Voznika 25babd6351 Run bazel build before deleting cached gopath files
bazel creates sysmlink to the cache on the first invokation.
On a new clone, there are no symlink, thus `rm -rf bazel-bin/gopath`
has no effect. Call `bazel build something` first, then delete
cached gopath.

PiperOrigin-RevId: 327536044
2020-08-19 17:05:45 -07:00
Zach Koopmans f8a9483002 Fix return for rseq_test.
Accept 128 + SIGNAL as well as SIGNAL as valid
returns for fork/exec tests.

Also, make changes so that test compiles in opensource. Test
had compile errors on latest Ubuntu 16.04 image with updated bazel to
3.4.0 (as well as base 2.0) used for Kokoro tests.

PiperOrigin-RevId: 327510310
2020-08-19 14:46:55 -07:00
Kevin Krakauer 182f66ee5e ip6tables: move ipv4-specific logic into its own file
A later change will introduce the equivalent IPv6 logic.

#3549

PiperOrigin-RevId: 327499064
2020-08-19 13:47:47 -07:00
Kevin Krakauer 5cf330106a ip6tables: test initial state
Tests that we have the correct initial (empty) state for ip6tables.

#3549

PiperOrigin-RevId: 327477657
2020-08-19 12:03:34 -07:00
Jamie Liu 3fd4b83fa3 Remove use of channels from p9.connState legacy transport.
- Remove sendDone, which currently does nothing whatsoever (errors sent to the
  channel are completely unused). Instead, have request handlers log errors
  they get from p9.send() inline.

- Replace recvOkay and recvDone with recvMu/recvIdle/recvShutdown. In addition
  to being slightly clearer (IMO), this eliminates the p9.connState.service()
  goroutine, significantly reducing the overhead involved in passing connection
  receive access between goroutines (from buffered chan send/recv + unbuffered
  chan send/recv to just a mutex unlock/lock).

PiperOrigin-RevId: 327476755
2020-08-19 11:58:59 -07:00
Fabricio Voznika 41777e90ea Change runtimeoptions proto handling.
Stolen from cl/327337408 (ascannell is OOO)

PiperOrigin-RevId: 327475423
2020-08-19 11:45:46 -07:00
Zach Koopmans 3331722291 Skip ECN test for native/linux tests.
Skip check for ECN bits in native/linux tests. General advice
for the ECN field is to leave the setting to the kernel, so
behavior of the test is undefined for different kernels.

http://www.masterraghu.com/subjects/np/introduction/unix_network_programming_v1.3/ch07lev1sec6.html

PiperOrigin-RevId: 327451414
2020-08-19 09:51:04 -07:00
Dean Deng 33c60b893f Return appropriate errors when file locking is unsuccessful.
test_eintr now passes in the Python runtime tests.

Updates #3515.

PiperOrigin-RevId: 327441081
2020-08-19 08:53:12 -07:00
Ayush Ranjan 35dc7fe7e7 [vfs] Allow offsets for special files other than regular files.
Some character and block devices can be seekable. So allow their FD to maintain
file offset.

PiperOrigin-RevId: 327370684
2020-08-18 22:02:23 -07:00
Dean Deng e5f05d9bf4 Get rid of kernfs.Inode.Destroy.
This interface method is unneeded.

PiperOrigin-RevId: 327370325
2020-08-18 21:54:08 -07:00
Dean Deng f2822da542 Move ERESTART* error definitions to syserror package.
This is needed to avoid circular dependencies between the vfs and kernel
packages.

PiperOrigin-RevId: 327355524
2020-08-18 19:28:53 -07:00
Fabricio Voznika 9da77d00fa Don't set atime if mount is readonly
Updates #1035

PiperOrigin-RevId: 327351475
2020-08-18 19:00:15 -07:00
Fabricio Voznika afe7303c3c Add more information to panic when device ID don't match
PiperOrigin-RevId: 327351357
2020-08-18 18:52:24 -07:00
Zach Koopmans f6d2490482 Fix return value in shm_test for opensource
Some machines return 128 + signal for failures. Accept that
as a valid result.

PiperOrigin-RevId: 327326113
2020-08-18 16:07:35 -07:00
Nayana Bidari 4184a7d5f1 RACK: Create a new list for segments.
RACK requires the segments to be in the order of their transmission
or retransmission times. This cl creates a new list and moves the
retransmitted segments to the end of the list.

PiperOrigin-RevId: 327325153
2020-08-18 15:59:37 -07:00
Jamie Liu 6405525b04 Avoid holding locks when opening files in VFS2.
Fixes #3243, #3521

PiperOrigin-RevId: 327308890
2020-08-18 14:36:06 -07:00
Fabricio Voznika 760c131da1 Return EROFS if mount is read-only
PiperOrigin-RevId: 327300635
2020-08-18 13:58:42 -07:00
Zach Koopmans 4141dc0d2c Fix timeval for Socket test
tv_usec field should be a multiple of 4K to pass
in open source on linux/native, so make it one.

PiperOrigin-RevId: 327288405
2020-08-18 12:56:44 -07:00
Jamie Liu b3141b680f Wait for all p9 handlers to complete before server shutdown.
... including those invoked via flipcall.

PiperOrigin-RevId: 327283194
2020-08-18 12:32:14 -07:00
Ayush Ranjan b9d87ae7af [vfs2] Implement /proc/sys/net/ipv4/tcp_rmem and /proc/sys/net/ipv4/tcp_wmem.
Updates #1035

PiperOrigin-RevId: 327253907
2020-08-18 10:22:07 -07:00
Zach Koopmans 673b6cc7fc Fix readahead test for opensource.
Skip InvalidOffset and InvalidLength for Linux as the test is invalid for
later Kernel versions.

Add UnsupportedFile test as this check is in all kernel versions.

PiperOrigin-RevId: 327248035
2020-08-18 10:02:27 -07:00
Zach Koopmans da5c2ea6dc Fix return value for MMap Tests in OpenSource
Some systems return 128 + errno instead of just errno, which is the case
here.

PiperOrigin-RevId: 327247836
2020-08-18 09:54:48 -07:00
gVisor bot 6d0c5803d5 Add a skeleton for verity file system
PiperOrigin-RevId: 327123477
2020-08-17 16:43:45 -07:00
Nicolas Lacasse d42d01b976 Stop masking the IO error in handleIOError.
PiperOrigin-RevId: 327123331
2020-08-17 16:30:27 -07:00
gVisor bot 1b938ba72c Add Verify in merkle tree library
Verify checks input data against the merkle tree, and compares the root
hash with expectation.

PiperOrigin-RevId: 327116711
2020-08-17 15:56:22 -07:00
Zach Koopmans 988ab27058 Fix AllSocketPairTest for open source.
Setting timeouts for sockets on GCP images (debian) for usecs only
respects multiples of 4K. Set the test with a multiple of 4K with a comment.

PiperOrigin-RevId: 327093848
2020-08-17 14:04:20 -07:00
Ayush Ranjan e3e1b36896 [vfs] Do O_DIRECTORY check after resolving symlinks.
Fixes python runtime test test_glob.
Updates #3515

We were checking is the to-be-opened dentry is a dir or not before resolving
symlinks. We should check that after resolving symlinks.
This was preventing us from opening a symlink which pointed to a directory
with O_DIRECTORY.

Also added this check in tmpfs and removed a duplicate check.

PiperOrigin-RevId: 327085895
2020-08-17 13:26:31 -07:00
Ghanan Gowripalan e3c4bbd10a Remove address range functions
Should have been removed in cl/326791119
9a7b5830aa

PiperOrigin-RevId: 327074156
2020-08-17 12:30:05 -07:00
Dean Deng 3bd066d503 Remove weak references from unix sockets.
The abstract socket namespace no longer holds any references on sockets.
Instead, TryIncRef() is used when a socket is being retrieved in
BoundEndpoint(). Abstract sockets are now responsible for removing themselves
from the namespace they are in, when they are destroyed.

Updates #1486.

PiperOrigin-RevId: 327064173
2020-08-17 11:42:20 -07:00
Arthur Sfez 58154194b3 Add a unit test for out of order IP reassembly
PiperOrigin-RevId: 327042869
2020-08-17 10:19:11 -07:00
Ayush Ranjan 97263e5053 [vfs] Return EIO when opening /dev/tty.
This is in compliance with VFS1. See pkg/sentry/fs/dev/tty.go in the struct
ttyInodeOperations.

Fixes the failure of python runtime test_ioctl.
Updates #3515

PiperOrigin-RevId: 327042758
2020-08-17 10:05:43 -07:00
Ghanan Gowripalan 9a7b5830aa Don't support address ranges
Previously the netstack supported assignment of a range of addresses.
This feature is not used so remove it.

PiperOrigin-RevId: 326791119
2020-08-15 00:06:29 -07:00
Ghanan Gowripalan 1736b2208f Use a single NetworkEndpoint per NIC per protocol
The NetworkEndpoint does not need to be created for each address.
Most of the work the NetworkEndpoint does is address agnostic.

PiperOrigin-RevId: 326759605
2020-08-14 17:30:01 -07:00
Ian Lewis 3f523b3bbc Handle URLs better in issue reviver
- Handle urls ending in /
- Add some url parsing tests

PiperOrigin-RevId: 326750183
2020-08-14 16:23:34 -07:00
Nayana Bidari af433e159d Update README for packetimpact
PiperOrigin-RevId: 326733912
2020-08-14 14:49:14 -07:00
gVisor bot 3be8b49c70 Merge pull request #3375 from kevinGC:ipt-test-early-return
PiperOrigin-RevId: 326693922
2020-08-14 11:24:56 -07:00
Zach Koopmans e6ea59203b Skip UDPMulticast Tests when net interfaces aren't found.
PiperOrigin-RevId: 326686761
2020-08-14 10:53:04 -07:00
Julian Elischer 190634e0fc Give the ICMP Code its own type
This is  a preparatory commit for a larger commit working on
ICMP generation in error cases.
This is removal of technical debt and cleanup in the gvisor code
as part of gvisor issue 2211.

Updates #2211.

PiperOrigin-RevId: 326615389
2020-08-14 02:07:36 -07:00
Ayush Ranjan d6520e1d05 [vfs2][gofer] Fix file creation flags sent to gofer.
Fixes php runtime test ext/standard/tests/file/readfile_basic.phpt
Fixes #3516

fsgofers only want the access mode in the OpenFlags passed to Create(). If more
flags are supplied (like O_APPEND in this case), read/write from that fd will
fail with EBADF. See runsc/fsgofer/fsgofer.go:WriteAt()
VFS2 was providing more than just access modes. So filtering the flags using
p9.OpenFlagsModeMask == linux.O_ACCMODE fixes the issue.

Gofer in VFS1 also only extracts the access mode flags while making the create
RPC. See pkg/sentry/fs/gofer/path.go:Create()

Even in VFS2, when we open a handle, we extract out only the access mode flags
+ O_TRUNC.
See third_party/gvisor/pkg/sentry/fsimpl/gofer/handle.go:openHandle()

Added a test for this.

PiperOrigin-RevId: 326574829
2020-08-13 19:33:56 -07:00
Ghanan Gowripalan d3bb50ebf8 Use the user supplied MSS for accepted connections
This change supports using the user supplied MSS (TCP_MAXSEG socket
option) for new socket connections created from a listening TCP socket.
Note that the user supplied MSS will only be used if it is not greater
than the maximum possible MSS for a TCP connection's route. If it is
greater than the maximum possible MSS, the MSS will be capped at that
maximum value.

Test: tcp_test.TestUserSuppliedMSSOnListenAccept
PiperOrigin-RevId: 326567442
2020-08-13 18:29:47 -07:00
gVisor bot 20be1c0e63 Merge pull request #3476 from zhlhahaha:1930
PiperOrigin-RevId: 326563255
2020-08-13 17:59:00 -07:00
Ayush Ranjan 5036f135e4 Disable vfs2 for socket_stress_test.
PiperOrigin-RevId: 326553620
2020-08-13 16:58:43 -07:00
Ting-Yu Wang 47515f4751 Migrate to PacketHeader API for PacketBuffer.
Formerly, when a packet is constructed or parsed, all headers are set by the
client code. This almost always involved prepending to pk.Header buffer or
trimming pk.Data portion. This is known to prone to bugs, due to the complexity
and number of the invariants assumed across netstack to maintain.

In the new PacketHeader API, client will call Push()/Consume() method to
construct/parse an outgoing/incoming packet. All invariants, such as slicing
and trimming, are maintained by the API itself.

NewPacketBuffer() is introduced to create new PacketBuffer. Zero value is no
longer valid.

PacketBuffer now assumes the packet is a concatenation of following portions:
* LinkHeader
* NetworkHeader
* TransportHeader
* Data
Any of them could be empty, or zero-length.

PiperOrigin-RevId: 326507688
2020-08-13 13:08:57 -07:00
Bhasker Hariharan b928d074b4 Ensure TCP TIME-WAIT is not terminated prematurely.
Netstack's TIME-WAIT state for a TCP socket could be terminated prematurely if
the socket entered TIME-WAIT using shutdown(..., SHUT_RDWR) and then was closed
using close(). This fixes that bug and updates the tests to verify that Netstack
correctly honors TIME-WAIT under such conditions.

Fixes #3106

PiperOrigin-RevId: 326456443
2020-08-13 09:04:31 -07:00
Dean Deng 36134667b2 Add reference leak checking to vfs2 tmpfs.inode.
Updates #1486.

PiperOrigin-RevId: 326354750
2020-08-12 18:11:41 -07:00
Ayush Ranjan 42b610d567 [vfs2][gofer] Return appropriate errors when opening and creating files.
Fixes php test ext/standard/tests/file/touch_variation5.phpt on vfs2.
Updates #3516

Also spotted a bug with O_EXCL, where we did not return EEXIST when we tried
to open the root of the filesystem with O_EXCL | O_CREAT.

Added some more tests for open() corner cases.

PiperOrigin-RevId: 326346863
2020-08-12 17:19:09 -07:00
Kevin Krakauer d50f2e2c76 ip6tables: ABI structs and constants
Part of #3549.

PiperOrigin-RevId: 326329028
2020-08-12 16:20:51 -07:00
gVisor bot 252329c1f3 Merge pull request #3605 from lubinszARM:pr_helloworld_thunderx2
PiperOrigin-RevId: 326326710
2020-08-12 16:01:40 -07:00