Commit Graph

599 Commits

Author SHA1 Message Date
Zach Koopmans df8740b8a7 Mark gettid and getdents as nogotsan
PiperOrigin-RevId: 297915815
2020-02-28 13:22:35 -08:00
Ting-Yu Wang 6b4d36e325 Hide /dev/net/tun when using hostinet.
/dev/net/tun does not currently work with hostinet. This has caused some
program starts failing because it thinks the feature exists.

PiperOrigin-RevId: 297876196
2020-02-28 10:39:12 -08:00
Bin Lu dd1ed5c789 skip vsyscall test cases on Arm64
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-02-28 14:47:50 +08:00
Nayana Bidari abf7ebcd38 Internal change.
PiperOrigin-RevId: 297638665
2020-02-27 11:00:41 -08:00
Jay Zhuang de0b2ebf86 Add getsockopt tests for SO_SNDTIMEO and SO_RCVTIMEO
PiperOrigin-RevId: 297485310
2020-02-26 18:17:23 -08:00
Kevin Krakauer 408979e619 iptables: filter by IP address (and range)
Enables commands such as:
$ iptables -A INPUT -d 127.0.0.1 -j ACCEPT
$ iptables -t nat -A PREROUTING ! -d 127.0.0.1 -j REDIRECT

Also adds a bunch of REDIRECT+destination tests.
2020-02-26 11:04:00 -08:00
nybidari 818abc2bd5
Merge branch 'master' into iptables 2020-02-25 15:33:59 -08:00
Nayana Bidari acc405ba60 Add nat table support for iptables.
- commit the changes for the comments.
2020-02-25 15:03:51 -08:00
Adin Scannell 160d5751ab Add default behavior for gtest runner.
PiperOrigin-RevId: 297009116
2020-02-24 17:29:34 -08:00
gVisor bot 93626a28e4 Merge pull request #1886 from avagin:arm64-travis-ci
PiperOrigin-RevId: 296975376
2020-02-24 14:34:13 -08:00
Andrei Vagin 75d7f76a6c arm64: add a travis build ci
Build runsc and run "runsc do ls".

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-02-21 22:44:19 -08:00
Ting-Yu Wang b8f56c79be Implement tap/tun device in vfs.
PiperOrigin-RevId: 296526279
2020-02-21 15:42:56 -08:00
Adin Scannell 10aa4d3b34 Factor platform tags.
PiperOrigin-RevId: 296519566
2020-02-21 15:06:08 -08:00
gVisor bot 4a73bae269 Initial network namespace support.
TCP/IP will work with netstack networking. hostinet doesn't work, and sockets
will have the same behavior as it is now.

Before the userspace is able to create device, the default loopback device can
be used to test.

/proc/net and /sys/net will still be connected to the root network stack; this
is the same behavior now.

Issue #1833

PiperOrigin-RevId: 296309389
2020-02-20 15:20:40 -08:00
Adin Scannell 30794512d3 Add basic microbenchmarks.
PiperOrigin-RevId: 296104390
2020-02-19 18:21:54 -08:00
gVisor bot 55c99ce106 Include more test files in exports_files
So that they can be included by Fuchsia's syscall tests

PiperOrigin-RevId: 296030383
2020-02-19 12:32:44 -08:00
gVisor bot 56fd9504aa Enable IPV6_RECVTCLASS socket option for datagram sockets
Added the ability to get/set the IP_RECVTCLASS socket option on UDP endpoints.
If enabled, traffic class from the incoming Network Header passed as ancillary
data in the ControlMessages.

Adding Get/SetSockOptBool to decrease the overhead of getting/setting simple
options. (This was absorbed in a CL that will be landing before this one).

Test:
* Added unit test to udp_test.go that tests getting/setting as well as
verifying that we receive expected TOS from incoming packet.
* Added a syscall test for verifying getting/setting
* Removed test skip for existing syscall test to enable end to end test.
PiperOrigin-RevId: 295840218
2020-02-18 15:45:36 -08:00
gVisor bot 247843bbc5 iptables: use "-t nat" for NAT tests
PiperOrigin-RevId: 295835807
2020-02-18 15:25:51 -08:00
gVisor bot c841373013 Deflake fallocate syscall test.
- Retry if fallocate returns EINTR.

- If fallocate fails, don't try to fstat and confirm the result.

PiperOrigin-RevId: 295789790
2020-02-18 12:02:05 -08:00
gVisor bot 7fdb609b3e Merge pull request #1850 from kevinGC:jump2
PiperOrigin-RevId: 295785052
2020-02-18 11:41:54 -08:00
Nayana Bidari b30b7f3422 Add nat table support for iptables.
Add nat table support for Prerouting hook with Redirect option.
Add tests to check redirect of ports.
2020-02-18 11:30:42 -08:00
Kevin Krakauer 6ef63cd7da We can now create and jump in iptables. For example:
$ iptables -N foochain
$ iptables -A INPUT -j foochain
2020-02-13 17:02:50 -08:00
gVisor bot 16308b9dc1 Merge pull request #1791 from kevinGC:uchains
PiperOrigin-RevId: 294957297
2020-02-13 11:19:09 -08:00
gVisor bot 69bf39e8a4 Internal change.
PiperOrigin-RevId: 294952610
2020-02-13 10:59:52 -08:00
Kevin Krakauer 6fdf2c53a1 iptables: User chains
- Adds creation of user chains via `-N <chainname>`
- Adds `-j RETURN` support for built-in chains, which triggers the
  chain's underflow rule (usually the default policy).
- Adds tests for chain creation, default policies, and `-j RETURN' from
  built-in chains.
2020-02-12 15:02:47 -08:00
gVisor bot 46a36b64d5 Include more test files in exports_files
So that they can be included by Fuchsia's syscall tests

PiperOrigin-RevId: 294654890
2020-02-12 06:36:43 -08:00
gVisor bot e07eacc99f Fix up test/runtimes/README.md.
In particular, explain how to push updates to the images.

PiperOrigin-RevId: 294508879
2020-02-11 13:38:45 -08:00
Adin Scannell 0efa8168c7 Update visibility.
PiperOrigin-RevId: 294265019
2020-02-10 11:30:21 -08:00
Kevin Krakauer 31f2182cd3 iptables: add instructions for runsc building.
The readme didn't mention that users need to:
- `bazel build` when working on iptables tests
- enable raw sockets in /etc/docker/daemon.json.

PiperOrigin-RevId: 294260169
2020-02-10 11:09:19 -08:00
Zach Koopmans 75412ed9f5 Internal change.
PiperOrigin-RevId: 294250370
2020-02-10 10:29:57 -08:00
Dean Deng 17b9f5e662 Support listxattr and removexattr syscalls.
Note that these are only implemented for tmpfs, and other impls will still
return EOPNOTSUPP.

PiperOrigin-RevId: 293899385
2020-02-07 14:47:13 -08:00
Jay Zhuang 6de49546cb Refactor syscall tests
- Move shared helpers V4Multicast and V4Broadcast to socket_test_util
- Add unnamed namespace so socket_ipv4_tcp_unbound_external_networking_test.cc
  and socket_ipv4_udp_unbound_external_networking_test.cc can be compiled
  together
- Add test files to "exports_files" so they can be included by Fuchsia's syscall
  test setup

PiperOrigin-RevId: 293880429
2020-02-07 13:19:18 -08:00
Kevin Krakauer bfa4a235f4 Fix `bazel run` target in docs.
PiperOrigin-RevId: 293676954
2020-02-06 14:27:31 -08:00
Adin Scannell 0e96fcafd4 Fix test case on AMD.
When ignored, the trap should be executed which generates
a SIGSEGV as in the above case.

PiperOrigin-RevId: 293618489
2020-02-06 10:12:16 -08:00
Adin Scannell 1b6a12a768 Add notes to relevant tests.
These were out-of-band notes that can help provide additional context
and simplify automated imports.

PiperOrigin-RevId: 293525915
2020-02-05 22:46:35 -08:00
Eyal Soha f3d9560703 recv() on a closed TCP socket returns ENOTCONN
From RFC 793 s3.9 p58 Event Processing:

If RECEIVE Call arrives in CLOSED state and the user has access to such a
connection, the return should be "error: connection does not exist"

Fixes #1598

PiperOrigin-RevId: 293494287
2020-02-05 17:56:42 -08:00
Nicolas Lacasse eea0eeee93 Disable get/set xattrs until list/remove exist too.
PiperOrigin-RevId: 293411655
2020-02-05 11:26:19 -08:00
Eyal Soha 37abbbc547 Add packetdrill tests to presubmit and CI testing
PiperOrigin-RevId: 293409718
2020-02-05 11:18:02 -08:00
Ting-Yu Wang 665b614e4a Support RTM_NEWADDR and RTM_GETLINK in (rt)netlink.
PiperOrigin-RevId: 293271055
2020-02-04 18:05:03 -08:00
gVisor bot b29aeebaf6 Merge pull request #1683 from kevinGC:ipt-udp-matchers
PiperOrigin-RevId: 293243342
2020-02-04 16:20:16 -08:00
Ian Gudger a26a954946 Add socket connection stress test.
Tests 65k connection attempts on common types of sockets to check for port
leaks.

Also fixes a bug where dual-stack sockets wouldn't properly re-queue
segments received while closing.

PiperOrigin-RevId: 293241166
2020-02-04 15:54:49 -08:00
Michael Pratt 6823b5e244 timer_create(2) should return 0 on success
The timer ID is copied out to the argument.

Fixes #1738

PiperOrigin-RevId: 293210801
2020-02-04 13:27:39 -08:00
Jay Zhuang c5d4041623 Include socket_ip_udp_loopback.cc in exportes_files
So it can be included in fuchsia's syscall tests

PiperOrigin-RevId: 293208306
2020-02-04 13:13:10 -08:00
Fabricio Voznika d7cd484091 Add support for sentry internal pipe for gofer mounts
Internal pipes are supported similarly to how internal UDS is done.
It is also controlled by the same flag.

Fixes #1102

PiperOrigin-RevId: 293150045
2020-02-04 08:20:52 -08:00
Ting-Yu Wang e7846e50f2 Reduce run time for //test/syscalls:socket_inet_loopback_test_runsc_ptrace.
* Tests are picked for a shard differently. It now picks one test from each
  block, instead of picking the whole block. This makes the same kind of tests
  spreads across different shards.

* Reduce the number of connect() calls in TCPListenClose.

PiperOrigin-RevId: 293019281
2020-02-03 15:42:21 -08:00
Eyal Soha 9742daf3c2 Add packetdrill tests that use docker.
PiperOrigin-RevId: 292973224
2020-02-03 12:04:22 -08:00
Adin Scannell 04cccaaeee Fix logic around AMD/Intel cases.
If the support is Ignored, then the call is still executed. We
simply rely on it to fall through to the int3. Therefore, we
must also bail on the vendor check.

PiperOrigin-RevId: 292620558
2020-01-31 14:45:47 -08:00
Ting-Yu Wang 7c118f7e19 KVM platform does not support 32bit.
Fixes: //test/syscalls:32bit_test_runsc_kvm
Ref change: 5d569408ef
PiperOrigin-RevId: 292563926
2020-01-31 10:07:45 -08:00
Adin Scannell 14959250fe Simplify testing link rules.
PiperOrigin-RevId: 292458933
2020-01-30 17:49:17 -08:00
gVisor bot af8f6f83a3 Merge pull request #1471 from xiaobo55x:syscall_test
PiperOrigin-RevId: 292445329
2020-01-30 16:12:25 -08:00
Jay Zhuang 9988cf2eef Wrap all GetSocketPairs() in unnamed namespaces
This avoids conflicting definitions of GetSocketPairs() in outer namespace when
multiple such cc files are complied for one binary.

PiperOrigin-RevId: 292420885
2020-01-30 14:17:58 -08:00
gVisor bot d62362f63f Merge pull request #1630 from xiaobo55x:kOLargeFile
PiperOrigin-RevId: 292419699
2020-01-30 14:03:22 -08:00
Bhasker Hariharan 4ee64a248e Fix for panic in endpoint.Close().
When sending a RST on shutdown we need to double check the
state after acquiring the work mutex as the endpoint could
have transitioned out of a connected state from the time
we checked it and we acquired the workMutex.

I added two tests but sadly neither reproduce the panic. I am
going to leave the tests in as they are good to have anyway.

PiperOrigin-RevId: 292393800
2020-01-30 12:00:35 -08:00
Michael Pratt ede8dfab37 Enforce splice offset limits
Splice must not allow negative offsets. Writes also must not allow offset +
size to overflow int64. Reads are similarly broken, but not just in splice
(b/148095030).

Reported-by: syzbot+0e1ff0b95fb2859b4190@syzkaller.appspotmail.com
PiperOrigin-RevId: 292361208
2020-01-30 09:14:31 -08:00
Kevin Krakauer 0ade523f06 Fix iptables tests that were broken by rename.
The name of the runner binary target changed from "runner" to "runner-image",
causing iptables tests to fail.

PiperOrigin-RevId: 292242263
2020-01-29 16:27:12 -08:00
Bhasker Hariharan 51b783505b Add support for TCP_DEFER_ACCEPT.
PiperOrigin-RevId: 292233574
2020-01-29 15:53:45 -08:00
Andrei Vagin f263801a74 fs/splice: don't report partial errors for special files
Special files can have additional requirements for granularity.
For example, read from eventfd returns EINVAL if a size is less 8 bytes.

Reported-by: syzbot+3905f5493bec08eb7b02@syzkaller.appspotmail.com
PiperOrigin-RevId: 292002926
2020-01-28 13:37:19 -08:00
Jianfeng Tan d99329e584 netlink: add support for RTM_F_LOOKUP_TABLE
Test command:
  $ ip route get 1.1.1.1

Fixes: #1099

Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/1121 from tanjianfeng:fix-1099 e6919f3d4ede5aa51a48b3d2be0d7a4b482dd53d
PiperOrigin-RevId: 291990716
2020-01-28 12:32:59 -08:00
Michael Pratt 76483b8b1e Check sigsetsize in rt_sigaction
This isn't in the libc wrapper, but it is in the syscall itself.

Discovered by @xiaobo55x in #1625.

PiperOrigin-RevId: 291973931
2020-01-28 11:26:09 -08:00
Michael Pratt 74e04506a4 Prefer Type& over Type &
And Type* over Type *. This is basically a whitespace only change.

gVisor code already prefers left-alignment of pointers and references, but
clang-format formats for consistency with the majority of a file, and some
files leaned the wrong way. This is a one-time pass to make us completely
conforming.

Autogenerated with:

$ find . \( -name "*.cc" -or -name "*.c" -or -name "*.h" \) \
    | xargs clang-format -i -style="{BasedOnStyle: Google,  \
        DerivePointerAlignment: false, PointerAlignment: Left}"

PiperOrigin-RevId: 291972421
2020-01-28 11:18:17 -08:00
Adin Scannell 5d569408ef Create platform_util for tests.
PiperOrigin-RevId: 291869423
2020-01-27 22:28:43 -08:00
Adin Scannell 5776a7b6f6 Fix header ordering and format all C++ code.
PiperOrigin-RevId: 291844200
2020-01-27 18:27:20 -08:00
Dean Deng 13c1f38dfa Update bug number for supporting extended attribute namespaces.
PiperOrigin-RevId: 291774815
2020-01-27 12:50:18 -08:00
Kevin Krakauer 29316e66ad Cleanup for GH review. 2020-01-27 12:27:04 -08:00
Adin Scannell d29e59af9f Standardize on tools directory.
PiperOrigin-RevId: 291745021
2020-01-27 12:21:00 -08:00
Kevin Krakauer 7636478a31 Merge branch 'master' into ipt-udp-matchers 2020-01-24 10:42:43 -08:00
gVisor bot 3d10edc942 Merge pull request #1617 from kevinGC:iptables-write-filter-proto
PiperOrigin-RevId: 291249314
2020-01-23 14:48:39 -08:00
Haibo Xu 49e84b10e5 Unify the kOLargeFile definition in syscall tests.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: Id9d6ae98305a4057d55d622ea4c3ac2228fea212
2020-01-23 01:04:02 +00:00
gVisor bot 8a5bfd7001 Merge pull request #1629 from xiaobo55x:fault_test
PiperOrigin-RevId: 291022423
2020-01-22 13:51:13 -08:00
Nicolas Lacasse 159992300d Toolchain version bumps.
- bazel_toolchain to 2.0.2
- rules_go to 0.21.0
- Go toolchain to 1.13.6
- Use new proto lib archive.

PiperOrigin-RevId: 290999410
2020-01-22 11:52:38 -08:00
Haibo Xu d59a3cc959 Enable fault() syscall test on arm64.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I9b2b2e0d84946c10cf136abeef6c60642fa3b6ec
2020-01-22 06:57:19 +00:00
Adin Scannell 2296b47344 Change to standard types.
PiperOrigin-RevId: 290846481
2020-01-21 17:28:57 -08:00
gVisor bot 45a8edbd5a Merge pull request #1492 from majek:err_typo_in_netstack_tests
PiperOrigin-RevId: 290840370
2020-01-21 16:32:49 -08:00
Kevin Krakauer 9143fcd7fd Add UDP matchers. 2020-01-21 14:47:17 -08:00
Ryan Heacock cbc0a92276 Correct todos referencing IPV6_RECVTCLASS
Bug 68320120 was revived because TODOs referenced the IP_RECVTOS bug instead
of the IPV6_RECVTCLASS bug.

PiperOrigin-RevId: 290820178
2020-01-21 14:22:06 -08:00
Kevin Krakauer 9f736ac6a7 More little fixes. 2020-01-21 13:42:43 -08:00
Kevin Krakauer 47bc7550c0 Fixing stuff 2020-01-21 13:37:25 -08:00
Kevin Krakauer 62357a0afb Merge branch 'master' into iptables-write-filter-proto 2020-01-21 13:16:25 -08:00
Dean Deng 2ba6198851 Add syscalls for lgetxattr, fgetxattr, lsetxattr, and fsetxattr.
Note that these simply will use the same logic as getxattr and setxattr, which
is not yet implemented for most filesystems.

PiperOrigin-RevId: 290800960
2020-01-21 12:43:18 -08:00
gVisor bot 5f82f092e7 Merge pull request #1558 from kevinGC:iptables-write-input-drop
PiperOrigin-RevId: 290793754
2020-01-21 12:08:52 -08:00
gVisor bot 7e155a133b Merge pull request #1546 from lubinszARM:pr_syscall_test_proc
PiperOrigin-RevId: 290789087
2020-01-21 11:42:41 -08:00
Andrei Vagin 9073521098 Convert EventMask to uint64
It is used for signalfd where the maximum signal is 64.

PiperOrigin-RevId: 290331008
2020-01-17 13:32:51 -08:00
gVisor bot c98e1bc23f Merge pull request #1459 from lubinszARM:pr_save_util
PiperOrigin-RevId: 290273702
2020-01-17 09:08:47 -08:00
gVisor bot 989b611f5a Merge pull request #1541 from nybidari:iptables
PiperOrigin-RevId: 290273561
2020-01-17 08:38:25 -08:00
Haibo Xu 82ae857877 Enable build of test/syscall tests on arm64.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I277d6c708bbf5c3edd7c3568941cfd01dc122e17
2020-01-17 07:39:57 +00:00
Dean Deng c50efc8c70 Disable xattr tests.
These can remain disabled until we actually support extended attributes.

The following modifications were also made:
1. Disable save/restore on tests that change file permissions. Restore will not
work properly for these tests, since it will try to open the file with
read-write after it has been read- or write-only.
2. Change user.abc to user.test.

PiperOrigin-RevId: 290123941
2020-01-16 13:11:47 -08:00
Bhasker Hariharan a611fdaee3 Changes TCP packet dispatch to use a pool of goroutines.
All inbound segments for connections in ESTABLISHED state are delivered to the
endpoint's queue but for every segment delivered we also queue the endpoint for
processing to a selected processor. This ensures that when there are a large
number of connections in ESTABLISHED state the inbound packets are all handled
by a small number of goroutines and significantly reduces the amount of work the
goscheduler has to perform.

We let connections in other states follow the current path where the
endpoint's goroutine directly handles the segments.

Updates #231

PiperOrigin-RevId: 289728325
2020-01-14 14:15:50 -08:00
Tamir Duberstein 50625cee59 Implement {g,s}etsockopt(IP_RECVTOS) for UDP sockets
PiperOrigin-RevId: 289718534
2020-01-14 13:33:23 -08:00
Kevin Krakauer d51eaa59c0 Merge branch 'iptables-write-input-drop' into iptables-write-filter-proto 2020-01-13 16:06:29 -08:00
Tamir Duberstein debd213da6 Allow dual stack sockets to operate on AF_INET
Fixes #1490
Fixes #1495

PiperOrigin-RevId: 289523250
2020-01-13 14:47:22 -08:00
Kevin Krakauer 31e49f4b19 Merge branch 'master' into iptables-write-input-drop 2020-01-13 12:22:15 -08:00
Andrei Vagin f54b9c0ee6 tests: fix errors detected by asan.
PiperOrigin-RevId: 289467083
2020-01-13 10:16:07 -08:00
Nayana Bidari 98327a94cc Add test for iptables TCP rule
Added tests for tcp protocol with input and output rules including options sport and dport
Increased timeout in iptables_test as TCP tests were timing out with existing value.
2020-01-13 09:11:40 -08:00
Brad Burlage bf6429b944 Don't set RWF_HIPRI on InvalidOffset test.
This test fails on ubuntu 18.04 because preadv2 for some reason returns
EOPNOTSUPP instead of EINVAL. Instead of root-causing the failure, I'm dropping
the flag in the preadv2 call since it isn't under test in this scenario.

PiperOrigin-RevId: 289188358
2020-01-10 16:36:34 -08:00
Nayana Bidari 9aeb053bba Add tests for redirect port
Fix indentation and change function names.
2020-01-10 09:05:25 -08:00
Bin Lu ebd25099bf enable //test/syscalls:proc_test support on Arm64
Problems with different platform architectures have been solved.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-01-10 16:45:48 +08:00
Bhasker Hariharan 356d81146b Deflake a couple of TCP syscall tests when run under gotsan.
PiperOrigin-RevId: 289010316
2020-01-09 17:58:48 -08:00
Nayana Bidari 04abc9cf55 Add test for redirect port
Fix the indentation and print statements.
Moved the NAT redirect tests to new file.
Added negative test to check redirect rule on ports other than
redirected port.
2020-01-09 15:38:28 -08:00
Kevin Krakauer 89d11b4d96 Added a test that we don't pass yet 2020-01-09 13:41:52 -08:00
Nayana Bidari 6cc8e2d814 Add test to check iptables redirect port rule 2020-01-09 10:24:26 -08:00