Commit Graph

2655 Commits

Author SHA1 Message Date
Ting-Yu Wang 69da42885a Enable ARP resolution in TAP devices.
PiperOrigin-RevId: 301208471
2020-03-16 12:03:27 -07:00
gVisor bot 159a230b9b Merge pull request #1943 from kevinGC:ipt-filter-ip
PiperOrigin-RevId: 301197007
2020-03-16 11:13:14 -07:00
Bhasker Hariharan 52758e16e0 Prevent vnetHdr from escaping in WritePacket.
PiperOrigin-RevId: 301157950
2020-03-16 08:03:27 -07:00
Fabricio Voznika 9712775028 Disallow kernfs.Inode.SetStat for readonly inodes
Updates #1195, #1193

PiperOrigin-RevId: 300950993
2020-03-14 13:48:06 -07:00
Dean Deng 5e413cad10 Plumb VFS2 imported fds into virtual filesystem.
- When setting up the virtual filesystem, mount a host.filesystem to contain
  all files that need to be imported.
- Make read/preadv syscalls to the host in cases where preadv2 may not be
  supported yet (likewise for writing).
- Make save/restore functions in kernel/kernel.go return early if vfs2 is
  enabled.

PiperOrigin-RevId: 300922353
2020-03-14 07:14:33 -07:00
Fabricio Voznika 45a8ae240d Add remaining procfs files
Closes #1195

PiperOrigin-RevId: 300867055
2020-03-13 18:57:07 -07:00
Fabricio Voznika 829beebf0b Panic if file in FDTable has been destroyed
This will give more information about the file to
identify where possibly the extra DecRef()
would be.

PiperOrigin-RevId: 300855874
2020-03-13 17:18:10 -07:00
Jamie Liu b0f2c3e764 Fix infinite loop in semaphore.sem.wakeWaiters().
PiperOrigin-RevId: 300845134
2020-03-13 16:09:18 -07:00
Zach Koopmans d8cf54f20f Internal change
PiperOrigin-RevId: 300836270
2020-03-13 15:18:14 -07:00
Michael Pratt 6d4497de25 Fix typo
PiperOrigin-RevId: 300832988
2020-03-13 15:02:42 -07:00
Ghanan Gowripalan 645b1b2e9c Refactor SLAAC address state into SLAAC prefix state
Previously, SLAAC related state was stored on a per-address basis. This was
sufficient for the simple case of a single SLAAC address per prefix, but
future CLs will introduce temporary addresses which will result in multiple
SLAAC addresses for a prefix. This refactor allows storing multiple addresses
for a prefix in a single SLAAC prefix state.

No behaviour changes - existing tests continue to pass.

PiperOrigin-RevId: 300832812
2020-03-13 14:59:19 -07:00
Jamie Liu 1c05352970 Fix oom_score_adj.
- Make oomScoreAdj a ThreadGroup field (Linux: signal_struct::oom_score_adj).

- Avoid deadlock caused by Task.OOMScoreAdj()/SetOOMScoreAdj() locking Task.mu
  and TaskSet.mu in the wrong order (via Task.ExitState()).

PiperOrigin-RevId: 300814698
2020-03-13 13:19:13 -07:00
Ghanan Gowripalan 530a31f3c0 Disable a NIC before removing it
When a NIC is removed, attempt to disable the NIC first to cleanup
dynamic state and stop ongoing periodic tasks (e.g. IPv6 router
solicitations, DAD) so that a removed NIC does not attempt to send
packets.

Tests:
    - stack_test.TestRemoveUnknownNIC
    - stack_test.TestRemoveNIC
    - stack_test.TestDADStop
    - stack_test.TestCleanupNDPState
    - stack_test.TestRouteWithDownNIC
    - stack_test.TestStopStartSolicitingRouters
PiperOrigin-RevId: 300805857
2020-03-13 12:30:16 -07:00
Jamie Liu 86409c9181 Avoid unnecessary work in transportDemuxer.deliverPacket().
- Don't allocate []*endpointsByNic in transportDemuxer.deliverPacket() unless
  actually needed for UDP broadcast/multicast.

- Don't allocate []*endpointsByNic via transportDemuxer.findEndpointLocked()
  => transportDemuxer.findAllEndpointsLocked().

- Skip unnecessary map lookups in transportDemuxer.findEndpointLocked() =>
  transportDemuxer.findAllEndpointsLocked() (now iterEndpointsLocked).

For most deliverable packets other than UDP broadcast/multicast packets, this
saves two slice allocations and three map lookups per packet.

PiperOrigin-RevId: 300804135
2020-03-13 12:22:19 -07:00
Jamie Liu b78cee3bae Fix lock recursion in kernel.ProcessGroup.SendSignal().
PiperOrigin-RevId: 300803515
2020-03-13 12:18:36 -07:00
Fabricio Voznika 722abdd833 Skip process if it has exited
PiperOrigin-RevId: 300802159
2020-03-13 12:11:13 -07:00
Zach Koopmans b8fda7f34f Run "startup" benchmark in Kokoro benchmark job.
PiperOrigin-RevId: 300798423
2020-03-13 11:51:50 -07:00
Dean Deng 2e38408f20 Implement access/faccessat for VFS2.
Note that the raw faccessat system call does not actually take a flags argument;
according to faccessat(2), the glibc wrapper implements the flags by using
fstatat(2). Remove the flag argument that we try to extract from vfs1, which
would just be a garbage value.

Updates #1965
Fixes #2101

PiperOrigin-RevId: 300796067
2020-03-13 11:41:08 -07:00
Ting-Yu Wang f458a325e9 Fix "application exiting with {Code:0 Signo:27}" during boot.
2aa9514a06 skips SIGURG, but later code expects
the sigchans array contains consecutive signal numbers.

PiperOrigin-RevId: 300793450
2020-03-13 11:26:45 -07:00
Ghanan Gowripalan 28d26d2c4f Honour the link's MaxHeaderLength when forwarding
LinkEndpoints may expect/assume that the a tcpip.PacketBuffer's Header
has enough capacity for its own headers, as per documentation for
LinkEndpoint.MaxHeaderLength.

Test: stack_test.TestNICForwarding
PiperOrigin-RevId: 300784192
2020-03-13 10:44:23 -07:00
Fabricio Voznika 8f8f16efaf Add support for mount flags
Plumbs MS_NOEXEC and MS_RDONLY. Others are TODO.

Updates #1623 #1193

PiperOrigin-RevId: 300764669
2020-03-13 08:58:04 -07:00
Eyal Soha f693e1334b Clarify comments about IHL in ipv4.go.
PiperOrigin-RevId: 300668506
2020-03-12 18:39:40 -07:00
Ting-Yu Wang bbf86003bf Remove flaky network namespace test that uses clone().
PiperOrigin-RevId: 300626011
2020-03-12 14:35:25 -07:00
Zach Koopmans 919664600d Mark gonet_test as flaky.
Mark /pkg/tcpip/adapters/gonet/gonet_test as flaky.

PiperOrigin-RevId: 300609529
2020-03-12 13:11:48 -07:00
Fabricio Voznika f2e4b5ab93 Kill sandbox process when parent process terminates
When the sandbox runs in attached more, e.g. runsc do, runsc run, the
sandbox lifetime is controlled by the parent process. This wasn't working
in all cases because PR_GET_PDEATHSIG doesn't propagate through execve
when the process changes uid/gid. So it was getting dropped when the
sandbox execve's to change to user nobody.

PiperOrigin-RevId: 300601247
2020-03-12 12:32:26 -07:00
Tamir Duberstein 035f7434e9 Use a heap in transport demuxer
...instead of sorting at various times. Plug a memory leak by setting
removed elements to nil.

PiperOrigin-RevId: 300471087
2020-03-11 21:13:46 -07:00
Tamir Duberstein ac05043525 Implement heap.Interface on pointer receiver
PiperOrigin-RevId: 300467253
2020-03-11 20:38:05 -07:00
Tamir Duberstein 538e35f61b Fix race condition (*tcp.endpoint).Close
Atomically close the endpoint. Before this change, it was possible for
multiple callers to perform duplicate work.

PiperOrigin-RevId: 300462110
2020-03-11 19:57:25 -07:00
Adin Scannell 61051f2268 Clean-up buffer implementation.
This also adds substantial test cases.

The Read/Write interfaces are dropped as they are not necessary.

PiperOrigin-RevId: 300461547
2020-03-11 19:52:14 -07:00
gVisor bot a9c6135ed7 Merge pull request #2108 from kevinGC:prepare-ipt-tests
PiperOrigin-RevId: 300449422
2020-03-11 18:17:20 -07:00
Bhasker Hariharan 81675b850e Fix memory leak in danglingEndpoints.
Endpoints which were being terminated in an ERROR state or were moved to CLOSED
by the worker goroutine do not run cleanupLocked() as that should already be run
by the worker termination. But when making that change we made the mistake of
not removing the endpoint from the danglingEndpoints which is normally done in
cleanupLocked().

As a result these endpoints are leaked since a reference is held to them in the
danglingEndpoints array forever till Stack is torn down.

PiperOrigin-RevId: 300438426
2020-03-11 17:03:57 -07:00
Kevin Krakauer 4054b021f0 iptables: ready tests to be enabled in kokoro
Fixed flakes (tested via --runs_per_test=100) and added skips for
not-yet-implemented features. Once submitted, the iptables tests will be
ready to enable in kokoro.
2020-03-11 15:13:58 -07:00
Zach Koopmans fd84cddab0 Internal change
PiperOrigin-RevId: 300410856
2020-03-11 14:46:17 -07:00
Michael Pratt 5ee9bbb15d Upgrade Kythe
PiperOrigin-RevId: 300409401
2020-03-11 14:39:21 -07:00
Andrei Vagin 22d89ef5cb Import "unsafe" in bluepill_arm64_unsafe.go
This fixes a compile time error:
pkg/sentry/platform/kvm/bluepill_arm64_unsafe.go:45:35: undefined: unsafe

PiperOrigin-RevId: 300375687
2020-03-11 12:01:46 -07:00
Andrei Vagin d3fa741fb5 runsc: Set asyncpreemptoff for the kvm platform
The asynchronous goroutine preemption is a new feature of Go 1.14.

When we switched to go 1.14 (cl/297915917) in the bazel config,
the kokoro syscall-kvm job started permanently failing. Lets
temporary set asyncpreemptoff for the kvm platform to unblock tests.

PiperOrigin-RevId: 300372387
2020-03-11 11:45:50 -07:00
gVisor bot 2c2622b942 Merge pull request #1975 from nybidari:iptables
PiperOrigin-RevId: 300362789
2020-03-11 11:02:04 -07:00
Andrei Vagin 2aa9514a06 runsc: don't redirect SIGURG which is used by Go's runtime scheduler
Go 1.14+ sends SIGURG to Ms to attempt asynchronous preemption of a G. Since it
can't guarantee that a SIGURG is only related to preemption, it continues to
forward them to signal.Notify (see runtime.sighandler).

When runsc is running a container, there are three processes: a parent process
and two children (sandbox and gopher). A parent process sets a signal handler
for all signals and redirect them to the container init process. This logic
should ignore SIGURG signals. We already ignore them in the Sentry, but it will
be better to not notify about them when this is possible.

PiperOrigin-RevId: 300345286
2020-03-11 09:50:06 -07:00
gVisor bot 7bca09107b Automated rollback of changelist 300217972
PiperOrigin-RevId: 300308974
2020-03-11 06:08:56 -07:00
gVisor bot 24e7005ab6 Merge pull request #1832 from xiaobo55x:tls_ptrace
PiperOrigin-RevId: 300270894
2020-03-11 01:06:19 -07:00
Ghanan Gowripalan f56fe66b13 Honour the link's MaxHeaderLength when forwarding
This change also updates where the IP packet buffer is held in an
outbound tcpip.PacketBuffer from Header to Data. This change removes
unncessary copying of the IP packet buffer when forwarding.

Test: stack_test.TestNICForwarding
PiperOrigin-RevId: 300217972
2020-03-10 17:52:31 -07:00
gVisor bot d6440ec5a1 The packet forwarding should resolve the link address if necessary.
Fixes #1510

Test:
- stack_test.TestForwardingWithStaticResolver
- stack_test.TestForwardingWithFakeResolver
- stack_test.TestForwardingWithNoResolver
- stack_test.TestForwardingWithFakeResolverPartialTimeout
- stack_test.TestForwardingWithFakeResolverTwoPackets
- stack_test.TestForwardingWithFakeResolverManyPackets
- stack_test.TestForwardingWithFakeResolverManyResolutions
PiperOrigin-RevId: 300182570
2020-03-10 14:50:13 -07:00
Ian Lewis 0990ef7517 Make checkpoint/restore e2e test less flaky
PiperOrigin-RevId: 300171916
2020-03-10 13:59:49 -07:00
Ting-Yu Wang b36de6e7be Move /proc/net to /proc/PID/net, and make /proc/net -> /proc/self/net.
Issue #1833

PiperOrigin-RevId: 299998105
2020-03-09 19:59:09 -07:00
Andrei Vagin 2446161b3f perf/signal: rewrite code in assembly to avoid compiler optimizations
Without this change, the assembly code of this test compiled without
optimizations:

mov    -0x150(%rbp),%rax
movl   $0x77777777,(%rax)
lea    -0x128(%rbp),%rax

with optimizations:

movl   $0x77777777,0x0

This code doesn't work properly, because the test changes rax in the segv
handler.

PiperOrigin-RevId: 299896117
2020-03-09 11:53:28 -07:00
Haibo Xu c04958e2fa Enable thread local storage support on arm64.
Linux use the task.thread.uw.tp_value field to store the
TLS pointer on arm64 platform, and we use a similar way
in gvisor to store it in the arch/State struct.

Signed-off-by: Haibo Xu <haibo.xu@arm.com>
Change-Id: Ie76b5c6d109bc27ccfd594008a96753806db7764
2020-03-09 01:04:55 +00:00
gVisor bot ddfc7239be Merge pull request #2055 from google:dependabot/bundler/benchmarks/workloads/ruby/puma-3.12.4
PiperOrigin-RevId: 299485340
2020-03-06 19:08:16 -08:00
dependabot[bot] bc319d29e1
Bump puma from 3.12.2 to 3.12.4 in /benchmarks/workloads/ruby
Bumps [puma](https://github.com/puma/puma) from 3.12.2 to 3.12.4.
- [Release notes](https://github.com/puma/puma/releases)
- [Changelog](https://github.com/puma/puma/blob/master/History.md)
- [Commits](https://github.com/puma/puma/compare/v3.12.2...v3.12.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-03-07 02:31:42 +00:00
gVisor bot bfbfaf325b Merge pull request #2056 from google:dependabot/bundler/benchmarks/workloads/ruby_template/puma-3.12.4
PiperOrigin-RevId: 299480247
2020-03-06 18:30:33 -08:00
Fabricio Voznika b23999f3e4 Fix runsc permissions for "dev.sh --refresh"
PiperOrigin-RevId: 299466906
2020-03-06 17:01:51 -08:00