Commit Graph

1792 Commits

Author SHA1 Message Date
Fabricio Voznika 28399818fc Make ExtractErrno a function
PiperOrigin-RevId: 306891171
2020-04-16 11:49:27 -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
Nicolas Lacasse 71e6ac3e1f Don't allow read/write when offset+size overflows.
PiperOrigin-RevId: 306348346
2020-04-13 18:00:17 -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 e1959f58dc Merge pull request #2321 from lubinszARM:pr_nogo
PiperOrigin-RevId: 306300032
2020-04-13 13:41:45 -07:00
Dean Deng 5d885d7fb2 Port socket-related syscalls to VFS2.
Note that most kinds of sockets are not yet supported in VFS2
(only Unix sockets are partially supported at the moment), so
these syscalls will still generally fail. Enabling them allows
us to begin running socket tests for VFS2 as more features are
ported over.

Updates #1476, #1478, #1484, #1485.

PiperOrigin-RevId: 306292294
2020-04-13 13:02:34 -07:00
Jon Budd 6a4d17a31d Remove obsolete TODOs for b/38173783
The comments in the ticket indicate that this behavior
is fine and that the ticket should be closed, so we shouldn't
need pointers to the ticket.

PiperOrigin-RevId: 306266071
2020-04-13 11:02:14 -07:00
Jamie Liu 445c366581 Fix VFS2 getdents()/getdents64() alignment.
PiperOrigin-RevId: 306263615
2020-04-13 10:52:22 -07:00
Ian Lewis daf3322498 Add logging message for noNewPrivileges OCI option.
noNewPrivileges is ignored if set to false since gVisor assumes that
PR_SET_NO_NEW_PRIVS is always enabled.

PiperOrigin-RevId: 305991947
2020-04-10 20:32:23 -07:00
Dean Deng 09ddb5a426 Port extended attributes to VFS2.
As in VFS1, we only support the user.* namespace. Plumbing is added to tmpfs
and goferfs.
Note that because of the slightly different order of checks between VFS2 and
Linux, one of the xattr tests needs to be relaxed slightly.

Fixes #2363.

PiperOrigin-RevId: 305985121
2020-04-10 19:02:55 -07:00
Fabricio Voznika 96f9142959 Use O_CLOEXEC when dup'ing FDs
The sentry doesn't allow execve, but it's a good defense
in-depth measure.

PiperOrigin-RevId: 305958737
2020-04-10 15:47:23 -07:00
Dean Deng 8bb8027d55 Return EIO from p9 if sending/receiving fails.
Continues the modifications in cl/272963663. This prevents non-syscall errors
from being propogated to kernel/task_syscall.go:ExtractErrno(), which causes a
sentry panic.

PiperOrigin-RevId: 305913127
2020-04-10 11:36:57 -07:00
Fabricio Voznika 1798d6cbee Remove TODO from kernel.Stracer
The dependency strace=>kernel grew over time. strace also depends on
task's FD table and FSContext. It could be fixed with some interfaces
the other way, but then we're trading an interface for another, and
kernel.Stracer is likely cleaner.

Closes #155

PiperOrigin-RevId: 305909678
2020-04-10 11:19:12 -07:00
gVisor bot 78126611e6 Merge pull request #2253 from amscanne:nogo
PiperOrigin-RevId: 305807868
2020-04-09 19:16:46 -07:00
Haibo Xu 7aa5caae71 Enable syscall ptrace test on arm64.
Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: I5bb8fa7d580d173b1438d6465e1adb442216c8fa
2020-04-10 10:00:26 +08:00
Ghanan Gowripalan c560bfd1a8 Drop invalid NDP NS messages
Better validate NDP NS messages and their options before doing work in
response to them. Also make sure that NA messages sent in response to
an NS use the correct IPv6 and link-layer addresses so they are
routed properly and received by the right node.

Test: stack_test.TestNeighorSolicitationResponse
PiperOrigin-RevId: 305799054
2020-04-09 18:04:42 -07:00
Ting-Yu Wang c9195349c9 Replace type assertion with TaskFromContext.
This should fix panic at aio callback.

PiperOrigin-RevId: 305798549
2020-04-09 18:00:33 -07:00
Jamie Liu 257225c34b Downgrade VFS1-specific FIXME to a NOTE.
PiperOrigin-RevId: 305794509
2020-04-09 17:30:51 -07:00
Fabricio Voznika 9f87502b46 Remove TODOs from Async IO
Block and drain requests in io_destroy(2).
Note the reason to create read-only mapping.

PiperOrigin-RevId: 305786312
2020-04-09 16:41:27 -07:00
Dean Deng 2b4687a46b Handle os.LinkError in p9/handlers.go.
PiperOrigin-RevId: 305721329
2020-04-09 11:17:11 -07:00
Jamie Liu 8f68be7491 Don't use REP string instructions in safecopy.memcpy.
PiperOrigin-RevId: 305718392
2020-04-09 11:03:43 -07:00
Andrei Vagin 7928aa345e Convert int and bool socket options to use GetSockOptInt and GetSockOptBool
PiperOrigin-RevId: 305699233
2020-04-09 09:31:48 -07:00
Bin Lu ab54d4f496 remove nogo exemption for machine_arm64_unsafe.go
Minimize the use of unsafe.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-04-09 03:54:58 -04:00
Andrei Vagin a10389e783 splice: cap splice calls to MAX_RW_COUNT
The Linux does the same.

Reported-by: syzbot+e81716e8956e92e9d56b@syzkaller.appspotmail.com
PiperOrigin-RevId: 305625439
2020-04-08 23:03:12 -07:00
Jamie Liu 0f75f7273d Don't call platform.AddressSpace.MapFile with no permissions.
PiperOrigin-RevId: 305598136
2020-04-08 18:42:05 -07:00
Fabricio Voznika 6dd5a1f3fe Clean up TODOs
PiperOrigin-RevId: 305592245
2020-04-08 17:58:13 -07:00
Dean Deng 981a587476 Remove InodeOperations FIXMEs that will be obsoleted by VFS2.
PiperOrigin-RevId: 305588941
2020-04-08 17:34:02 -07:00
Dean Deng 357f136e42 Handle utimes correctly for shared gofer filesystems.
Determine system time from within the sentry rather than relying on the remote
filesystem to prevent inconsistencies.
Resolve related TODOs; the time discrepancies in question don't exist anymore.

PiperOrigin-RevId: 305557099
2020-04-08 14:39:25 -07:00
Jamie Liu d8c0c1d9d5 Do not hold FileDescription references in VFS2 procfs inodes.
FileDescription references are side-effectual; for example, holding a reference
on the write end of a pipe prevents reads from the read end from returning EOF.

This change is consistent with Linux, but not VFS1; while VFS1 also has this
bug, it's less visible there since VFS1 procfs disables caching.

Updates #1195

PiperOrigin-RevId: 305545099
2020-04-08 13:40:27 -07:00
Fabricio Voznika b30130567d Enable SubprocessExited and SubprocessZombie for gVisor
Updates #164

PiperOrigin-RevId: 305544029
2020-04-08 13:34:44 -07:00
Adin Scannell 867eeb18d8 Remove lostcancel warnings.
Updates #2243
2020-04-08 10:14:34 -07:00
Adin Scannell f888b9ce83 Fix unused result errors.
This fixes a bug in the proc net directory.

Updates #2243
2020-04-08 10:14:34 -07:00
Adin Scannell 928a7c60b8 Fix all printf formatting errors.
Updates #2243
2020-04-08 10:14:34 -07:00
Adin Scannell 94b793262d Fix all copy locks violations.
This required minor restructuring of how system call tables were saved
and restored, but it makes way more sense this way.

Updates #2243
2020-04-08 10:00:14 -07:00
Fabricio Voznika 5a1324625f Make unlink tests pass with goferfs
Required directory checks were being skipped when there was
no child cached. Now the code always loads the child file
before unlinking it.

Updates #1198

PiperOrigin-RevId: 305382323
2020-04-07 18:27:55 -07:00
Dean Deng 693b6bdda9 Correctly distinguish between seekable and non-seekable host fds.
Check whether an fd is seekable by calling the seek syscall and
examining the return value, instead of checking the file type,
which is inaccurate.

PiperOrigin-RevId: 305361593
2020-04-07 16:17:40 -07:00
Ting-Yu Wang d5ddb53650 Remove out-of-date TODOs.
We already have network namespace for netstack.

PiperOrigin-RevId: 305341954
2020-04-07 14:33:48 -07:00
Ghanan Gowripalan 6db55a5bd8 Require that IPv6 headers be in the first fragment
Test:
- header_test.TestIPv6ExtHdrIter
- ipv6_test.TestReceiveIPv6Fragments

Updates #2197, #2333

PiperOrigin-RevId: 305330178
2020-04-07 13:37:10 -07:00
Fabricio Voznika 94319a8241 Make gofer.dentry.destroyLocked idempotent
gofer operations accumulate dentries touched in a slice to call
checkCachingLocked on them when the operation is over. In case
the same dentry is touched multiple times during the operation,
checkCachingLocked, and consequently destroyLocked, may be called
more than once for the same dentry.

Updates #1198

PiperOrigin-RevId: 305276819
2020-04-07 09:41:58 -07:00
Dean Deng 51e461cf9c Add concurrency guarantees to p9 extended attribute methods.
PiperOrigin-RevId: 305171772
2020-04-06 20:08:51 -07:00
Jamie Liu dd98fdd5be Correctly implement magic symlinks in VFS2 procfs.
Updates #1195

PiperOrigin-RevId: 305143567
2020-04-06 16:32:37 -07:00
Nicolas Lacasse f332a864e8 Port timerfd to VFS2.
PiperOrigin-RevId: 305067208
2020-04-06 10:52:56 -07:00
Dean Deng 00d9776a4b Add socket files to tmpfs VFS2.
Updates #1476.

PiperOrigin-RevId: 305024274
2020-04-06 07:31:27 -07:00
Dean Deng 24bee1c181 Record VFS2 sockets in global socket map.
Updates #1476, #1478, #1484, #1485.

PiperOrigin-RevId: 304845354
2020-04-04 21:02:42 -07:00