Commit Graph

834 Commits

Author SHA1 Message Date
Tamir Duberstein 0dbc112979 Compile-time constants are constexpr
PiperOrigin-RevId: 355506299
2021-02-03 16:21:37 -08:00
Bhasker Hariharan 8c7c5abafb Add support for rate limiting out of window ACKs.
Netstack today will send dupACK's with no rate limit for incoming out of
window segments. This can result in ACK loops for example if a TCP socket
connects to itself (actually permitted by TCP). Where the ACK sent in
response to packets being out of order itself gets considered as an out
of window segment resulting in another ACK being generated.

PiperOrigin-RevId: 355206877
2021-02-02 11:05:28 -08:00
Tamir Duberstein 00d21b9ae0 Assert TCP_INFO size before checking content
Also sync syscall test expectations on Fuchisa.

PiperOrigin-RevId: 355163492
2021-02-02 07:45:47 -08:00
Fabricio Voznika ccf9138e6d Remove side effect from open tests
Individual test cases must not rely on being executed in a clean environment.

PiperOrigin-RevId: 354730126
2021-01-30 13:38:05 -08:00
Kevin Krakauer 66aa6f3d4f setgid directory syscall tests
PiperOrigin-RevId: 354615220
2021-01-29 14:49:04 -08:00
Fabricio Voznika fdbfd447a0 Remove side effect from test cases
Individual test cases must not rely on being executed in a clean environment.

PiperOrigin-RevId: 354604389
2021-01-29 13:56:17 -08:00
Nayana Bidari 0a52b64794 - Add more comments for the TCP_INFO struct fields.
PiperOrigin-RevId: 354595623
2021-01-29 13:15:57 -08:00
Fabricio Voznika 9cc2570ea7 Change EXPECT/ASSERT to TEST_CHECK inside InForkedProcess
PiperOrigin-RevId: 354441239
2021-01-28 18:24:58 -08:00
gVisor bot d8c330254a Add O_PATH support in vfs2
PiperOrigin-RevId: 354367665
2021-01-28 12:24:37 -08:00
Tamir Duberstein 449c155bc0 Correctly check permissions in ping socket test
The previous check was using SOCK_RAW, despite the fact that the test only uses
SOCK_DGRAM. Simplify the test machinery while I'm here.

PiperOrigin-RevId: 354359842
2021-01-28 11:50:29 -08:00
Nayana Bidari 99988e45ed Add support for more fields in netstack for TCP_INFO
This CL adds support for the following fields:
- RTT, RTTVar, RTO
- send congestion window (sndCwnd) and send slow start threshold (sndSsthresh)
- congestion control state(CaState)
- ReorderSeen

PiperOrigin-RevId: 354195361
2021-01-27 16:14:50 -08:00
Dean Deng 96bd076e8a Initialize timestamps for gofer synthetic children.
Contrary to the comment on the socket test, the failure was due to an issue
with goferfs rather than kernfs.

PiperOrigin-RevId: 353918021
2021-01-26 12:02:05 -08:00
Dean Deng 203890b134 Move inotify events from syscall to vfs layer.
This also causes inotify events to be generated when reading files for exec.

This change also requires us to adjust splice+inotify tests due to
discrepancies between gVisor and Linux behavior. Note that these discrepancies
existed before; we just did not exercise them previously. See comment for more
details.

Fixes #5348.

PiperOrigin-RevId: 353907187
2021-01-26 11:17:05 -08:00
Dean Deng abdff88748 Do not send SCM Rights more than once when message is truncated.
If data is sent over a stream socket that will not fit all at once, it will
be sent over multiple packets. SCM Rights should only be sent with the first
packet (see net/unix/af_unix.c:unix_stream_sendmsg in Linux).

Reported-by: syzbot+aa26482e9c4887aff259@syzkaller.appspotmail.com
PiperOrigin-RevId: 353886442
2021-01-26 09:49:31 -08:00
Nayana Bidari daf0d3f6ca Move SO_SNDBUF to socketops.
This CL moves {S,G}etsockopt of SO_SNDBUF from all endpoints to socketops. For
unix sockets, we do not support setting of this option.

PiperOrigin-RevId: 353871484
2021-01-26 08:25:34 -08:00
Dean Deng 3946075403 Do not generate extraneous IN_CLOSE inotify events.
IN_CLOSE should only be generated when a file description loses its last
reference; not when a file descriptor is closed.

See fs/file_table.c:__fput.

Updates #5348.

PiperOrigin-RevId: 353810697
2021-01-26 00:02:52 -08:00
Fabricio Voznika 0592dac851 Remove side effect from shm tests
Individual test cases must not rely on being executed in a clean environment.

PiperOrigin-RevId: 353684155
2021-01-25 11:02:28 -08:00
Fabricio Voznika a358de583b Fix Inotify.Exec test
The test was execve itself into `/bin/true`, so the test was
not actually executing.

PiperOrigin-RevId: 353676855
2021-01-25 10:32:52 -08:00
Dean Deng f52f0101bb Implement F_GETLK fcntl.
Fixes #5113.

PiperOrigin-RevId: 353313374
2021-01-22 13:58:16 -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 a733a8142e Fix typo boundry -> boundary.
PiperOrigin-RevId: 352905565
2021-01-20 17:01:00 -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
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
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
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
Fabricio Voznika dbe4176565 Check for existence before permissions
Return EEXIST when overwritting a file as long as the caller has exec
permission on the parent directory, even if the caller doesn't have
write permission.

Also reordered the mount write check, which happens before permission
is checked.

Closes #5164

PiperOrigin-RevId: 351868123
2021-01-14 13:43:10 -08:00
Ayush Ranjan ad0ac73626 [rack] Set up TLP timer and configure timeout.
This change implements TLP details enumerated in
https://tools.ietf.org/html/draft-ietf-tcpm-rack-08#section-7.5.1.

Fixes #5083

PiperOrigin-RevId: 351467357
2021-01-12 16:00:26 -08:00
Adin Scannell 4e03e87547 Fix simple mistakes identified by goreportcard.
These are primarily simplification and lint mistakes. However, minor
fixes are also included and tests added where appropriate.

PiperOrigin-RevId: 351425971
2021-01-12 12:38:22 -08:00
Mithun Iyer 04b37c8220 Fix tuntap_test to cleanup after CreateInterfaceNoCap
PiperOrigin-RevId: 350646249
2021-01-07 15:08:27 -08:00
Ting-Yu Wang b1de1da318 netstack: Refactor tcpip.Endpoint.Read
Read now takes a destination io.Writer, count, options. Keeping the method name
Read, in contrast to the Write method.

This enables:
* direct transfer of views under VV
* zero copy

It also eliminates the need for sentry to keep a slice of view because
userspace had requested a read that is smaller than the view returned, removing
the complexity there.

Read/Peek/ReadPacket are now consolidated together and some duplicate code is
removed.

PiperOrigin-RevId: 350636322
2021-01-07 14:17:18 -08:00
Kevin Krakauer 084ad58210 Run external networking test
PiperOrigin-RevId: 350438564
2021-01-06 15:25:35 -08:00
Ghanan Gowripalan abe9d9f67f Support add/remove IPv6 multicast group sock opt
IPv4 was always supported but UDP never supported joining/leaving IPv6
multicast groups via socket options.

Add: IPPROTO_IPV6, IPV6_JOIN_GROUP/IPV6_ADD_MEMBERSHIP
Remove: IPPROTO_IPV6, IPV6_LEAVE_GROUP/IPV6_DROP_MEMBERSHIP

Test: integration_test.TestUDPAddRemoveMembershipSocketOption
PiperOrigin-RevId: 350396072
2021-01-06 11:41:42 -08:00
Andrei Vagin b9b99d3d26 Don't check that msg_flags contains MSG_ERRQUEUE on gvisor platforms.
PiperOrigin-RevId: 350246333
2021-01-05 16:47:39 -08:00
Andrei Vagin 2a200811d4 fs/fuse: check that a task has a specified file descriptor
Reported-by: syzbot+814105309d2ae8651084@syzkaller.appspotmail.com
PiperOrigin-RevId: 350159452
2021-01-05 09:47:30 -08:00
Dean Deng 4691a81253 Add test for open(2) with O_WRONLY|O_RDWR.
PiperOrigin-RevId: 349607959
2020-12-30 15:22:35 -08:00
Jing Chen d302c05700 Deflake semaphore_test_native
PiperOrigin-RevId: 349490873
2020-12-29 17:38:23 -08:00
Tamir Duberstein 91c05c609e Export socket_ipv6_udp_unbound_loopback.cc
PiperOrigin-RevId: 349458984
2020-12-29 12:56:59 -08:00
gVisor bot 5dc60a7632 Merge pull request #5166 from kevinGC:bk-warnings
PiperOrigin-RevId: 349314945
2020-12-28 12:12:35 -08:00
Kevin Krakauer 5259b90dac Resolve compiler warnings
The buildkite syscall tests start with a lot of C++ warnings. This
cleans that up a little.
2020-12-23 16:49:01 -08:00
Andrei Vagin d079159876 vfs1: don't allow to open socket files
open() has to return ENXIO in this case.

O_PATH isn't supported by vfs1.

PiperOrigin-RevId: 348820478
2020-12-23 11:11:07 -08:00
gVisor bot 6d96a2394d Internal change.
PiperOrigin-RevId: 348720223
2020-12-22 17:46:41 -08:00
Nicolas Lacasse 1ea241e4cc Fix seek on /proc/pid/cmdline when task is zombie.
PiperOrigin-RevId: 348056159
2020-12-17 11:16:06 -08:00
Ayush Ranjan 028271b530 [netstack] Implement IP(V6)_RECVERR socket option.
PiperOrigin-RevId: 348055514
2020-12-17 11:10:41 -08:00
Jing Chen 1e56a2f9a2 Implement command SEM_INFO and SEM_STAT for semctl.
PiperOrigin-RevId: 347711998
2020-12-15 16:06:06 -08:00
Nayana Bidari b15acae9a6 Fix error code for connect in raw sockets.
PiperOrigin-RevId: 347650354
2020-12-15 11:07:48 -08:00
Ayush Ranjan a1c56bc227 [netstack] Update raw socket and hostinet control message parsing.
There are surprisingly few syscall tests that run with hostinet. For example
running the following command only returns two results:
`bazel query test/syscalls:all | grep hostnet`

I think as a result, as our control messages evolved, hostinet was left
behind. Update it to support all control messages netstack supports.

This change also updates sentry's control message parsing logic to make it up to
date with all the control messages we support.

PiperOrigin-RevId: 347508892
2020-12-14 18:00:55 -08:00
Nayana Bidari ab593661ef Move SO_ERROR and SO_OOBINLINE option to socketops.
SO_OOBINLINE option is set/get as boolean value, which is the same as linux.
As we currently do not support disabling this option, we always return it as
true.

PiperOrigin-RevId: 347413905
2020-12-14 10:22:32 -08:00
Nayana Bidari d45420b152 Fix panic when IPv4 address is used in sendmsg for IPv6 sockets
We do not rely on error for getsockopt options(which have boolean values)
anymore. This will cause issue in sendmsg where we used to return error
for IPV6_V6Only option. Fix the panic by returning error (for sockets other
than TCP and UDP) if the address does not match the type(AF_INET/AF_INET6) of
the socket.

PiperOrigin-RevId: 347063838
2020-12-11 13:31:28 -08:00