Commit Graph

2749 Commits

Author SHA1 Message Date
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
gVisor bot ce0a69ea97 Merge pull request #2238 from amscanne:nogo
PiperOrigin-RevId: 303010530
2020-03-25 17:55:14 -07:00
Adin Scannell 882ed330e6 nogo: enable sanitizers.
This enables all relevant santizers (though most analyzers will not find
much, it will prevent instances from creeping in), and codifies existing
exceptions in tools/nogo.js to be fixed.
2020-03-25 16:21:27 -07:00
Adin Scannell d440fe0613 Fix go_marshal Example name.
There is a canonical naming convention for Examples, which are checked
by analyzers. This must be fixed since adding exceptions for generated
code will be more challenging.
2020-03-25 16:18:05 -07:00
gVisor bot 3afbe5461a Merge pull request #2151 from xiaobo55x:seccomp_test
PiperOrigin-RevId: 302987344
2020-03-25 15:59:53 -07:00
Fabricio Voznika 5f03dca522 Fix race in TestRunEnvHasHome
It's possible to execute the command that checks user's
$HOME dir before the user is created. Move the code that
creates the user inside exec so it can be serialized.

PiperOrigin-RevId: 302986184
2020-03-25 15:58:45 -07:00
Fabricio Voznika f2eba94015 Remove TODO to push down exec permission check
Pushing it down requires all implementation to check for
exec individualy which is not maintanable. Making it part
of GenericCheckPermissions add extra cost to everyone that
calls it. So it's better to keep is in
VirtualFilesystem.OpenAt.

Updates #1193

PiperOrigin-RevId: 302982993
2020-03-25 15:57:37 -07:00
Fabricio Voznika e541ebec2f Misc fixes to make stat_test pass (almost)
The only test failing now requires socket which is not
available in VFS2 yet.

Updates #1198

PiperOrigin-RevId: 302976572
2020-03-25 14:59:15 -07:00
Fabricio Voznika c7f5673529 Set file mode and type to attribute
Makes less error prone to find file type.

Updates #1197

PiperOrigin-RevId: 302974244
2020-03-25 14:49:13 -07:00
Andrei Vagin 2e09f2bdce travis: exclude copybara branches
When copybara migrates changes, it creates a new branch and then creates a
pull-requests which is based on this branch. In this case, travis-ci
triggers build twice for the branch and for the pull-request.

PiperOrigin-RevId: 302930634
2020-03-25 11:21:34 -07:00
Jamie Liu e7fbf69495 Fix futex_benchmark.
- Fix definitions of Futex* wrappers.

- Correctly handle glibc syscall() (which returns -1 and sets errno instead of
  returning the raw syscall return value).

- De-parameterize FutexWaitBitset, which was apparently intended to test with
  deadlines of between 0 and 100000 nanoseconds after the Unix epoch, but was
  broken due to the preceding two issues.

- Use wall time to measure the durations of tests that are expected to block
  (and thus stop accumulating CPU time).

- Require 5s for all tests to improve robustness in the presence of sentry GC.

- Remove FutexContend and FutexContendDeadline; it's unclear what these are
  supposed to measure, given that (1) FutexLock is unrealistically inefficient
  and (2) the benchmark rewards slow scheduling (since this reduces
  contention).

PiperOrigin-RevId: 302925246
2020-03-25 10:59:39 -07:00
Bhasker Hariharan d04adebaab Fix data-race in endpoint.Readiness
PiperOrigin-RevId: 302924789
2020-03-25 10:55:22 -07:00