Commit Graph

2159 Commits

Author SHA1 Message Date
Jay Zhuang 65f53c5833 Put GetSocketPairs() in unnamed namespace
This avoids conflicting definitions of GetSocketPairs() in outer namespace when
multiple such cc files are complied for one binary.

PiperOrigin-RevId: 286243045
2019-12-18 12:50:04 -08:00
Michael Pratt 803437c96b Upgrade to Python 3
Python 3 tools must be listed in exec_tools for genrules.

PiperOrigin-RevId: 286241702
2019-12-18 12:23:03 -08:00
Bin Lu eb868be743 supporting lazy-fpsimd in guest on Arm64
Several jobs were finished in this patch:
1, provide functions to get/set fpcr/fpsr/vregs
2, support lazy-fpsimd-context-switch in el1

Signed-off-by: Bin Lu <bin.lu@arm.com>
2019-12-18 16:45:15 +08:00
Kevin Krakauer 64d00cc63d Internal change.
PiperOrigin-RevId: 286083614
2019-12-17 16:21:48 -08:00
gVisor bot 725e73eed0 Merge pull request #1393 from ernado:cpu-num-from-quota
PiperOrigin-RevId: 286068605
2019-12-17 15:07:45 -08:00
Michael Pratt 91f1ac7319 Mark enableCpuidFault nosplit
This is called after fork, so it must be nosplit.

Updates #1408

PiperOrigin-RevId: 286053054
2019-12-17 14:18:54 -08:00
gVisor bot 3ab90ecf25 Merge pull request #1394 from zhuangel:bindlock
PiperOrigin-RevId: 286051631
2019-12-17 13:53:16 -08:00
gVisor bot e416724fb3 Merge pull request #1321 from lubinszARM:pr_testutils_vfp
PiperOrigin-RevId: 286042427
2019-12-17 13:10:50 -08:00
gVisor bot 3f4d8fefb4 Internal change.
PiperOrigin-RevId: 286003946
2019-12-17 10:10:06 -08:00
Aleksandr Razumov 67f678be27
Leave minimum CPU number as a constant
Remove introduced CPUNumMin config and hard-code it as 2.
2019-12-17 20:41:02 +03:00
gVisor bot 67000b929b Explicitly export files needed by other packages
PiperOrigin-RevId: 285968611
2019-12-17 06:33:08 -08:00
Aleksandr Razumov b661434202
Add minimum CPU number and only lower CPUs on --cpu-num-from-quota
* Add `--cpu-num-min` flag to control minimum CPUs
* Only lower CPU count
* Fix comments
2019-12-17 13:27:13 +03:00
Nicolas Lacasse 0881abdfdd Remove useless comments from p9/handlers.go.
These comments provided nothing, and have been copy-pasted into all
implementations. The code is clear without them.

I considered also removing the "handle implements handler.handle" comments, but
will let those stay for now.

PiperOrigin-RevId: 285876428
2019-12-16 16:32:59 -08:00
gVisor bot 2e2545b458 Merge pull request #1392 from zhuangel:bindleak
PiperOrigin-RevId: 285874181
2019-12-16 16:21:17 -08:00
Dean Deng 3193b2fff8 Drop unnecessary cast.
Bitshift operators with signed int is supported in Go 1.13.

PiperOrigin-RevId: 285853622
2019-12-16 14:41:20 -08:00
Dean Deng e6f4124afd Implement checks for get/setxattr at the syscall layer.
Add checks for input arguments, file type, permissions, etc. that match
the Linux implementation. A call to get/setxattr that passes all the
checks will still currently return EOPNOTSUPP. Actual support will be
added in following commits.

Only allow user.* extended attributes for the time being.

PiperOrigin-RevId: 285835159
2019-12-16 13:20:07 -08:00
Yong He bd5c7bf58d Fix deadlock in overlay bind
Copy up parent when binding UDS on overlayfs is supported in commit
02ab1f187c.
But the using of copyUp in overlayBind will cause sentry stuck, reason
is dead lock in renameMu.

1 [Process A] Invoke a Unix socket bind operation
  renameMu is hold in fs.(*Dirent).genericCreate by process A
2 [Process B] Invoke a read syscall on /proc/task/mounts
  waitng on Lock of renameMu in fs.(*MountNamespace).FindMount
3 [Process A] Continue Unix socket bind operation
  wating on RLock of renameMu in fs.copyUp

Root cause is recursive reading lock of reanmeMu in bind call trace,
if there are writing lock between the two reading lock, then deadlock
occured.

Fixes #1397
2019-12-16 18:37:35 +08:00
Yong He 8a46e83111 Fix UDS bind cause fd leak in gofer
After the finalizer optimize in 76039f8959
commit, clientFile needs to closed before finalizer release it.
The clientFile is not closed if it is created via
gofer.(*inodeOperations).Bind, this will cause fd leak which is hold
by gofer process.

Fixes #1396

Signed-off-by: Yong He <chenglang.hy@antfin.com>
Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
2019-12-16 18:28:10 +08:00
Aleksandr Razumov 8782f0e287
Set CPU number to CPU quota
When application is not cgroups-aware, it can spawn excessive threads
which often defaults to CPU number.
Introduce a opt-in flag that will set CPU number accordingly to CPU
quota (if available).

Fixes #1391
2019-12-15 21:12:43 +03:00
lubinszARM 6b42453039 enable kvm to support arm64
There are 4 jobs were finished in this package:
  	1, Virtual machine initialization.
	2, Bluepill implementation.
	3, Move ring0.Vectors() into the address with 11-bits alignment.
	4, Basic support for "SwitchToUser".
Signed-off-by: Bin Lu <bin.lu@arm.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/919 from lubinszARM:pr_kvm eedea52db451bf62722759009a9f14c54a69c55f
PiperOrigin-RevId: 285501256
2019-12-13 17:11:23 -08:00
Ghanan Gowripalan ad80dcf470 Properly generate the EUI64 interface identifier from an Ethernet address
Fixed a bug where the interface identifier was not properly generated from an
Ethernet address.

Tests: Unittests to make sure the functions generating the EUI64 interface
identifier are correct.
PiperOrigin-RevId: 285494562
2019-12-13 16:41:41 -08:00
Kevin Krakauer be2754a4b9 Add iptables testing framework.
It would be preferrable to test iptables via syscall tests, but there are some
problems with that approach:

* We're limited to loopback-only, as syscall tests involve only a single
  container. Other link interfaces (e.g. fdbased) should be tested.
* We'd have to shell out to call iptables anyways, as the iptables syscall
  interface itself is too large and complex to work with alone.
* Running the Linux/native version of the syscall test will require root, which
  is a pain to configure, is inherently unsafe, and could leave host iptables
  misconfigured.

Using the go_test target allows there to be no new test runner.

PiperOrigin-RevId: 285274275
2019-12-12 14:42:11 -08:00
Jamie Liu 93d429d5b1 Implement memmap.MappingIdentity for vfs.FileDescription.
PiperOrigin-RevId: 285255855
2019-12-12 13:19:33 -08:00
Rahat Mahmood 007707a072 Implement kernfs.
PiperOrigin-RevId: 285231002
2019-12-12 11:20:47 -08:00
Andrei Vagin 378d6c1f36 unix: allow to bind unix sockets only to AF_UNIX addresses
Reported-by: syzbot+2c0bcfd87fb4e8b7b009@syzkaller.appspotmail.com
PiperOrigin-RevId: 285228312
2019-12-12 11:08:56 -08:00
Bhasker Hariharan b9aa62b9f9 Enable IPv6 in runsc
Fixes #1341

PiperOrigin-RevId: 285108973
2019-12-11 19:14:26 -08:00
Bhasker Hariharan 6fc9f0aefd Add support for TCP_USER_TIMEOUT option.
The implementation follows the linux behavior where specifying
a TCP_USER_TIMEOUT will cause the resend timer to honor the
user specified timeout rather than the default rto based timeout.

Further it alters when connections are timedout due to keepalive
failures. It does not alter the behavior of when keepalives are
sent. This is as per the linux behavior.

PiperOrigin-RevId: 285099795
2019-12-11 17:52:53 -08:00
Dean Deng 1601e78a52 Add syscall tests for getxattr and setxattr.
Support for getxattr and setxattr are in subsequent commits.

PiperOrigin-RevId: 285088817
2019-12-11 16:41:17 -08:00
Zach Koopmans e2e3b38460 GCloudProducer: tunnel_dispatch, mock_recorder, and machine.
Work to import GCloudProducer, written in gerrit, which is
too large to do in one CL. GCloudProducer sets up gcloud
instances to run benchmark workloads.

Included are:
- gcloud_mock_recorder - used to Mock GCloudProducer
- tunnel_dispatcher - updates to this module to bring it in line
with the style guide
- machine - updates to this module to bring it in line with the
 style guide

All changes are independent of the rest of the changes, and
should "just build".

PiperOrigin-RevId: 285076423
2019-12-11 15:51:41 -08:00
Brad Burlage e690651c67 Run kythe build with -std=c++17
We seem to be getting some compiler errors when using the Kythe
extractors.bazelrc.

I'm not able to reproduce this on my local machine, so I'm hoping copying the
cxxopt from gvisor.dev/pr/1350 will fix the build.

PiperOrigin-RevId: 285054258
2019-12-11 14:48:11 -08:00
Jamie Liu 481dbfa5ab Add vfs.Pathname{WithDeleted,ForGetcwd}.
The former is needed for vfs.FileDescription to implement
memmap.MappingIdentity, and the latter is needed to implement getcwd(2).

PiperOrigin-RevId: 285051855
2019-12-11 14:26:32 -08:00
Michael Pratt 0d027262e0 Add additional packages to go branch
We're missing several packages that runsc doesn't depend on. Most notable are
several tcpip link packages.

To find packages, I looked at a diff of directories on master vs go:

$ bazel build //:gopath
$ find bazel-bin/gopath/src/gvisor.dev/gvisor/ -type d > /tmp/gopath.txt
$ find . -type d > /tmp/master.txt
$ sed 's|bazel-bin/gopath/src/gvisor.dev/gvisor/||' < /tmp/gopath.txt > /tmp/gopath.trunc.txt
$ sed 's|./||' < /tmp/master.txt > /tmp/master.trunc.txt
$ vimdiff /tmp/gopath.trunc.txt /tmp/master.trunc.txt

Testing packages are still left out because :gopath can't depend on testonly
targets...

PiperOrigin-RevId: 285049029
2019-12-11 14:22:36 -08:00
gVisor bot b80cba6126 Merge pull request #1248 from xiaobo55x:ptrace
PiperOrigin-RevId: 285038987
2019-12-11 13:52:24 -08:00
Andrei Vagin f8c5ad061b runsc/debug: add an option to list all processes
runsc debug --ps list all processes with all threads. This option is added to
the debug command but not to the ps command, because it is going to be used for
debug purposes and we want to add any useful information without thinking about
backward compatibility.

This will help to investigate syzkaller issues.

PiperOrigin-RevId: 285013668
2019-12-11 11:05:41 -08:00
Dean Deng 1643224af0 Finish incomplete comment.
PiperOrigin-RevId: 285012278
2019-12-11 10:37:35 -08:00
Dean Deng 2e3b9b0a68 Deduplicate and simplify control message processing for recvmsg and sendmsg.
Also, improve performance by calculating how much space is needed before making
an allocation for sendmsg in hostinet.

PiperOrigin-RevId: 284898581
2019-12-10 19:27:42 -08:00
Jamie Liu 46651a7d26 Add most VFS methods for syscalls.
PiperOrigin-RevId: 284892289
2019-12-10 18:21:07 -08:00
Ghanan Gowripalan 4ff71b5be4 Inform the integrator on receipt of an NDP Recursive DNS Server option
This change adds support to let an integrator know when it receives an NDP
Router Advertisement message with the NDP Recursive DNS Server option with at
least one DNS server's address. The stack will not maintain any state related to
the DNS servers - the integrator is expected to maintain any required state and
invalidate the servers after its valid lifetime expires, or refresh the lifetime
when a new one is received for a known DNS server.

Test: Unittest to make sure that an event is sent to the integrator when an NDP
Recursive DNS Server option is received with at least one address.
PiperOrigin-RevId: 284890502
2019-12-10 18:05:23 -08:00
Brad Burlage a0aa784ecf Remove pyenv calls but log the python 3 version in use.
Apparently our Kokoro VM images don't have pyenv -- I previously tested this on
the Kokoro QA shared pool.

PiperOrigin-RevId: 284855160
2019-12-10 14:55:35 -08:00
Brad Burlage 87337e92e3 Add Kokoro configs for publishing Kythe xrefs.
PiperOrigin-RevId: 284835614
2019-12-10 13:25:27 -08:00
Dean Deng 39386d78bb Format fd_set parameters in select(2)/pselect(2) for strace.
I1202 14:55:06.835076    7991 x:0] [   1] select_test E
  select(0xa, 0x7fc6ce924c28 [0 1], null, null, 0x7fc6ce924c08 {sec=0 usec=0})
I1202 14:55:06.835102    7991 x:0] [   1] select_test X
  select(0xa, 0x7fc6ce924c28 [0 1], null, null, 0x7fc6ce924c08 {sec=0 usec=0})

PiperOrigin-RevId: 284831805
2019-12-10 13:06:01 -08:00
Dean Deng 769e1cdcbe Re-enable execveat test that was causing files in /bin to be deleted.
Test now no longer deletes files incorrectly, due to a fix in fs utils
used by TempPath (github.com/google/gvisor/pull/1368).

Fixes #1366

PiperOrigin-RevId: 284814605
2019-12-10 11:42:03 -08:00
Dean Deng f6e87be82f Let socket.ControlMessages Release() the underlying transport.ControlMessages.
PiperOrigin-RevId: 284804370
2019-12-10 11:36:08 -08:00
Dean Deng f47eaffd5c Do not consider symlinks as directories in fs utils.
IsDirectory() is used in RecursivelyDelete(), which should not follow symlinks.
The only other use (syscalls/linux/rename.cc) is not affected by this change.

Updates #1366.

PiperOrigin-RevId: 284803968
2019-12-10 11:09:44 -08:00
Michael Pratt c15be3f8cf Add all upstream syscalls to tables
Package strace is missing some syscalls we actually implement (e.g.,
getrandom). We also see newer syscalls sometimes (e.g., membarrier) that would
be handy to have formatted.

Let's go ahead and add all syscalls in the latest upstream release (v5.4), even
though we only intend to implement v4.4. None of them are implemented, just
included as placeholders.

PiperOrigin-RevId: 284797577
2019-12-10 10:42:09 -08:00
Dean Deng 30f7316dc4 Make comments clearer for control message handling.
PiperOrigin-RevId: 284791600
2019-12-10 10:01:06 -08:00
Dean Deng aadbf322c6 Disable execveat test that is causing files in /bin to be deleted.
Disable until gvisor.dev/issue/1366 is resolved.

Updates #1366

PiperOrigin-RevId: 284786895
2019-12-10 09:41:07 -08:00
Dean Deng 4a19ebd431 Add hostinet tests for sendmsg and recvmsg with TOS/TCLASS.
PiperOrigin-RevId: 284786069
2019-12-10 09:34:38 -08:00
Ian Gudger 98aafb1334 Add test for SO_BINDTODEVICE state bug.
This was accidentally dropped from the change which fixed the bug.

Updates #1217

PiperOrigin-RevId: 284689362
2019-12-09 20:09:23 -08:00
Ian Gudger 18af75db9d Add UDP SO_REUSEADDR support to the port manager.
Next steps include adding support to the transport demuxer and the UDP endpoint.

PiperOrigin-RevId: 284652151
2019-12-09 15:53:00 -08:00