Commit Graph

3972 Commits

Author SHA1 Message Date
Nicolas Lacasse 5f33fdf37e Pass overlay credentials via context in copy up.
Some VFS operations (those which operate on FDs) get their credentials via the
context instead of via an explicit creds param. For these cases, we must pass
the overlay credentials on the context.

PiperOrigin-RevId: 327881259
2020-08-21 15:06:09 -07:00
Nicolas Lacasse 5ec3d4ed3e Make mounts ReadWrite first, then later change to ReadOnly.
This lets us create "synthetic" mountpoint directories in ReadOnly mounts
during VFS setup.

Also add context.WithMountNamespace, as some filesystems (like overlay) require
a MountNamespace on ctx to handle vfs.Filesystem Operations.

PiperOrigin-RevId: 327874971
2020-08-21 14:30:03 -07:00
Zach Koopmans c9e752b644 Fix Inotify tests in open source.
The order of unlink events (dir event/file event) is undefined,
so make tests accept both orderings.

PiperOrigin-RevId: 327873316
2020-08-21 14:21:44 -07:00
Nicolas Lacasse 2c422b7f21 Fix parent directory creation in CreateDeviceFile.
It was not properly creating recursive directories. Added tests for this case.

Updates #1196

PiperOrigin-RevId: 327850811
2020-08-21 12:10:14 -07:00
Zach Koopmans c24db90be5 Skip ElfInterpreterStaticTest for 5.X kernels.
gVisor emulates 4.6 kernel versions, and test doesn't work on 5.0 versions
(observed on our Ubuntu18.04 image). Skip it.

PiperOrigin-RevId: 327845037
2020-08-21 11:39:04 -07:00
Nicolas Lacasse 0324b94a73 Skip socket stress tests on KVM platform.
They time out.

PiperOrigin-RevId: 327830892
2020-08-21 10:23:43 -07:00
Ayush Ranjan 73c69cb4d8 [vfs] Create recursive dir creation util.
Refactored the recursive dir creation util in runsc/boot/vfs.go to be more
flexible.

PiperOrigin-RevId: 327719100
2020-08-20 16:28:31 -07:00
Fabricio Voznika e8a25a2834 Enable strace+debug in syscall tests
This is done to ease troubleshooting when tests fail. runsc
logs are not stored when tests passe, so this will only
affect failing tests and should not increase log storage
too badly.

PiperOrigin-RevId: 327717551
2020-08-20 16:19:10 -07:00
Ting-Yu Wang df48227099 stateify: Fix afterLoad not being called for root object
PiperOrigin-RevId: 327711264
2020-08-20 15:40:15 -07:00
Dean Deng 3163aff866 Add reference count checking to the fsimpl/host package.
Includes a minor refactor for inode construction.

Updates #1486.

PiperOrigin-RevId: 327694933
2020-08-20 14:12:52 -07:00
Michael Pratt 129018ab3d Consistent precondition formatting
Our "Preconditions:" blocks are very useful to determine the input invariants,
but they are bit inconsistent throughout the codebase, which makes them harder
to read (particularly cases with 5+ conditions in a single paragraph).

I've reformatted all of the cases to fit in simple rules:

1. Cases with a single condition are placed on a single line.
2. Cases with multiple conditions are placed in a bulleted list.

This format has been added to the style guide.

I've also mentioned "Postconditions:", though those are much less frequently
used, and all uses already match this style.

PiperOrigin-RevId: 327687465
2020-08-20 13:32:24 -07:00
Bhasker Hariharan f12b545d8f Skip listening TCP ports when trying to bind a free port.
PiperOrigin-RevId: 327686558
2020-08-20 13:25:23 -07:00
Arthur Sfez 7ca62b9daa Only use the NextHeader value of the first IPv6 fragment extension header.
As per RFC 8200 Section 4.5:
  The Next Header field of the last header of the Per-Fragment
  headers is obtained from the Next Header field of the first
  fragment's Fragment header.

Test:
  - pkg/tcpip/network/ipv6:ipv6_test
  - pkg/tcpip/network/ipv4:ipv4_test
  - pkg/tcpip/network/fragmentation:fragmentation_test

Updates #2197

PiperOrigin-RevId: 327671635
2020-08-20 12:06:45 -07:00
Bhasker Hariharan 710adf23cd Use a explicit random src for RandomID.
PiperOrigin-RevId: 327659759
2020-08-20 11:07:29 -07:00
Nicolas Lacasse d2e32395c1 Fix tabs in lock-ordering doc.
PiperOrigin-RevId: 327654207
2020-08-20 10:42:53 -07:00
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