Commit Graph

2893 Commits

Author SHA1 Message Date
Ghanan Gowripalan 782041509f Prevent race when reassigning CancellableTimer
Capture a timer's locker for each instance of a CancellableTimer so that
reassigning a tcpip.CancellableTimer does not cause a data race.

Reassigning a tcpip.CancellableTimer updates its underlying locker. When
a timer fires, it does a read of the timer's locker variable to lock it.
This read of the locker was not synchronized so a race existed where one
goroutine may reassign the timer (updating the locker) and another
handles the timer firing (attempts to lock the timer's locker).

Test: tcpip_test.TestCancellableTimerReassignment
PiperOrigin-RevId: 307499822
2020-04-20 16:32:44 -07:00
Adin Scannell 1a597e01be Add a functional vm_test for root_test.
This change renames the tools/images directory to tools/vm for clarity, and
adds a functional vm_test. Sharding is also added to the same test, and some
documentation added around key flags & variables to describe how they work.

Subsequent changes will add vm_tests for other cases, such as the runtime tests.

PiperOrigin-RevId: 307492245
2020-04-20 15:48:27 -07:00
gVisor bot 07b1b4cc98 Merge pull request #2313 from kevinGC:firstn
PiperOrigin-RevId: 307477185
2020-04-20 14:31:12 -07:00
Ting-Yu Wang 470633d7e9 Fix release.sh. git commands need to be run in git repo.
PiperOrigin-RevId: 307458938
2020-04-20 12:58:32 -07:00
gVisor bot 763d16f912 Merge pull request #2060 from xiaobo55x:rseq
PiperOrigin-RevId: 307453436
2020-04-20 12:31:22 -07:00
Adin Scannell 9ba3086d9d Move runtime_tests.sh to align with other scripts.
PiperOrigin-RevId: 307435879
2020-04-20 11:08:59 -07:00
Jamie Liu e72ce8cce4 Change lingering uses of "memfs" in fsimpl/tmpfs to "tmpfs".
PiperOrigin-RevId: 307422746
2020-04-20 10:10:35 -07:00
Dean Deng 1a940f2b6c Resolve issue with file mode for host fds.
Instead of plumbing error through kernfs.Inode.Mode, panic if err != nil.
The errors that can result from an fstat syscall all indicate that something
is fundamentally wrong, and panicking should be acceptable.

PiperOrigin-RevId: 307406847
2020-04-20 08:51:47 -07:00
Eyal Soha db2a60be67 Don't accept segments outside the receive window
Fixed to match RFC 793 page 69.

Fixes #1607

PiperOrigin-RevId: 307334892
2020-04-19 22:16:14 -07:00
Eyal Soha 08b2fd9bc2 Convert tcp_user_timeout test from packetdrill to packetimpact.
PiperOrigin-RevId: 307328289
2020-04-19 20:49:06 -07:00
gVisor bot ea9bb1c4ea Merge pull request #2235 from xiaobo55x:pcid
PiperOrigin-RevId: 307166482
2020-04-17 22:24:14 -07:00
Adin Scannell 9a233c94f1 Fix watchdog skipStack: the meaning was reversed.
PiperOrigin-RevId: 307166317
2020-04-17 22:19:47 -07:00
Kevin Krakauer e838290e67 prlimit: don't check credentials on self
prlimit was erroneously comparing UIDs and GIDs when getting/setting a process'
own limits. From the manpage:

To set or get the resources of a process other than itself, the caller must have
the CAP_SYS_RESOURCE capability, or the real, effective, and saved set user IDs
of the target process must match the real user ID of the caller and the real,
effective, and saved set group IDs of the target process must match the real
group ID of the caller.

PiperOrigin-RevId: 307127266
2020-04-17 15:33:05 -07:00
Ghanan Gowripalan 486759a37d Support NDP DNS Search List option
Inform the netstack integrator when the netstack receives an NDP Router
Advertisement message with the NDP DNS Search List option with at least
one domain name. The stack will not maintain any state related to the
search list - the integrator is expected to maintain any required state
and invalidate domain names after their lifetime expires, or refresh the
lifetime when a new one is received for a known domain name.

Test:
- header_test.TestNDPDNSSearchListOption
- header_test.TestNDPDNSSearchListOptionSerialize
- header_test.TestNDPSearchListOptionDomainNameLabelInvalidSymbols
- header_test.TestNDPOptionsIterCheck
- stack_test.TestNDPDNSSearchListDispatch
PiperOrigin-RevId: 307109375
2020-04-17 13:56:19 -07:00
Fabricio Voznika a80cd43023 Add test name to boot and gofer log files
This is to make easier to find corresponding logs in
case test fails.

PiperOrigin-RevId: 307104283
2020-04-17 13:28:54 -07:00
Kevin Krakauer a551add5d8 Remove View.First() and View.RemoveFirst()
These methods let users eaily break the VectorisedView abstraction, and
allowed netstack to slip into pseudo-enforcement of the "all headers are
in the first View" invariant. Removing them and replacing with PullUp(n)
breaks this reliance and will make it easier to add iptables support and
rework network buffer management.

The new View.PullUp(n) method is low cost in the common case, when when
all the headers fit in the first View.
2020-04-17 13:25:57 -07:00
gVisor bot 80deebb0bf Merge pull request #1978 from lubinszARM:pr_signal_mm
PiperOrigin-RevId: 307078788
2020-04-17 11:18:11 -07:00
Zach Koopmans 12bde95635 Get /bin/true to run on VFS2
Included:
- loader_test.go RunTest and TestStartSignal VFS2
- container_test.go TestAppExitStatus on VFS2
- experimental flag added to runsc to turn on VFS2

Note: shared mounts are not yet supported.
PiperOrigin-RevId: 307070753
2020-04-17 10:39:19 -07:00
Ting-Yu Wang 4a818d6437 proc net test: Annotate disable-save test with NoRandomSave.
PiperOrigin-RevId: 307069884
2020-04-17 10:34:57 -07:00
Tamir Duberstein 6c225ea2d5 Allow caller-defined sinks for packet sniffing.
PiperOrigin-RevId: 307053624
2020-04-17 09:05:16 -07:00
Tamir Duberstein b4de018a67 Permit setting unknown options
This previously changed in 305699233, but this behaviour turned out to
be load bearing.

PiperOrigin-RevId: 307033802
2020-04-17 06:41:38 -07:00
Jamie Liu f03996c5e9 Implement pipe(2) and pipe2(2) for VFS2.
Updates #1035

PiperOrigin-RevId: 306968644
2020-04-16 19:27:03 -07:00
Ghanan Gowripalan f367cf8e67 Drop invalid NDP NA messages
Better validate NDP NAs options before updating the link address cache.

Test: stack_test.TestNeighorAdvertisementWithTargetLinkLayerOption
PiperOrigin-RevId: 306962924
2020-04-16 18:33:20 -07:00
Tamir Duberstein e7dcd942ac Properly delegate Wait
PiperOrigin-RevId: 306959393
2020-04-16 18:06:55 -07:00
Mithun Iyer 3b05f576d7 Reset pending connections on listener shutdown.
When the listening socket is read shutdown, we need to reset all pending
and incoming connections. Ensure that the endpoint is not cleaned up
from the demuxer and subsequent bind to same port does not go through.

PiperOrigin-RevId: 306958038
2020-04-16 17:58:08 -07:00
Ghanan Gowripalan b33c3bb4a7 Return detailed errors when iterating NDP options
Test: header_test.TestNDPOptionsIterCheck
PiperOrigin-RevId: 306953867
2020-04-16 17:27:19 -07:00
Bhasker Hariharan 0eda0104a5 Fix data race in tcp_test.
This change makes SynRcvdCountThreshold and the global synRcvdCount into a stack
configurable value. This is required because in cases like mod_proxy which
create multiple Stack instances the count will be a global value that impacts
all Stack instances.

Further the tests relied on modifying the global threshold to simulate tests
where we want to verify SYN cookie based behaviour. This lead to data races due
to the global being modified/read without locks or atomics.

PiperOrigin-RevId: 306947723
2020-04-16 16:49:18 -07:00
Eyal Soha 75e864fc75 Use multierr in packetimpact Connection.Close()
PiperOrigin-RevId: 306930652
2020-04-16 15:15:50 -07:00
Fabricio Voznika 5a8ee1beee Preserve log FD after execve
PiperOrigin-RevId: 306908296
2020-04-16 13:17:00 -07:00
gVisor bot eb7b1903e0 Test TCP behavior when receiving unacceptable segment in CLOSE_WAIT
TCP, in CLOSE-WAIT state, MUST return ACK with proper SEQ and ACK numbers after
recv a seg with OTW SEQ or unacc ACK number, and remain in same state. If the
connection is in a synchronized state, any unacceptable segment (out of window
sequence number or unacceptable acknowledgment number) must elicit only an empty
acknowledgment segment containing the current send-sequence number and an
acknowledgment indicating the next sequence number expected to be received, and
the connection remains in the same state.

PiperOrigin-RevId: 306897984
2020-04-16 12:22:17 -07:00
Fabricio Voznika 28399818fc Make ExtractErrno a function
PiperOrigin-RevId: 306891171
2020-04-16 11:49:27 -07:00
Eyal Soha 09c7e3f6e4 Add tests for segments outside the receive window.
The tests are based on RFC 793 page 69.

Updates #1607

PiperOrigin-RevId: 306768847
2020-04-15 19:37:00 -07:00
Eyal Soha 3d3bf9603d Use hex.Dump for Layer.String() of byte slices.
PiperOrigin-RevId: 306726587
2020-04-15 14:59:15 -07:00
Ting-Yu Wang ea5b8e9633 Use if_nametoindex to get interface index.
Removed the TODO to use netlink.

PiperOrigin-RevId: 306721468
2020-04-15 14:31:36 -07:00
Eyal Soha 1bcc2bf17f Refactor connections.go to make it easier to add new connection types.
Rather than have a struct for the state of each type of connection, such as
TCP/IPv4, UDP/IPv4, TCP/IPv6, etc, have a state for each layer, such as UDP,
TCP, IPv4, IPv6.  Those states can be composed into connections.

Tested:
  Existing unit tests still pass/fail as expected.
PiperOrigin-RevId: 306703180
2020-04-15 13:01:11 -07:00
Tamir Duberstein 7c13546d3b Deduplicate packet logging
PiperOrigin-RevId: 306677789
2020-04-15 11:02:30 -07:00
Tamir Duberstein 0348edc3cb Remove unnecessary code
Remove useless casts and duplicate return statements.

PiperOrigin-RevId: 306627916
2020-04-15 06:05:38 -07:00
Mithun Iyer 9c918340e4 Reset pending connections on listener close
Attempt to redeliver TCP segments that are enqueued into a closing
TCP endpoint. This was being done for Established endpoints but not
for those that are listening or performing connection handshake.

Fixes #2417

PiperOrigin-RevId: 306598155
2020-04-15 01:11:44 -07:00
Bhasker Hariharan 28212b3f17 Reduce flakiness in tcp_test.
Tests now use a MinRTO of 3s instead of default 200ms. This reduced flakiness in
a lot of the congestion control/recovery tests which were flaky due to
retransmit timer firing too early in case the test executors were overloaded.

This change also bumps some of the timeouts in tests which were too sensitive to
timer variations and reduces the number of slow start iterations which can
make the tests run for too long and also trigger retansmit timeouts etc if
the executor is overloaded.

PiperOrigin-RevId: 306562645
2020-04-14 19:33:35 -07:00
Ghanan Gowripalan 36fbaac520 Attempt SLAAC address regeneration on DAD conflicts
As per RFC 7217 section 6, attempt to regenerate IPv6 SLAAC address in response
to a DAD conflict if the address was generated with an opaque IID as outlined in
RFC 7217 section 5.

Test:
- stack_test.TestAutoGenAddrWithOpaqueIIDDADRetries
- stack_test.TestAutoGenAddrWithEUI64IIDNoDADRetries
- stack_test.TestAutoGenAddrContinuesLifetimesAfterRetry
PiperOrigin-RevId: 306555645
2020-04-14 18:32:35 -07:00
Jamie Liu 2dd6384de8 Fix cleanup around socketpair() failure to copy out FDs.
- Use the fs.File, rather than the vfs.FileDescription, in the VFS1 version.

- Check for a nil fs.File/vfs.FileDescription before calling DecRef, which is
  possible if a racing dup2() or dup3() replaces the file descriptor between
  when it is installed and when it is returned. (This is not possible in Linux
  because Linux separates allocation of a file descriptor from binding an
  allocated file descriptor to a struct file, and dup2/dup3 return EBUSY if
  asked to replace an allocated but unbound file descriptor.)

PiperOrigin-RevId: 306517101
2020-04-14 14:41:06 -07:00
Jamie Liu 52b4b19249 Pass O_LARGEFILE in syscalls/linux/vfs2.openat.
Needed for PipeTest_Flags: files opened by open() and openat() get O_LARGEFILE
(on architectures with 64-bit off_t), but not FDs created by other syscalls
such as pipe().

Updates #1035

PiperOrigin-RevId: 306504788
2020-04-14 13:37:51 -07:00
gVisor bot ac9b32c36b Merge pull request #2212 from aaronlu:dup_stdioFDs
PiperOrigin-RevId: 306477639
2020-04-14 11:20:11 -07:00
gVisor bot 81c44c4cd7 Test TCP should piggyback ACK in ESTAB state
TCP, in ESTABLISHED state, SHOULD piggyback acknowledgement with a segment being
transmitted (whenever possible) without incurring undue delay

PiperOrigin-RevId: 306474550
2020-04-14 11:05:38 -07:00
gVisor bot 82530e4c30 Merge pull request #2375 from lubinszARM:pr_exec_binary
PiperOrigin-RevId: 306432289
2020-04-14 07:12:06 -07:00
gVisor bot c230d12b5c Add Sniffer.Drain() draining socket receive buffer
Add Sniffer.Drain() which drains the socket's receive buffer by temporarily
setting the socket to non-blocking, and receiving in a loop until EINTR,
EWOULDBLOCK or EAGAIN. This method should be used when long periods of time
elapses without receiving on the socket, because uninteresting packets may have
piled up in the receive buffer, filling it up and causing packets critical to
test operation to be dropped.

PiperOrigin-RevId: 306380480
2020-04-13 23:05:08 -07:00
Nicolas Lacasse 71e6ac3e1f Don't allow read/write when offset+size overflows.
PiperOrigin-RevId: 306348346
2020-04-13 18:00:17 -07:00
Tamir Duberstein d303684d7a Remove unnecessary threads
The work being done in these threads is not asynchronous with respect to
the test; that is, it is equivalent to issue non-blocking `connect`
calls serially, since the work is done asynchronously with respect to
the caller. Futhermore, this test was added to test closing a listener
with completed but not delivered connections, which never required
threading in the first place.

PiperOrigin-RevId: 306339486
2020-04-13 17:00:51 -07:00
gVisor bot 7e5d67ee90 Merge pull request #2168 from xiaobo55x:ptrace_test
PiperOrigin-RevId: 306306809
2020-04-13 14:17:53 -07:00
gVisor bot 3f4e826fb3 Merge pull request #2288 from xiaobo55x:fork_test
PiperOrigin-RevId: 306306494
2020-04-13 14:13:28 -07:00