Commit Graph

1504 Commits

Author SHA1 Message Date
Jamie Liu 9c09db654e Fix async-signal-unsafety in chroot test.
PiperOrigin-RevId: 384295543
2021-07-12 12:49:48 -07:00
Jamie Liu fbd4ccf333 Fix async-signal-unsafety in socket test.
PiperOrigin-RevId: 383689096
2021-07-08 12:26:56 -07:00
Ayush Ranjan add8bca5ba [op] Make TCPNonBlockingConnectClose more reasonable.
This test single handedly causes the syscalls:socket_inet_loopback_test test
variants to take more than an hour to run on some of our testing environments.

Reduce how aggressively this test tries to replicate a fixed flake. This is a
regression test.

PiperOrigin-RevId: 382849039
2021-07-02 18:47:48 -07:00
Bhasker Hariharan 570ca57180 Fix bug with TCP bind w/ SO_REUSEADDR.
In gVisor today its possible that when trying to bind a TCP socket
w/ SO_REUSEADDR specified and requesting the kernel pick a port by
setting port to zero can result in a previously bound port being
returned. This behaviour is incorrect as the user is clearly requesting
a free port. The behaviour is fine when the user explicity specifies
a port.

This change now checks if the user specified a port when making a port
reservation for a TCP port and only returns unbound ports even if
SO_REUSEADDR was specified.

Fixes #6209

PiperOrigin-RevId: 382607638
2021-07-01 14:42:00 -07:00
gVisor bot 3e5a6981d6 Merge pull request #6085 from liornm:fix-tun-no_pi
PiperOrigin-RevId: 382202462
2021-06-29 17:54:17 -07:00
Lucas Manning 90dbb4b0c7 Add SIOCGIFFLAGS ioctl support to hostinet.
PiperOrigin-RevId: 382194711
2021-06-29 17:01:11 -07:00
liornm ddbc273659 Fix TUN IFF_NO_PI bug
When TUN is created with IFF_NO_PI flag, there will be no Ethernet header and no packet info, therefore, both read and write will fail. 

This commit fix this bug.
2021-06-29 10:51:58 +03:00
Kevin Krakauer 2cbd82c0d6 code quality: cleanup lint messages
dns

PiperOrigin-RevId: 381949375
2021-06-28 14:43:39 -07:00
Kevin Krakauer 27cc5a883a check explicitly that AF_PACKET sockets can't write in gVisor
PiperOrigin-RevId: 381896875
2021-06-28 10:40:55 -07:00
Tamir Duberstein 4feb9187bb [tcp_info_test] Increase retransmission timeout
PiperOrigin-RevId: 381515399
2021-06-25 11:46:14 -07:00
Tamir Duberstein c689c36c78 [tcp_info_test] Remove %v
PiperOrigin-RevId: 381508674
2021-06-25 11:13:01 -07:00
Etienne Perot 4470caec4e Run `:socket_inet_loopback_isolated_test_linux` tests in a container.
This creates new user and network namespaces for all tests in
`:socket_inet_loopback_isolated_test_linux`.

PiperOrigin-RevId: 381374120
2021-06-24 17:49:09 -07:00
Jamie Liu 6b23d2a08e Fix PR_SET_PTRACER applicability to non-leader threads.
Compare

	if (!thread_group_leader(tracee))
		tracee = rcu_dereference(tracee->group_leader);

in security/yama/yama_lsm.c:ptracer_exception_found().

PiperOrigin-RevId: 381074242
2021-06-23 11:17:44 -07:00
Bhasker Hariharan e5fe488b22 Wake up Writers when tcp socket is shutdown for writes.
PiperOrigin-RevId: 380967023
2021-06-22 23:41:29 -07:00
Etienne Perot 62efdf29d8 `socket_inet_loopback`: Split off tests that need isolation in their own file.
This allows these tests, which can cause flakiness when run in the same network
namespace as the other `socket_inet_loopback` tests, to run as separate tests
in their own environment. It also means that all of the shards of those tests
can be more isolated from each other as well.

PiperOrigin-RevId: 380930198
2021-06-22 17:53:37 -07:00
Tamir Duberstein ddfdc9827b Remove timeouts
These aren't useful and create opportunities for flakes.

PiperOrigin-RevId: 380889223
2021-06-22 14:12:55 -07:00
Ian Lewis 04a81bc336 Trigger poll/epoll events on zero-length hostinet sendmsg
Fixes #2726

PiperOrigin-RevId: 380753516
2021-06-22 01:10:24 -07:00
Kevin Krakauer c6da1b0022 clean up tcpdump TODOs
tcpdump is largely supported. We've also chose not to implement writeable
AF_PACKET sockets, and there's a bug specifically for promiscuous mode (#3333).

Fixes #173.

PiperOrigin-RevId: 380733686
2021-06-21 22:16:11 -07:00
Kevin Krakauer 0f5c1f5eaf raw sockets: don't overwrite destination address
Also makes the behavior of raw sockets WRT fragmentation clearer, and makes the
ICMPv4 header-length check explicit.

Fixes #3160.

PiperOrigin-RevId: 380033450
2021-06-17 13:35:29 -07:00
Kevin Krakauer 34152da7e5 Fix broken hdrincl test
Fixes #3159.

PiperOrigin-RevId: 379814096
2021-06-16 14:43:10 -07:00
Kevin Krakauer 488ba4176e Deflake SocketInetLoopbackTest.TCPBacklog
The value can be off by one depending on the kernel we're running.

Tested with --runs_per_test=1000.

PiperOrigin-RevId: 379535390
2021-06-15 11:33:01 -07:00
Kevin Krakauer 20c6816045 Cleanup lint messages
PiperOrigin-RevId: 379380041
2021-06-14 17:17:34 -07:00
Zach Koopmans 397a59fc95 Remove debug lines from exec.cc
PiperOrigin-RevId: 379298590
2021-06-14 09:52:02 -07:00
Zach Koopmans b92e8ee8d6 Fix //test/syscalls:exec_test_native
Later kernels add empty arguments to argv, throwing off return values for the
exec_basic_workload.cc binary. This is result of a bug introduced by
ccbb18b67323b "exec/binfmt_script: Don't modify bprm->buf and then return -
ENOEXEC". Before this change, an empty interpreter string was reported if the
first non-space/non-tab character after "#!" was '\0' (end of file, previously-
overwritten trailing space or tab, or previously-overwritten first newline).
After this change, an empty interpreter string is reported if all characters
after "#!" are spaces or tabs, or the first non-space non-tab character is at
i_end, which is the position of the first newline after "#!". However, if
there is no newline after "#!" (as in ExecTest.InterpreterScriptNoPath),
then i_end = buf_end (= bprm->buf + sizeof(bprm->buf) - 1, the last possible
byte in the buffer) and neither condition holds.

Change white space for script inputs to take into account the above bug.

Co-authored-by: Andrei Vagin <avagin@gmail.com>
PiperOrigin-RevId: 378997171
2021-06-11 20:33:58 -07:00
Andrei Vagin 3c63fce628 Temorary skip test cases that fail on Linux
PiperOrigin-RevId: 378974239
2021-06-11 16:47:52 -07:00
Zach Koopmans c3326c440a [benchmarks] Fix redis benchmark.
Intermittenly, the connection between the client redis_benchmark container can be
flaky with the server, even if the server has been up for a long time. If this
happens, just re-run a client until we get a result.

Also, don't start a new server for each operation.

Also also, modify Makefile run-benchmark call to accept RUNTIME=runc correctly.

PiperOrigin-RevId: 378918886
2021-06-11 11:56:15 -07:00
Mithun Iyer 3c91fa42ae Try to avoid accept, incoming ACK race
This test checks if an incoming ACK is dropped by the listener when the
accept queue is full. The ACK receive handling could race with the test
invoking accept on the DUT, causing the test to be flaky. Add a wait
time before invoking accept on the DUT to give cycles for the incoming
ACK to be handled/dropped by the listener.

PiperOrigin-RevId: 378770225
2021-06-10 17:23:34 -07:00
Jamie Liu 0058fca32e Disable all tests dependent on cloud_gvisor::testing::FuseTest.
PiperOrigin-RevId: 378753134
2021-06-10 15:54:34 -07:00
Fabricio Voznika 21169357ca Add /proc/sys/vm/max_map_count
Set it to int32 max because gVisor doesn't have a limit.

Fixes #2337

PiperOrigin-RevId: 378722230
2021-06-10 13:36:03 -07:00
gVisor bot c867c5526d Merge pull request #6103 from sudo-sturbia:semaphore-err
PiperOrigin-RevId: 378607458
2021-06-10 02:39:40 -07:00
Nicolas Lacasse 3fb646ed10 Rename go files that contain "main" function to main.go.
This is a good Go convention that we should follow.

PiperOrigin-RevId: 378538679
2021-06-09 17:36:51 -07:00
Nicolas Lacasse 539fe2b61a Remove unnecessary TODO bug.
The bug id was not adding anything relevant here

PiperOrigin-RevId: 378485983
2021-06-09 13:36:23 -07:00
Andrei Vagin b3a44bfab8 test: use std::vector instead of allocating memory with calloc
A memory that is allocated with calloc has to be freed.

PiperOrigin-RevId: 378001409
2021-06-07 14:11:30 -07:00
Jamie Liu ee1003bde2 Implement RENAME_NOREPLACE for all VFS2 filesystem implementations.
PiperOrigin-RevId: 377966969
2021-06-07 11:42:34 -07:00
Mithun Iyer 03f17c7d90 Honor data and FIN from the ACK completing handshake
If the ACK completing the handshake has FIN or data, requeue the segment
for further processing by the newly established endpoint. Otherwise,
the segments would have to be retransmitted by the peer to be processed
by the established endpoint. Doing this, keeps the behavior in parity
with Linux.

This also addresses a test flake with TCPNonBlockingConnectClose where
the ACK (completing the handshake) and multiple retransmitted FINACKs
from the peer could be dropped by the listener, when using syncookies
and the accept queue is full. The handshake could eventually get
completed with a retransmitted FINACK, without actual processing of
FIN. This can cause the poll with POLLRDHUP on the accepted socket to
sometimes time out before the next FINACK retransmission.

PiperOrigin-RevId: 377651695
2021-06-04 23:39:44 -07:00
Sam Balana a2d3407396 Forward verbose flag to packetimpact tester
Forwards the testing verbose flag to the packetimpact test runner. This is
necessary for debugging inside packetimpact tests. When this flag is present,
all t.Logs in the packetimpact test wil be shown in the resulting test output.

PiperOrigin-RevId: 377614550
2021-06-04 16:47:50 -07:00
Sam Balana a2c88252c8 Allow sniffer receive timeout durations less than one usec
Fixes the erronously signaled fatal error when the sniffer receive timeout
duration is less than one usec. This was caused by the converstion from float64
to int64; the integer conversion truncated the floating point to 0, which
signaled the fatal error.

PiperOrigin-RevId: 377600179
2021-06-04 15:19:53 -07:00
Sam Balana 2406295249 Add bind syscall tests for ICMP and ICMPv6
Updates #5711
Updates #6021
Updates #6022

PiperOrigin-RevId: 377582446
2021-06-04 13:53:17 -07:00
Adam Barth ddcd17399b Reset global_num_signals_received on RegisterSignalHandler
Previously, the value of global_num_signals_received would persist between
tests. Now, we reset the value to zero when we register a signal handler.

PiperOrigin-RevId: 377308357
2021-06-03 09:47:24 -07:00
Mithun Iyer 9357b4f7eb Ensure full shutdown of endpoint on notifyClose
Address a race with non-blocking connect and socket close, causing the
FIN (because of socket close) to not be sent out, even after completing
the handshake.

The race occurs with this sequence:
(1) endpoint Connect starts handshake, sending out SYN
(2) handshake complete() releases endpoint lock, waiting on sleeper.Fetch()
(3) endpoint Close acquires endpoint lock, does not enqueue FIN (as the
    endpoint is not yet connected) and asserts notifyClose
(4) SYNACK from peer gets enqueued asserting newSegmentWaker
(5) handshake complete() re-aqcuires lock, first processes newSegmentWaker
    event, transitions to ESTABLISHED and proceeds to protocolMainLoop()
(6) protocolMainLoop() exits while processing notifyClose
When the execution follows the above sequence, no FIN is sent to the peer.
This causes the listener side to have a half-open connection sitting in
the accept queue.

Fix this by ensuring that the protocolMainLoop() performs clean shutdown
when the endpoint state is still ESTABLISHED.

This would not be a bug, if during handshake complete(), sleeper.Fetch()
prioritized notificationWaker over newSegmentWaker. In that case, the
handshake would not have completed in (5) above.

Fixes #6067

PiperOrigin-RevId: 376994395
2021-06-01 23:37:48 -07:00
Zyad A. Ali 69e3476ad5 Test system-wide semaphore limits. 2021-06-01 20:41:57 +02:00
Mithun Iyer 77dc0f5bc9 Ignore RST received for a TCP listener
The current implementation has a bug where TCP listener does not ignore
RSTs from the peer. While handling RST+ACK from the peer, this bug can
complete handshakes that use syncookies. This results in half-open
connection delivered to the accept queue.

Fixes #6076

PiperOrigin-RevId: 376868749
2021-06-01 10:46:40 -07:00
Fabricio Voznika 394c6089c3 Fix test_app task-tree
Executing `select {}` to wait forever triggers Go runtime deadlock
detection and kills the child, causing the number actual processes
be less than expected.

PiperOrigin-RevId: 376298799
2021-05-27 19:55:03 -07:00
Sam Balana 121af37738 Support SO_BINDTODEVICE in ICMP sockets
Adds support for the SO_BINDTODEVICE socket option in ICMP sockets with an
accompanying packetimpact test to exercise use of this socket option.

Adds a unit test to exercise the NIC selection logic introduced by this change.
The remaining unit tests for ICMP sockets need to be added in a subsequent CL.
See https://gvisor.dev/issues/5623 for the list of remaining unit tests.

Adds a "timeout" field to PacketimpactTestInfo, necessary due to the long
runtime of the newly added packetimpact test.

Fixes #5678
Fixes #4896
Updates #5623
Updates #5681
Updates #5763
Updates #5956
Updates #5966
Updates #5967

PiperOrigin-RevId: 376271581
2021-05-27 16:19:00 -07:00
Andrei Vagin 17df2df75c nanosleep has to store the finish time in the restart block
nanosleep has to count time that a thread spent in the stopped state.

PiperOrigin-RevId: 376258641
2021-05-27 15:11:49 -07:00
Sam Balana 522ae2dd1f Specify subsequent layers as ICMP payloads and add ICMPv6.Pointer
Moves specification of subsequent layers to the Payload field of the ICMP and
ICMPv6 layers.

Removes the need to manually encode type-specific ICMP or ICMPv6 headers, such
as the "pointer" header of parameter problem messages, in the payload. This is
necessary prework to enable matching of more type-specific headers, such as
"ident" of echo requests.

Fixes a bug where the "reserved" header defined by ICMPv6 RFC 4443 was being
incorrectly encoded by ToBytes. This change fixes the implementation by copying
the payload into Payload, instead of the MessageBody.

PiperOrigin-RevId: 376026420
2021-05-26 14:16:40 -07:00
Chong Cai 9fcc44f991 Add verity getdents tests
PiperOrigin-RevId: 376001603
2021-05-26 12:23:14 -07:00
Chong Cai 080d122326 Enable verity after mount in verity_mount test
PiperOrigin-RevId: 375823719
2021-05-25 16:46:28 -07:00
Kevin Krakauer f7bc60603e setgid directories for VFS1 tmpfs, overlayfs, and goferfs
PiperOrigin-RevId: 375780659
2021-05-25 13:21:52 -07:00
Tamir Duberstein 090ee43a1c Expect POLLRDHUP on Fuchsia
PiperOrigin-RevId: 375749377
2021-05-25 11:14:23 -07:00