Commit Graph

3430 Commits

Author SHA1 Message Date
Tamir Duberstein 9d2b2c121f Replace use of %v in sniffer
PiperOrigin-RevId: 315711208
2020-06-10 10:02:41 -07:00
Fabricio Voznika 203dc121f6 Redirect TODOs to more specific issues
Closes #1623

PiperOrigin-RevId: 315681993
2020-06-10 06:51:32 -07:00
Fabricio Voznika 67565078bb Implement flock(2) in VFS2
LockFD is the generic implementation that can be embedded in
FileDescriptionImpl implementations. Unique lock ID is
maintained in vfs.FileDescription and is created on demand.

Updates #1480

PiperOrigin-RevId: 315604825
2020-06-09 18:46:42 -07:00
gVisor bot 52c922f7c0 Merge pull request #2712 from lubinszARM:pr_sigfp_init
PiperOrigin-RevId: 315599736
2020-06-09 18:05:01 -07:00
gVisor bot e3cbfbf349 Merge pull request #2907 from lubinszARM:pr_minor
PiperOrigin-RevId: 315595602
2020-06-09 17:34:41 -07:00
gVisor bot 4950ccde75 Fix write hang bug found by syzkaller.
After this change e.mu is only promoted to exclusively locked during
route.Resolve. It downgrades back to read-lock afterwards.
This prevents the second RLock() call gets stuck later in the stack.

https://syzkaller.appspot.com/bug?id=065b893bd8d1d04a4e0a1d53c578537cde1efe99

Syzkaller logs does not contain interesting stack traces.
The following stack trace is obtained by running repro locally.

goroutine 53 [semacquire, 3 minutes]:
runtime.gopark(0xfd4278, 0x1896320, 0xc000301912, 0x4)
        GOROOT/src/runtime/proc.go:304 +0xe0 fp=0xc0000e25f8 sp=0xc0000e25d8 pc=0x437170
runtime.goparkunlock(...)
        GOROOT/src/runtime/proc.go:310
runtime.semacquire1(0xc0001220b0, 0xc00000a300, 0x1, 0x0)
        GOROOT/src/runtime/sema.go:144 +0x1c0 fp=0xc0000e2660 sp=0xc0000e25f8 pc=0x4484e0
sync.runtime_Semacquire(0xc0001220b0)
        GOROOT/src/runtime/sema.go:56 +0x42 fp=0xc0000e2690 sp=0xc0000e2660 pc=0x448132
gvisor.dev/gvisor/pkg/sync.(*RWMutex).RLock(...)
        pkg/sync/rwmutex_unsafe.go:76
gvisor.dev/gvisor/pkg/tcpip/transport/udp.(*endpoint).HandleControlPacket(0xc000122000, 0x7ee5, 0xc00053c16c, 0x4, 0x5e21, 0xc00053c224, 0x4, 0x1, 0x0, 0xc00007ed00)
        pkg/tcpip/transport/udp/endpoint.go:1345 +0x169 fp=0xc0000e26d8 sp=0xc0000e2690 pc=0x9843f9
......
gvisor.dev/gvisor/pkg/tcpip/transport/udp.(*protocol).HandleUnknownDestinationPacket(0x18bb5a0, 0xc000556540, 0x5e21, 0xc00053c16c, 0x4, 0x7ee5, 0xc00053c1ec, 0x4, 0xc00007e680, 0x4)
        pkg/tcpip/transport/udp/protocol.go:143 +0xb9a fp=0xc0000e8260 sp=0xc0000e7510 pc=0x9859ba
......
gvisor.dev/gvisor/pkg/tcpip/transport/udp.sendUDP(0xc0001220d0, 0xc00053ece0, 0x1, 0x1, 0x883, 0x1405e217ee5, 0x11100a0, 0xc000592000, 0xf88780)
        pkg/tcpip/transport/udp/endpoint.go:924 +0x3b0 fp=0xc0000ed390 sp=0xc0000ec750 pc=0x981af0
gvisor.dev/gvisor/pkg/tcpip/transport/udp.(*endpoint).write(0xc000122000, 0x11104e0, 0xc00020a460, 0x0, 0x0, 0x0, 0x0, 0x0)
        pkg/tcpip/transport/udp/endpoint.go:510 +0x4ad fp=0xc0000ed658 sp=0xc0000ed390 pc=0x97f2dd

PiperOrigin-RevId: 315590041
2020-06-09 17:02:14 -07:00
Fabricio Voznika 6722b1e56f Don't WriteOut to readonly mounts
When the file closes, it attempts to write dirty cached
attributes to the file. This should not be done when the
mount is readonly.

PiperOrigin-RevId: 315585058
2020-06-09 16:36:56 -07:00
Fabricio Voznika 0ae5bd24d7 Mount root and volumes as read-only if --overlay is enabled
PiperOrigin-RevId: 315583963
2020-06-09 16:31:38 -07:00
gVisor bot ea2c11fcf8 Merge pull request #2885 from google:dependabot/bundler/benchmarks/workloads/ruby_template/puma-3.12.6
PiperOrigin-RevId: 315558580
2020-06-09 14:21:35 -07:00
Ghanan Gowripalan 2d3b9d18e7 Handle removed NIC in NDP timer for packet tx
NDP packets are sent periodically from NDP timers. These timers do not
hold the NIC lock when sending packets as the packet write operation
may take some time. While the lock is not held, the NIC may be removed
by some other goroutine. This change handles that scenario gracefully.

Test: stack_test.TestRemoveNICWhileHandlingRSTimer
PiperOrigin-RevId: 315524143
2020-06-09 11:33:20 -07:00
Jamie Liu ecff24930c Ensure pgalloc.MemoryFile.fileSize is always chunk-aligned.
findAvailableLocked() may return a non-aligned FileRange.End after expansion
since it may round FileRange.Start down to a hugepage boundary.

PiperOrigin-RevId: 315520321
2020-06-09 11:16:05 -07:00
Kevin Krakauer 20afd66e01 Invoke bazel query via bash function.
PiperOrigin-RevId: 315514034
2020-06-09 10:48:24 -07:00
Bin Lu b792cc1ca9 minor change in kvm module for Arm64
Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-06-09 05:42:41 -04:00
Bin Lu 5ad1025d2d initialize an empty fp state area for sentry on Arm64
We need to initialize an empty fp state area for the sentry.

Signed-off-by: Bin Lu <bin.lu@arm.com>
2020-06-09 05:01:03 -04:00
Fabricio Voznika 4e96b94915 Combine executable lookup code
Run vs. exec, VFS1 vs. VFS2 were executable lookup were
slightly different from each other. Combine them all
into the same logic.

PiperOrigin-RevId: 315426443
2020-06-08 23:08:23 -07:00
Andrei Vagin 12f9094761 test/runtimes/proctor: remove an unknown nocgo attribute from go_test rule
PiperOrigin-RevId: 315353408
2020-06-08 14:29:43 -07:00
gVisor bot ac37979ca8 Merge pull request #1875 from zhiqiangxu:fix_scope_add
PiperOrigin-RevId: 315341669
2020-06-08 13:34:58 -07:00
Jamie Liu dc029b4b96 Implement VFS2 tmpfs mount options.
As in VFS1, the mode, uid, and gid options are supported.

Updates #1197

PiperOrigin-RevId: 315340510
2020-06-08 13:28:18 -07:00
Kevin Krakauer 32b823fcdb netstack: parse incoming packet headers up-front
Netstack has traditionally parsed headers on-demand as a packet moves up the
stack. This is conceptually simple and convenient, but incompatible with
iptables, where headers can be inspected and mangled before even a routing
decision is made.

This changes header parsing to happen early in the incoming packet path, as soon
as the NIC gets the packet from a link endpoint. Even if an invalid packet is
found (e.g. a TCP header of insufficient length), the packet is passed up the
stack for proper stats bookkeeping.

PiperOrigin-RevId: 315179302
2020-06-07 13:38:43 -07:00
gVisor bot 6260304179 Merge pull request #2788 from lubinszARM:pr_exec_2
PiperOrigin-RevId: 315166991
2020-06-07 09:56:53 -07:00
gVisor bot 427d208216 Merge pull request #2872 from kevinGC:ipt-skip-prerouting
PiperOrigin-RevId: 315041419
2020-06-05 20:44:01 -07:00
Rahat Mahmood 21b6bc7280 Implement mount(2) and umount2(2) for VFS2.
This is mostly syscall plumbing, VFS2 already implements the internals of
mounts. In addition to the syscall defintions, the following mount-related
mechanisms are updated:

- Implement MS_NOATIME for VFS2, but only for tmpfs and goferfs. The other VFS2
  filesystems don't implement node-level timestamps yet.

- Implement the 'mode', 'uid' and 'gid' mount options for VFS2's tmpfs.

- Plumb mount namespace ownership, which is necessary for checking appropriate
  capabilities during mount(2).

Updates #1035

PiperOrigin-RevId: 315035352
2020-06-05 19:12:03 -07:00
Adin Scannell 527d08f6af Add +checkescape annotations to kvm/ring0.
This analysis also catches a potential bug, which is a split on mapPhysical.
This would have led to potential guest-exit during Mapping (although this
would have been handled by the now-unecessary retryInGuest loop).

PiperOrigin-RevId: 315025106
2020-06-05 17:25:28 -07:00
Adin Scannell 8d8dce418f Add stale issue & PR cleanup.
PiperOrigin-RevId: 315020368
2020-06-05 16:51:58 -07:00
Kevin Krakauer 74a7d76c97 iptables: loopback traffic skips prerouting chain
Loopback traffic is not affected by rules in the PREROUTING chain.

This change is also necessary for istio's envoy to talk to other
components in the same pod.
2020-06-05 16:43:50 -07:00
Adin Scannell f385e581a5 Drop flaky tag.
PiperOrigin-RevId: 315018295
2020-06-05 16:39:08 -07:00
Adin Scannell 9aaca5a6da Use top-down allocation for pgalloc.
This change has multiple small components.

First, the chunk size is bumped to 1GB in order to avoid creating excessive
VMAs in the Sentry, which can lead to VMA exhaustion (and hitting limits).

Second, gap-tracking is added to the usage set in order to efficiently scan
for available regions.

Third, reclaim is moved to a simple segment set. This is done to allow the
order of reclaim to align with the Allocate order (which becomes much more
complex when trying to track a "max page" as opposed to "min page", so we
just track explicit segments instead, which should make reclaim scanning
faster anyways).

Finally, the findAvailable function attempts to scan from the top-down, in
order to maximize opportunities for VMA merging in applications (hopefully
preventing the same VMA exhaustion that can affect the Sentry).

PiperOrigin-RevId: 315009249
2020-06-05 15:39:57 -07:00
Andrei Vagin 8c1f5b5cd8 Unshare files on exec
The current task can share its fdtable with a few other tasks,
but after exec, this should be a completely separate process.

PiperOrigin-RevId: 314999565
2020-06-05 14:45:32 -07:00
Nicolas Lacasse e4e11f2798 Expand syscall filters to support MSAN.
PiperOrigin-RevId: 314997564
2020-06-05 14:33:50 -07:00
Rahat Mahmood 6d9a68ca41 Centralize the categories of endpoint states.
PiperOrigin-RevId: 314996457
2020-06-05 14:28:05 -07:00
dependabot[bot] 7f92190795
Bump puma from 3.12.4 to 3.12.6 in /benchmarks/workloads/ruby_template
Bumps [puma](https://github.com/puma/puma) from 3.12.4 to 3.12.6.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2020-06-05 21:25:29 +00:00
Bhasker Hariharan 526df4f52a Fix error code returned due to Port exhaustion.
For TCP sockets gVisor incorrectly returns EAGAIN when no ephemeral ports are
available to bind during a connect. Linux returns EADDRNOTAVAIL. This change
fixes gVisor to return the correct code and adds a test for the same.

This change also fixes a minor bug for ping sockets where connect() would fail
with EINVAL unless the socket was bound first.

Also added tests for testing UDP Port exhaustion and Ping socket port
exhaustion.

PiperOrigin-RevId: 314988525
2020-06-05 13:43:01 -07:00
gVisor bot 45bf7492ef Merge pull request #2879 from avagin:test-hostinet
PiperOrigin-RevId: 314970516
2020-06-05 12:05:07 -07:00
Nicolas Lacasse d208bb86ac Merge pull request #2789 from Rajpratik71:optimization/git-clone
PiperOrigin-RevId: 314855924
2020-06-05 11:29:53 -07:00
Ting-Yu Wang 41da7a568b Fix copylocks error about copying IPTables.
IPTables.connections contains a sync.RWMutex. Copying it will trigger copylocks
analysis. Tested by manually enabling nogo tests.

sync.RWMutex is added to IPTables for the additional race condition discovered.

PiperOrigin-RevId: 314817019
2020-06-05 11:29:09 -07:00
Mithun Iyer f766366091 Handle TCP segment split cases as per MSS.
- Always split segments larger than MSS.
  Currently, we base the segment split decision as a function of the
  send congestion window and MSS, which could be greater than the MSS
  advertised by remote.
- While splitting segments, ensure the PSH flag is reset when there
  are segments that are queued to be sent.
- With TCP_CORK, hold up segments up until MSS. Fix a bug in computing
  available send space before attempting to coalesce segments.

Fixes #2832

PiperOrigin-RevId: 314802928
2020-06-05 11:28:24 -07:00
Andrei Vagin d61e88e342 Remove gvisor/pkg/tmutex
It isn't used.

PiperOrigin-RevId: 314775492
2020-06-05 11:27:39 -07:00
Ian Lewis 51c61cb2dc Add back gitter badge.
PiperOrigin-RevId: 314630516
2020-06-05 11:26:50 -07:00
Andrei Vagin 9e66ac4c20 test/syscall: run hostnet tests in separate network namespaces
A few tests use hard coded port numbers, so we need to guruantee that
these ports will not be used for somthing else.
2020-06-04 18:23:45 -07:00
Ting-Yu Wang d3a8bffe04 Pass PacketBuffer as pointer.
Historically we've been passing PacketBuffer by shallow copying through out
the stack. Right now, this is only correct as the caller would not use
PacketBuffer after passing into the next layer in netstack.

With new buffer management effort in gVisor/netstack, PacketBuffer will
own a Buffer (to be added). Internally, both PacketBuffer and Buffer may
have pointers and shallow copying shouldn't be used.

Updates #2404.

PiperOrigin-RevId: 314610879
2020-06-03 15:00:42 -07:00
Zach Koopmans d8d86f0f3a Add test for O_TRUNC
b/36576592 calls out an edge case previously not supported
by HostFS. HostFS is currently being removed, meaning gVisor
supports this feature. Simply add the test to open_test.

PiperOrigin-RevId: 314610226
2020-06-03 14:56:04 -07:00
Nicolas Lacasse 7da69fe971 Fix data race on f.offset.
We must hold f.mu to write f.offset.

PiperOrigin-RevId: 314582968
2020-06-03 12:35:13 -07:00
Michael Pratt b2e2a081a8 Add metric for startup watchdog timeout
PiperOrigin-RevId: 314570894
2020-06-03 11:37:10 -07:00
Adin Scannell fa9c905505 Fix test release commands to work with older GPG.
The --quick-generate-key command wasn't added until recently.

PiperOrigin-RevId: 314570297
2020-06-03 11:32:11 -07:00
Jamie Liu c8e7968389 Take Mount reference in VFS.connectLocked.
Updates #179

PiperOrigin-RevId: 314563830
2020-06-03 11:02:57 -07:00
Mithun Iyer 162848e129 Avoid TCP segment split when out of sender window.
If the entire segment cannot be accommodated in the receiver advertised
window and if there are still unacknowledged pending segments, skip
splitting the segment. The segment transmit would get retried by the
retransmit handler.

PiperOrigin-RevId: 314538523
2020-06-03 08:49:49 -07:00
Andrei Vagin e6334e81ca Check that two sockets with different types can't be connected to each other
PiperOrigin-RevId: 314450191
2020-06-02 19:19:15 -07:00
gVisor bot c615faaee4 Merge pull request #2855 from ridwanmsharif:ridwanmsharif/fuse-doc-edit
PiperOrigin-RevId: 314449030
2020-06-02 19:08:49 -07:00
Michael Pratt 43279c6734 Fix typos
PiperOrigin-RevId: 314415253
2020-06-02 15:29:26 -07:00
gVisor bot b062821d3e Merge pull request #2837 from avagin:make-startup-option
PiperOrigin-RevId: 314415164
2020-06-02 15:24:33 -07:00