Commit Graph

2760 Commits

Author SHA1 Message Date
gVisor bot 1921c246a9 Internal change.
PiperOrigin-RevId: 304641990
2020-04-03 10:20:55 -07:00
Uros Prestor d151693530 Avoid sending a partial dirent when the Rreaddir response exceeds message limit.
PiperOrigin-RevId: 304542967
2020-04-02 22:03:20 -07:00
Fabricio Voznika dd3bc49997 Add NAME_MAX checks and update file times
NAME_MAX should be enforced per filesystem implementation
because other file systems may not have the same restriction.

Gofer filesystem now keeps a reference to the kernel clock to
avoid lookup in the Context on file access to update atime.

Update access, modification, and status change times in tmpfs.

Updates #1197, #1198.

PiperOrigin-RevId: 304527148
2020-04-02 19:39:03 -07:00
Ghanan Gowripalan 4582a2f188 Drop NDP messages with fragment extension header
As per RFC 6980 section 5, nodes MUST silently ignore NDP messages if
the packet carrying them include an IPv6 Fragmentation Header.

Test: ipv6_test.TestNDPValidation
PiperOrigin-RevId: 304519379
2020-04-02 18:30:15 -07:00
Dean Deng 5b2396d244 Fix typo in TODO comments.
PiperOrigin-RevId: 304508083
2020-04-02 17:07:13 -07:00
Jamie Liu dbc507dc5c Add equivalents to FMODE_PREAD/PWRITE to VFS2.
This is mostly required for PipeTest_OffsetCalls.

The options are DenyPRead/PWrite rather than AllowPRead/PWrite since, in Linux
terms, fs/open.c:do_dentry_open sets FMODE_PREAD|FMODE_PWRITE unconditionally
(although it allows filesystem implementations of open to unset these flags),
so they're set for most FDs; it's usually FDs created outside of open(2) that
don't get them, e.g.:

- Syscall-created pipes (fs/pipe.c:create_pipe_files =>
  fs/file_table.c:alloc_file_pseudo)

- Epoll instances (fs/eventpoll.c:do_epoll_create =>
  fs/anon_inodes.c:anon_inode_getfile => alloc_file_pseudo)

- Sockets (net/socket.c:sock_alloc_file => alloc_file_pseudo)

This CL adds the flags to epoll instances; a subsequent CL reworks the VFS2
implementation of pipe FDs to be filesystem-independent and adds the flags
there, and sockets aren't implemented yet.

Updates #1035

PiperOrigin-RevId: 304506434
2020-04-02 16:58:24 -07:00
Ghanan Gowripalan ecc3d01d18 Increment NDP message RX stats before validation
Tests:
- ipv6_test.TestHopLimitValidation
- ipv6_test.TestRouterAdvertValidation
PiperOrigin-RevId: 304495723
2020-04-02 15:59:48 -07:00
Jamie Liu 30388ff591 Rename files in //pkg/sync to better reflect what they contain.
PiperOrigin-RevId: 304447031
2020-04-02 11:57:06 -07:00
Zach Koopmans 035836193e Fix typo in benchmarks.sh
PiperOrigin-RevId: 304440599
2020-04-02 11:25:26 -07:00
Bhasker Hariharan c6d5742c21 Fix flaky TCPLinger2TimeoutAfterClose test.
The test is flaky in cooperative S/R mode because TCP timers are not restored
across a S/R. This can cause the TCPLinger2 timer to not fire. This change
disables S/R before setting the TCP_LINGER2 timeout.

PiperOrigin-RevId: 304430536
2020-04-02 10:41:12 -07:00
Zach Koopmans 37025990d6 Add "/snap/bin" to PATH.
"gcloud" may be installed as a snap, under "/snap/bin". Make
sure this is in our PATH so that we can use gcloud.

PiperOrigin-RevId: 304297180
2020-04-01 17:40:19 -07:00
Rahat Mahmood 1561ae3037 go-marshal: Allow array lens to be consts and simple expressions.
Previously, go-marshal only allowed literals for array
lengths. However, it's very common for ABI structs to have a fix-sized
array whose length is defined by a constant; for example PATH_MAX.
Having to convert all such arrays to have literal lengths is too
awkward.

PiperOrigin-RevId: 304289345
2020-04-01 16:51:28 -07:00
Ghanan Gowripalan aecd3a25a9 Deflake tcpip/stack:stack_x_test
Timeouts were increased to deflake pkg/tcpip/stack:stack_x_test tests
that depend on timers. Some timeouts used previously were intended for
tests that do not depend on timers, so this change updates those
timeouts to give more time for a timer-based event to occur. This
change also de-parallelizes non-subtests to reduce the number of active
timers.

Test: bazel test //pkg/tcpip/stack:stack_x_test --runs_per_test=500
PiperOrigin-RevId: 304287622
2020-04-01 16:41:26 -07:00
Nicolas Lacasse 0d1e299079 Pass configurable FilesystemType to tmpfs.
PiperOrigin-RevId: 304234086
2020-04-01 12:06:37 -07:00
Eyal Soha 38f4501c99 Add context.Context argument to XxxWithErrno functions
This allows control over the gRPC timeouts as needed.

PiperOrigin-RevId: 304225713
2020-04-01 11:27:03 -07:00
Adin Scannell 4e6a1a5adb Automated rollback of changelist 303799678
PiperOrigin-RevId: 304221302
2020-04-01 11:06:26 -07:00
Michael Pratt db7917556a Fix 386 build tags
The build tag for 32-bit x86 is 386, not i386.

Updates #2298

PiperOrigin-RevId: 304206373
2020-04-01 10:00:03 -07:00
Dean Deng d01a8ca347 Add FileDescription interface for socket files.
Refactor the existing socket interface to share methods between VFS1 and VFS2.
The method signatures do not contain anything filesystem-related, so they don't
need to be re-defined for VFS2.

Updates #1476, #1478, #1484, #1485.

PiperOrigin-RevId: 304184545
2020-04-01 07:57:12 -07:00
Rahat Mahmood 507f997213 go-marshal: Improve collision detection of import statments.
Previously, the import statement collision detection mechanism aborted
go-marshal whenever it detected two imports in any package that has
the same local name. Consider this trivial package, defined by the the
following two source files:

file1.go:

package example
import (
        path/a/to/foo
)
...

file2.go:

package example
import (
       another/package/with/final/component/foo
)
...

Go-marshal previously couldn't handle generating code for the the
above package, even if none of the types marked for marshalling used
either of the imported foo packages. This turns out to be too
restrictive as we run into this a lot in practice. Examples include
"encoding/binary" vs "gvisor/pkg/binary/binary", and "sync" vs
"gvisor/pkg/sync/sync".

This change allows go-marshal to proceed with marshalling, and only
abort if the code generated by go-marshal references any such
ambiguous import names.

PiperOrigin-RevId: 304131190
2020-04-01 00:43:55 -07:00
Rahat Mahmood 840980aeba Implement automated marshalling for slices of Marshallable types.
PiperOrigin-RevId: 304119255
2020-03-31 22:56:09 -07:00
Eyal Soha d25036ad17 Test receiving multicast packets over UDP
PiperOrigin-RevId: 304098611
2020-03-31 19:53:11 -07:00
Dean Deng 639d94f9f7 Add socket filesystem and global disconnected socket mount for VFS2.
A socket mount where anonymous sockets will reside is added to the
VirtualFilesystem. Socketfs is built on top of kernfs.

Updates #1476, #1478, #1484, #1485.

PiperOrigin-RevId: 304095251
2020-03-31 19:17:12 -07:00
Zach Koopmans 57e67e32b5 Debug script issues on Kokoro.
PiperOrigin-RevId: 304068950
2020-03-31 16:17:56 -07:00
Nicolas Lacasse b6639f77e5 Include original copyUp error in panic if cleanupUpper fails.
When copyUp fails, we attempt to clean up the upper filesystem by removing any
files that have already been copied-up. If the cleanup fails, we panic because
the "overlay filesystem is in an inconsistent state".

This CL adds the original copy-up error to the panic information, to hopefully
make it easier to track down how the overlay filesystem got into the
inconsistent state.

PiperOrigin-RevId: 304053370
2020-03-31 15:11:11 -07:00
Nicolas Lacasse e1c8eaca8f Fix /proc/self/mounts and /proc/self/mountinfo in VFS2.
Some extra fields were added to the Mount type to expose necessary data to the
proc filesystem.

PiperOrigin-RevId: 304053361
2020-03-31 15:07:26 -07:00
Nicolas Lacasse 9de982ea79 Allow passing root file type to tmpfs.
PiperOrigin-RevId: 304053357
2020-03-31 15:02:57 -07:00
Michael Pratt 32a133537e Add AMD Rome CPUID flag.
This flag is set on Rome CPUs, but it is not documented.

PiperOrigin-RevId: 303825532
2020-03-30 14:38:41 -07:00
Zach Koopmans e36eccc4b1 BigQuery schema for benchmark-tools dashboard.
PiperOrigin-RevId: 303805784
2020-03-30 13:05:45 -07:00
Adin Scannell 3fac85da95 kvm: handle exit reasons even under EINTR.
In the case of other signals (preemption), inject a normal bounce and
defer the signal until the vCPU has been returned from guest mode.

PiperOrigin-RevId: 303799678
2020-03-30 12:37:57 -07:00
Zach Koopmans 4aee370640 Internal change.
PiperOrigin-RevId: 303773475
2020-03-30 10:44:55 -07:00
gVisor bot 1876f10e15 Merge pull request #2265 from amscanne:arm64_nogo
PiperOrigin-RevId: 303753027
2020-03-30 09:08:55 -07:00
Jamie Liu f6e4daa67a Add vfs.PathnameReachable().
/proc/[pid]/mount* omit mounts whose mount point is outside the chroot, which
is checked (indirectly) via __d_path().

PiperOrigin-RevId: 303434226
2020-03-27 16:57:14 -07:00
Nicolas Lacasse 10f2c8db91 Add FilesystemType.Name method, and FilesystemType field to Filesystem struct.
Both have analogues in Linux:
* struct file_system_type has a char *name field.
* struct super_block keeps a pointer to the file_system_type.

These fields are necessary to support the `filesystem type` field in
/proc/[pid]/mountinfo.

PiperOrigin-RevId: 303434063
2020-03-27 16:56:16 -07:00
Ghanan Gowripalan 2a4aff7f7e Support Hop By Hop and Destination Options ext hdr
Enables handling the Hop by Hop and Destination Options extension
headers, but options are not yet supported. All options will be
treated as unknown and their respective action will be followed.

Note, the stack does not yet support sending ICMPv6 error messages in
response to options that cannot be handled/parsed. That will come
in a later change (Issue #2211).

Tests:
- header_test.TestIPv6UnknownExtHdrOption
- header_test.TestIPv6OptionsExtHdrIterErr
- header_test.TestIPv6OptionsExtHdrIter
- ipv6_test.TestReceiveIPv6ExtHdrs
PiperOrigin-RevId: 303433085
2020-03-27 16:52:25 -07:00
Dean Deng 76a7ace751 Add BoundEndpointAt filesystem operation.
BoundEndpointAt() is needed to support Unix sockets bound at a
file path, corresponding to BoundEndpoint() in VFS1.

Updates #1476.

PiperOrigin-RevId: 303258251
2020-03-26 21:52:24 -07:00
Dean Deng 137f361400 Use host-defined file owner and mode, when possible, for imported fds.
Using the host-defined file owner matches VFS1. It is more correct to use the
host-defined mode, since the cached value may become out of date. However,
kernfs.Inode.Mode() does not return an error--other filesystems on kernfs are
in-memory so retrieving mode should not fail. Therefore, if the host syscall
fails, we rely on a cached value instead.

Updates #1672.

PiperOrigin-RevId: 303220864
2020-03-26 16:47:20 -07:00
Ghanan Gowripalan edc3c049eb Use panic instead of log.Fatalf
PiperOrigin-RevId: 303212189
2020-03-26 16:01:00 -07:00
gVisor bot 0e62a548eb Merge pull request #2130 from nybidari:iptables
PiperOrigin-RevId: 303208407
2020-03-26 15:47:00 -07:00
Ghanan Gowripalan fbe80460a7 Handle IPv6 Fragment & Routing extension headers
Enables the reassembly of fragmented IPv6 packets and handling of the
Routing extension header with a Segments Left value of 0. Atomic
fragments are handled as described in RFC 6946 to not interfere with
"normal" fragment traffic. No specific routing header type is supported.

Note, the stack does not yet support sending ICMPv6 error messages in
response to IPv6 packets that cannot be handled/parsed. That will come
in a later change (Issue #2211).

Test:
- header_test.TestIPv6RoutingExtHdr
- header_test.TestIPv6FragmentExtHdr
- header_test.TestIPv6ExtHdrIterErr
- header_test.TestIPv6ExtHdrIter
- ipv6_test.TestReceiveIPv6ExtHdrs
- ipv6_test.TestReceiveIPv6Fragments

RELNOTES: n/a
PiperOrigin-RevId: 303189584
2020-03-26 14:05:39 -07:00
Nicolas Lacasse e466ab04a2 Add unique ID to Mount type.
Analagous to Linux's mount.mnt_id. This ID is displayed in
/proc/[pid]/mountinfo.

PiperOrigin-RevId: 303185564
2020-03-26 13:49:59 -07:00
Adin Scannell a5742f177a Add nogo exemption for machine_arm64_unsafe.go 2020-03-26 12:29:14 -07:00
Nayana Bidari 92b9069b67 Support owner matching for iptables.
This feature will match UID and GID of the packet creator, for locally
generated packets. This match is only valid in the OUTPUT and POSTROUTING
chains. Forwarded packets do not have any socket associated with them.
Packets from kernel threads do have a socket, but usually no owner.
2020-03-26 12:21:24 -07:00
gVisor bot 01ac53099f Merge pull request #2254 from kevinGC:container-timeout
PiperOrigin-RevId: 303159175
2020-03-26 11:42:15 -07:00
gVisor bot f5fbe859ed Merge pull request #2177 from xiaobo55x:sysret_test
PiperOrigin-RevId: 303158421
2020-03-26 11:37:45 -07:00
Jay Zhuang d5ef8091b4 Add IPv4 to bind_to_device distribution test
PiperOrigin-RevId: 303156734
2020-03-26 11:33:28 -07:00
Kevin Krakauer bc3def43c3 Check error in DropTCP*Port tests and fix comment.
PiperOrigin-RevId: 303147253
2020-03-26 10:47:51 -07:00
Jay Zhuang c64796748c Clean up transport_demuxer.go and test
- Change receiver of endpoint lookup functions
- Remove unused struct fields and functions in test
- s/%v/%s/ for errors
- Capitalize NIC
  https://github.com/golang/go/wiki/CodeReviewComments#initialisms

PiperOrigin-RevId: 303119580
2020-03-26 08:50:17 -07:00
gVisor bot 7aa388ce74 Merge pull request #1986 from lubinszARM:pr_ring0_clean_1
PiperOrigin-RevId: 303105826
2020-03-26 08:49:12 -07:00
Fabricio Voznika de694e5484 Combine file mode and isDir arguments
Updates #1035

PiperOrigin-RevId: 303021328
2020-03-26 08:48:04 -07:00
Kevin Krakauer 4f374da60c iptable: fix tests timeouts
Tests were run assuming a runtime of "runsc" was present, and did not
have --net-raw enabled.
2020-03-25 20:37:48 -07:00