Commit Graph

5095 Commits

Author SHA1 Message Date
Dean Deng f52f0101bb Implement F_GETLK fcntl.
Fixes #5113.

PiperOrigin-RevId: 353313374
2021-01-22 13:58:16 -08:00
Tamir Duberstein 6c0e1d9cfe Define tcpip.Payloader in terms of io.Reader
Fixes #1509.

PiperOrigin-RevId: 353295589
2021-01-22 12:26:09 -08:00
Nayana Bidari 527ef5fc03 Add tests for RACK
- Added packetimpact tests for RACK.

PiperOrigin-RevId: 353282342
2021-01-22 11:38:46 -08:00
Dean Deng 65594d30ad Avoid atomic operations in kcov processing.
Atomic operations here significantly slow down gVisor builds with
kcov/coverage enabled. Also mark these functions go:norace to avoid
complaints from the race detector.

PiperOrigin-RevId: 353281865
2021-01-22 11:32:56 -08:00
Zach Koopmans 16b81308cf Add initial mitigate code and cpu parsing.
PiperOrigin-RevId: 353274135
2021-01-22 10:52:57 -08:00
Fabricio Voznika 9b4f4655ed Remove dependency to abi/linux
abi package is to be used by the Sentry to implement the Linux ABI.
Code dealing with the host should use x/sys/unix.

PiperOrigin-RevId: 353272679
2021-01-22 10:47:28 -08:00
Fabricio Voznika f14f3ba3ef Fix TestDuplicateEnvVariable flakyness
Updates #5226

PiperOrigin-RevId: 353262133
2021-01-22 09:57:44 -08:00
Ayush Ranjan 010cadd3b8 [infra] Fix Build Github action failure.
The GH Build action has been failing with the error message:
```
--- BUILD -c opt //runsc
tee: /proc/self/fd/2: No such device or address
```

tee /dev/fd/2 seems to be the canonical way of copying stdin to stderr.
So use that instead.

PiperOrigin-RevId: 353259087
2021-01-22 09:42:15 -08:00
Ghanan Gowripalan e0f4e46e34 Resolve static link addresses in GetLinkAddress
If a network address has a static mapping to a link address, calculate
it in GetLinkAddress.

Test: stack_test.TestStaticGetLinkAddress
PiperOrigin-RevId: 353179616
2021-01-21 23:26:40 -08:00
Toshi Kikuchi cfbf209173 iptables: support matching the input interface name
We have support for the output interface name, but not for the input
interface name.
This change adds the support for the input interface name, and adds the
test cases for it.

Fixes #5300

PiperOrigin-RevId: 353179389
2021-01-21 23:19:19 -08:00
Ian Lewis d02c03a268 Syscall docs update
- Moves the id to the <tr> tag so that the page aligns properly when using an
anchor.
- Makes the syscall number a link to the anchor.
- Fixes some broken links to syscalls without man pages.

PiperOrigin-RevId: 353159903
2021-01-21 20:11:53 -08:00
Ghanan Gowripalan 9f46328e11 Only use callback for GetLinkAddress
GetLinkAddress's callback will be called immediately with a
stack.LinkResolutionResult which will hold the link address
so no need to also return the link address from the function.

Fixes #5151.

PiperOrigin-RevId: 353157857
2021-01-21 19:55:37 -08:00
Ghanan Gowripalan 8ecff18902 Do not cache remote link address in Route
...unless explicitly requested via ResolveWith.

Remove cancelled channels from pending packets as we can use the link
resolution channel in a FIFO to limit the number of maximum pending
resolutions we should queue packets for.

This change also defers starting the goroutine that handles link
resolution completion to when link resolution succeeds, fails or
gets cancelled due to the max number of pending resolutions being
reached.

Fixes #751.

PiperOrigin-RevId: 353130577
2021-01-21 16:40:06 -08:00
Adin Scannell 48dfb8db9e Add image presubmit tests and mark fsstress x86_64 only.
PiperOrigin-RevId: 353118942
2021-01-21 15:53:34 -08:00
Fabricio Voznika 7bf656f4c6 Fix ownership change logic
Previously fsgofer was skipping chown call if the uid and gid
were the same as the current user/group. However, when setgid
is set, the group may not be the same as the caller. Instead,
compare the actual uid/gid of the file after it has been
created and change ownership only if needed.

Updates #180

PiperOrigin-RevId: 353118733
2021-01-21 15:47:23 -08:00
Ghanan Gowripalan 89df5a681c Queue packets in WritePackets when resolving link address
Test: integration_test.TestWritePacketsLinkResolution

Fixes #4458.

PiperOrigin-RevId: 353108826
2021-01-21 14:54:14 -08:00
Ghanan Gowripalan 0ca4cf7698 Populate EgressRoute, GSO, Netproto in NIC
fdbased and qdisc layers expect these fields to already be
populated before being reached.

PiperOrigin-RevId: 353099492
2021-01-21 14:10:37 -08:00
Fabricio Voznika 1005a88491 Fix fsstress argument name
Updates #5273

PiperOrigin-RevId: 353087710
2021-01-21 13:20:52 -08:00
Zeling Feng 60b07541db Syscall test for connecting to unspecified address
For an active OPEN call with unspecified foreign socket, TCP MUST
return error: foreign socket unspecified

PiperOrigin-RevId: 352961691
2021-01-21 00:44:49 -08:00
Dean Deng 2c58af2264 Update splice syscall documentation.
PiperOrigin-RevId: 352954044
2021-01-20 23:39:37 -08:00
Ian Lewis 33b803e47f Add syscall docs back to menu
Syscall docs were excluded from the navigation menu. This change adds them
back.

PiperOrigin-RevId: 352942238
2021-01-20 21:53:11 -08:00
Nayana Bidari b0136253e6 Remove unimplemented message for SO_LINGER
- Removes the unimplemented message for SO_LINGER
- Fix the length for IP_PKTINFO option

PiperOrigin-RevId: 352917611
2021-01-20 18:16:51 -08:00
Jamie Liu a50bc8446c Don't use task goroutine context in fsimpl tests.
PiperOrigin-RevId: 352908368
2021-01-20 17:15:59 -08:00
Dean Deng a733a8142e Fix typo boundry -> boundary.
PiperOrigin-RevId: 352905565
2021-01-20 17:01:00 -08:00
Dean Deng 55332aca95 Move Lock/UnlockPOSIX into LockFD util.
PiperOrigin-RevId: 352904728
2021-01-20 16:55:07 -08:00
Jamie Liu ca9a45f282 Fix refcount increments in gofer.filesystem.Sync.
Fixes #5263

PiperOrigin-RevId: 352903844
2021-01-20 16:48:54 -08:00
Jamie Liu 9af6150b5e Remove string allocation from strings.Repeat() in /proc/[pid]/maps.
PiperOrigin-RevId: 352894106
2021-01-20 15:56:40 -08:00
Julian Elischer 2865166403 Change the way the IP options report problems
The error messages are not needed or used as these are not processing errors
so much as errors to be reported back to the packet sender. Implicitly
describe whether each error should generate ICMP packets or not. Most do
but there are a couple that do not.

Slightly alter some test expectations for Linux compatibility and add a
couple more. Improve Linux compatibility on error packet returns. Some
cosmetic changes to tests to match the upcoming packet impact version
of the same tests.

PiperOrigin-RevId: 352889785
2021-01-20 15:36:03 -08:00
Michaël Lévesque-Dion 9ea1a875eb rewrite diff check to match example in cmp.Diff docs 2021-01-20 14:03:35 -05:00
Ghanan Gowripalan 7ff5ceaeae Do not have a stack-wide linkAddressCache
Link addresses are cached on a per NIC basis so instead of having a
single cache that includes the NIC ID for neighbor entry lookups,
use a single cache per NIC.

PiperOrigin-RevId: 352684111
2021-01-19 16:56:49 -08:00
Andrei Vagin 48ea2c34d1 platform/ptrace: workaround a kernel ptrace issue on ARM64
On ARM64, when ptrace stops on a system call, it uses the x7 register to
indicate whether the stop has been signalled from syscall entry or syscall
exit. This means that we can't get a value of this register and we can't change
it. More details are in the comment for tracehook_report_syscall in
arch/arm64/kernel/ptrace.c.

This happens only if we stop on a system call, so let's queue a signal, resume
a stub thread and catch it on a signal handling.

Fixes: #5238
PiperOrigin-RevId: 352668695
2021-01-19 15:34:02 -08:00
Arthur Sfez be17b94446 Per NIC NetworkEndpoint statistics
To facilitate the debugging of multi-homed setup, track Network
protocols statistics for each endpoint. Note that the original
stack-wide stats still exist.

A new type of statistic counter is introduced, which track two
versions of a stat at the same time. This lets a network endpoint
increment both the local stat and the stack-wide stat at the same
time.

Fixes #4605

PiperOrigin-RevId: 352663276
2021-01-19 15:07:39 -08:00
Kevin Krakauer 833ba3590b Ensure that IP{V6}_RECVORIGDSTADDR yields the post-NAT address and port.
PiperOrigin-RevId: 352624174
2021-01-19 12:14:08 -08:00
Ghanan Gowripalan a2ec1932c9 Drop CheckLocalAddress from LinkAddressCache
PiperOrigin-RevId: 352623277
2021-01-19 12:08:36 -08:00
Ayush Ranjan 1a072e298e [infra] Attempt to fix Kokoro image workflow.
#5274 broke `make load-basic_fsstress` target. It works locally but for some
inconceivable reason it fails to build on Kokoro.

Error message:
```
Step 1/12 : FROM alpine
 ---> 1fca6fe4a1ec
Step 2/12 : RUN apk add git
 ---> Running in 109a5326259a
standard_init_linux.go:207: exec user process caused "no such file or directory"
The command '/bin/sh -c apk add git' returned a non-zero code: 1
make: *** [load-basic_fsstress] Error 1
tools/images.mk:149: recipe for target 'load-basic_fsstress' failed
```

Copied the approach from the following issue to achieve the same goal:
https://github.com/nodejs/docker-node/issues/586#issue-273737852.

PiperOrigin-RevId: 352602945
2021-01-19 10:46:59 -08:00
Ghanan Gowripalan f5736fa2bf Do not use a stack-wide queue of pending packets
Packets may be pending on link resolution to complete before being sent.
Link resolution is performed for neighbors which are unique to a NIC so
hold link resolution related state under the NIC, not the stack.

Note, this change may result in more queued packets but that is okay as
RFC 4861 section 7.2.2 recommends that the stack maintain a queue of
packets for each neighbor that is waiting for link resolution to
complete, not a fixed limit per stack.

PiperOrigin-RevId: 352322155
2021-01-17 18:14:28 -08:00
Ghanan Gowripalan cd75bb163f Resolve known link address on route creation
If a Route is being created through a link that requires link address
resolution and a remote address that has a known mapping to a link
address, populate the link address when the route is created.

This removes the need for neighbor/link address caches to perform this
check.

Fixes #5149

PiperOrigin-RevId: 352122401
2021-01-15 18:49:22 -08:00
Ghanan Gowripalan 2814a032be Support GetLinkAddress with neighborCache
Test: integration_test.TestGetLinkAddress
PiperOrigin-RevId: 352119404
2021-01-15 18:15:26 -08:00
Ghanan Gowripalan fd5b52c87f Only pass stack.Route's fields to LinkEndpoints
stack.Route is used to send network packets and resolve link addresses.
A LinkEndpoint does not need to do either of these and only needs the
route's fields at the time of the packet write request.

Since LinkEndpoints only need the route's fields when writing packets,
pass a stack.RouteInfo instead.

PiperOrigin-RevId: 352108405
2021-01-15 16:49:15 -08:00
Tamir Duberstein 12d9790833 Remove count argument from tcpip.Endpoint.Read
The same intent can be specified via the io.Writer.

PiperOrigin-RevId: 352098747
2021-01-15 15:49:15 -08:00
Ayush Ranjan f37ace6661 [rack] Retransmit the probe segment after the probe timer expires.
This change implements TLP details enumerated in
https://tools.ietf.org/html/draft-ietf-tcpm-rack-08#section-7.5.2.

Fixes #5084

PiperOrigin-RevId: 352093473
2021-01-15 15:19:45 -08:00
Ting-Yu Wang ec9e263f21 Correctly return EMSGSIZE when packet is too big in raw socket.
IPv4 previously accepts the packet, while IPv6 panics. Neither is the behavior
in Linux.

splice() in Linux has different behavior than in gVisor. This change documents
it in the SpliceTooLong test.

Reported-by: syzbot+b550e78e5c24d1d521f2@syzkaller.appspotmail.com
PiperOrigin-RevId: 352091286
2021-01-15 15:10:27 -08:00
Ghanan Gowripalan 55c7fe48d2 Populate EgressRoute, GSO, Netproto for batch writes
We loop over the list of packets anyways so setting these aren't
expensive.

Now that they are populated only by the link endpoint that uses them,
TCP does not need to.

PiperOrigin-RevId: 352090853
2021-01-15 15:03:47 -08:00
Fabricio Voznika c7fc4a5d66 Add fsstress tests
Updates #5273

PiperOrigin-RevId: 352088736
2021-01-15 14:51:51 -08:00
Dean Deng 9db126eb65 Combine reference count logs into one message.
Otherwise, races can occur between concurrent logs.

PiperOrigin-RevId: 352086914
2021-01-15 14:40:26 -08:00
Fabricio Voznika f03144d886 Support TEST_PREMATURE_EXIT_FILE in syscall tests
PiperOrigin-RevId: 352068182
2021-01-15 13:03:58 -08:00
Ting-Yu Wang f1420cf484 Add sanity check on return values from Write
io.Writer.Write requires err to be non-nil if n < len(v).

We could allow this but it will be irreversible if users depend on this
behavior.

Ported the test that discovered this.

PiperOrigin-RevId: 352065946
2021-01-15 12:51:08 -08:00
Mithun Iyer f7f66c8c6c Add tests for cases of ARP failures on TCP connect
Also fix test expectation for UDP sendto() case in tuntap syscall test.

Fixes #5155

PiperOrigin-RevId: 352056612
2021-01-15 12:03:52 -08:00
gVisor bot 714a020ab5 Merge pull request #5237 from travigd:add-containerd-pause
PiperOrigin-RevId: 352032380
2021-01-15 10:09:43 -08:00
Jamie Liu e57ebcd37a Simplify the pipe implementation.
- Remove the pipe package's dependence on the buffer package, which becomes
  unused as a result. The buffer package is currently intended to serve two use
  cases, pipes and temporary buffers, and does neither optimally as a result;
  this change facilitates retooling the buffer package to better serve the
  latter.

- Pass callbacks taking safemem.BlockSeq to the internal pipe I/O methods,
  which makes most callbacks trivial.

- Fix VFS1's splice() and tee() to immediately return if a pipe returns a
  partial write.

PiperOrigin-RevId: 351911375
2021-01-14 17:35:07 -08:00