Commit Graph

4360 Commits

Author SHA1 Message Date
Adin Scannell ecf9a7ef09 Add precise synchronization to KVM.
By using TSC scaling as a hack, we can trick the kernel into setting an offset
of exactly zero. Huzzah!

PiperOrigin-RevId: 335922019
2020-10-07 12:08:09 -07:00
Dean Deng 7e55ee14eb Fix text processing in bazel build command.
The extraction of the build target was overfitted before, making build_cmd fail
in some environments.

PiperOrigin-RevId: 335916651
2020-10-07 11:45:26 -07:00
Peter Johnston 95cac27d0d Discard invalid Neighbor Solicitations
...per RFC 4861 s7.1.1.

PiperOrigin-RevId: 335742851
2020-10-06 16:17:24 -07:00
Arthur Sfez 99bf022c2a Add support for IPv6 fragmentation
Most of the IPv4 fragmentation code was moved in the fragmentation
package and it is reused by IPv6 fragmentation.

Test:
  - pkg/tcpip/network/ipv4:ipv4_test
  - pkg/tcpip/network/ipv6:ipv6_test
  - pkg/tcpip/network/fragmentation:fragmentation_test

Fixes #4389

PiperOrigin-RevId: 335714280
2020-10-06 14:03:39 -07:00
gVisor bot b761330ca7 Merge pull request #4355 from majek:marek/swallow-SO_RCVBUFFORCE-error
PiperOrigin-RevId: 335714100
2020-10-06 14:02:07 -07:00
Jamie Liu 1336af78d5 Implement membarrier(2) commands other than *_SYNC_CORE.
Updates #267

PiperOrigin-RevId: 335713923
2020-10-06 13:55:16 -07:00
gVisor bot 3dc3fb2375 Fix typo in merkletree
PiperOrigin-RevId: 335709552
2020-10-06 13:35:31 -07:00
gVisor bot 68e1dfa308 Merge pull request #3150 from wietsevenema:patch-2
PiperOrigin-RevId: 335702168
2020-10-06 13:01:23 -07:00
Dean Deng a57dc67b63 [vfs2] Don't leak reference from Mountnamespace.Root().
PiperOrigin-RevId: 335583637
2020-10-06 00:21:02 -07:00
Julian Elischer 798cc6b04d Fix IPv4 ICMP echo handler to copy options
The IPv4 RFCs are specific (though obtuse) that an echo response
packet needs to contain all the options from the echo request,
much as if it been routed back to the sender, though apparently
with a new TTL. They suggest copying the incoming packet header
to achieve this so that is what this patch does.

PiperOrigin-RevId: 335559176
2020-10-05 20:43:55 -07:00
Dean Deng a1df7f2ed1 Simplify nil assignment in kcov.
PiperOrigin-RevId: 335548610
2020-10-05 19:05:26 -07:00
Fabricio Voznika 9e64b9f3a5 Fix gofer monitor prematurely destroying container
When all container tasks finish, they release the mount which in turn
will close the 9P session to the gofer. The gofer exits when the connection
closes, triggering the gofer monitor. The gofer monitor will _think_ that
the gofer died prematurely and destroy the container. Then when the caller
attempts to wait for the container, e.g. to get the exit code, wait fails
saying the container doesn't exist.

Gofer monitor now just SIGKILLs the container, and let the normal teardown
process to happen, which will evetually destroy the container at the right
time. Also, fixed an issue with exec racing with container's init process
exiting.

Closes #1487

PiperOrigin-RevId: 335537350
2020-10-05 17:40:23 -07:00
gVisor bot 8ef7cebcbb Merge pull request #4079 from lemin9538:arm64_fix
PiperOrigin-RevId: 335532690
2020-10-05 17:11:42 -07:00
gVisor bot 1bc78d9fda Merge pull request #3970 from benbuzbee:gomaxprocs
PiperOrigin-RevId: 335516972
2020-10-05 16:00:01 -07:00
Fabricio Voznika 9e9fec3a09 Enable more VFS2 tests
Updates #1487

PiperOrigin-RevId: 335516732
2020-10-05 15:54:36 -07:00
Kevin Krakauer e73bb6d302 Remove reference to deleted script
PiperOrigin-RevId: 335516625
2020-10-05 15:49:14 -07:00
gVisor bot 1c1eefbd4b Merge pull request #4368 from zhlhahaha:1979
PiperOrigin-RevId: 335492800
2020-10-05 13:59:12 -07:00
Ghanan Gowripalan 91e2d15a62 Remove AssignableAddressEndpoint.NetworkEndpoint
We can get the network endpoint directly from the NIC.

This is a preparatory CL for when a Route needs to hold a dedicated NIC
as its output interface. This is because when forwarding is enabled,
packets may be sent from a NIC different from the NIC a route's local
address is associated with.

PiperOrigin-RevId: 335484500
2020-10-05 13:18:57 -07:00
gVisor bot 5aa75653ab Internal change.
PiperOrigin-RevId: 335429072
2020-10-05 13:17:19 -07:00
Dean Deng e0aaf40e39 Fix kcov enabling and disabling procedures.
- When the KCOV_ENABLE_TRACE ioctl is called with the trace kind KCOV_TRACE_PC,
  the kcov mode should be set to KCOV_*MODE*_TRACE_PC.
- When the owning task of kcov exits, the memory mapping should not be cleared
  so it can be used by other tasks.
- Add more tests (also tested on native Linux kcov).

PiperOrigin-RevId: 335202585
2020-10-03 09:26:25 -07:00
gVisor bot 55f835d1fd Merge pull request #4377 from avagin:kvm-if-flag
PiperOrigin-RevId: 335122704
2020-10-02 16:30:05 -07:00
Andrei Vagin 28ced626a3 tools/checkescape: trim the "(SB)" before searching it in the allowed list
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-02 14:27:49 -07:00
Andrei Vagin de85b045d4 kvm/x86: handle a case when interrupts are enabled in the kernel space
Before we thought that interrupts are always disabled in the kernel
space, but here is a case when goruntime switches on a goroutine which
has been saved in the host mode. On restore, the popf instruction is
used to restore flags and this means that all flags what the goroutine
has in the host mode will be restored in the kernel mode. And in the
host mode, interrupts are always enabled.

The long story short, we can't use the IF flag for determine whether a
tasks is running in user or kernel mode.

This patch reworks the code so that in userspace, the first bit of the
IOPL flag will be always set. This doesn't give any new privilidges for
a task because CPL in userspace is always 3. But then we can use this
flag to distinguish user and kernel modes. The IOPL flag is never set in
the kernel and host modes.

Reported-by: syzbot+5036b325a8eb15c030cf@syzkaller.appspotmail.com
Reported-by: syzbot+034d580e89ad67b8dc75@syzkaller.appspotmail.com
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-02 13:16:58 -07:00
Adin Scannell 0cea647218 Save addresses for "allowed" functions.
PiperOrigin-RevId: 335086850
2020-10-02 13:14:16 -07:00
Rahat Mahmood 4f462b0ed9 Convert uses of the binary package in kernel to go-marshal.
PiperOrigin-RevId: 335077195
2020-10-02 12:24:24 -07:00
Jamie Liu ed94c0de51 Actually disable nodejs test parallel/test-fs-write-stream-double-close.
PiperOrigin-RevId: 335070320
2020-10-02 11:51:17 -07:00
Nayana Bidari d23f1ec0fa Update minimum RTT for RACK.
We are currently tracking the minimum RTT for RACK as smoothed RTT. As per RFC
minimum RTT can be a global minimum of all RTTs or filtered value of recent
RTT measurements. In this cl minimum RTT is updated to global minimum of all
RTTs for the connection.

PiperOrigin-RevId: 335061518
2020-10-02 11:09:35 -07:00
gVisor bot 02cff90ad9 Merge pull request #4035 from lubinszARM:pr_misc_01
PiperOrigin-RevId: 335051794
2020-10-02 10:27:03 -07:00
Chong Cai 7f39d53428 Add a verity test for modified parent Merkle file
When a child's root hash or its Merkle path is modified in its parent's
Merkle tree file, opening the file should fail, provided the directory
is verity enabled. The test for this behavior is added.

PiperOrigin-RevId: 334963690
2020-10-01 22:26:30 -07:00
gVisor bot cb41f67031 Merge pull request #3824 from btw616:fix/issue-3823
PiperOrigin-RevId: 334721453
2020-09-30 18:25:06 -07:00
Adin Scannell ae51aef5bb Ensure proctor is built as pure Go binary.
PiperOrigin-RevId: 334716351
2020-09-30 17:48:52 -07:00
Kevin Krakauer 6f8d64f422 ip6tables: redirect support
Adds support for the IPv6-compatible redirect target. Redirection is a limited
form of DNAT, where the destination is always the localhost.

Updates #3549.

PiperOrigin-RevId: 334698344
2020-09-30 16:04:26 -07:00
Arthur Sfez 7f9e13053e Count IP OutgoingPacketErrors in the NetworkEndpoint methods
Before this change, OutgoingPacketErrors was incremented in the
stack.Route methods. This was going to be a problem once
IPv4/IPv6 WritePackets support fragmentation because Route.WritePackets
might now know how many packets are left after an error occurs.

Test:
  - pkg/tcpip/network/ipv4:ipv4_test
  - pkg/tcpip/network/ipv6:ipv6_test
PiperOrigin-RevId: 334687983
2020-09-30 15:09:38 -07:00
Chong Cai 38704d9b66 Implement ioctl with measure in verity fs
PiperOrigin-RevId: 334682753
2020-09-30 14:45:12 -07:00
Chong Cai 490a1fc100 Internal change.
PiperOrigin-RevId: 334678513
2020-09-30 14:25:08 -07:00
gVisor bot 9751044a96 Merge pull request #2256 from laijs:kpti
PiperOrigin-RevId: 334674481
2020-09-30 14:07:43 -07:00
Ben Buzbee 12731f4271 Use consistent thread configuration for sandbox go runtime
With cgroups configured NumCPU is correct, however GOMAXPROCS is still derived from total host core count and ignores cgroup restrictions. This can lead to different and undesired behavior across different hosts.
For example, the total number of threads in the guest process will be larger on machines with more cores.

This change configures the go runtime for the sandbox to only use the number of threads consistent with its restrictions.
2020-09-30 20:32:33 +00:00
Julian Elischer 694d6ae32f Use the ICMP error response facility
Add code in IPv6 to send ICMP packets while processing extension headers.

Add some accounting in processing IPV6 Extension headers which
allows us to report meaningful information back in ICMP parameter
problem packets.

IPv4 also needs to send a message when an unsupported protocol
is requested.

Add some tests to generate both ipv4 and ipv6 packets with
various errors and check the responses.

Add some new checkers and cleanup some inconsistencies in
the messages in that file.

Add new error types for the ICMPv4/6 generators.

Fix a bug in the ICMPv4 generator that stopped it from generating
"Unknown protocol" messages.

Updates #2211

PiperOrigin-RevId: 334661716
2020-09-30 13:05:14 -07:00
Ayush Ranjan 3e450a991b [go-marshal] Port ext codebase to use go marshal.
PiperOrigin-RevId: 334656292
2020-09-30 12:39:25 -07:00
Kevin Krakauer b49a17fc3d Make all Target.Action implementation pointer receivers
PiperOrigin-RevId: 334652998
2020-09-30 12:22:58 -07:00
Chong Cai 299e5d6e40 Add verity fs tests
The tests confirms that when a file is opened in verity, the
corresponding Merkle trees are generated. Also a normal read succeeds on
verity enabled files, but fails if either the verity file or the Merkle
tree file is modified.

PiperOrigin-RevId: 334640331
2020-09-30 11:21:37 -07:00
Kevin Krakauer 3ef549b67f Set transport protocol number during parsing
PiperOrigin-RevId: 334535896
2020-09-29 23:21:46 -07:00
Kevin Krakauer 0aae51c6e0 iptables: remove unused min/max NAT range fields
PiperOrigin-RevId: 334531794
2020-09-29 22:41:47 -07:00
Ghanan Gowripalan e5ece9aea7 Return permanent addresses when NIC is down
Test: stack_test.TestGetMainNICAddressWhenNICDisabled
PiperOrigin-RevId: 334513286
2020-09-29 19:46:50 -07:00
Adin Scannell d4d9238c52 Stop depending on go_binary targets.
Closes #3374

PiperOrigin-RevId: 334505627
2020-09-29 18:34:59 -07:00
Rahat Mahmood 387501219e Replace remaining uses of reflection-based marshalling.
- Rewrite arch.Stack.{Push,Pop}. For the most part, stack now
  implements marshal.CopyContext and can be used as the target of
  marshal operations. Stack.Push had some extra logic for
  automatically null-terminating slices. This was only used for two
  specific types of slices, and is now handled explicitly.

- Delete usermem.CopyObject{In,Out}.

- Replace most remaining uses of the encoding/binary package with
  go-marshal. Most of these were using the binary package to compute
  the size of a struct, which go-marshal can directly replace. ~3 uses
  of the binary package remain. These aren't reasonably replaceable by
  go-marshal: for example one use is to construct the syscall
  trampoline for systrap.

- Fill out remaining convenience wrappers in the primitive package.

PiperOrigin-RevId: 334502375
2020-09-29 18:08:07 -07:00
Rahat Mahmood fee2c07728 go-marshal tests should respect build tags.
Previously, the go-marshal-generated tests did not respect build
tags. This can cause the test to unbuildable under some build
configurations, as the original types the tests refer to may not be
defined.

This CL copies the build tags from the input files to the test,
similar to the generated library; however test packages have an
additional constraint. A test package cannot be totally empty
(i.e. have no test/example/benchmark defined), otherwise the go
compiler returns an error. To ensure the generated test package always
contains a testable entity under all build configurations, we now emit
an extra test file with no build tags that contains a single no-op
example.

PiperOrigin-RevId: 334496821
2020-09-29 17:29:08 -07:00
Ghanan Gowripalan 6ae83404af Don't allow broadcast/multicast source address
As per relevant IP RFCS (see code comments), broadcast (for IPv4) and
multicast addresses are not allowed. Currently checks for these are
done at the transport layer, but since it is explicitly forbidden at
the IP layers, check for them there.

This change also removes the UDP.InvalidSourceAddress stat since there
is no longer a need for it.

Test: ip_test.TestSourceAddressValidation
PiperOrigin-RevId: 334490971
2020-09-29 16:54:23 -07:00
Fabricio Voznika 4a428b13b2 Add /proc/[pid]/cwd
PiperOrigin-RevId: 334478850
2020-09-29 15:49:27 -07:00
Kevin Krakauer 7fbb45e8ed iptables: refactor to make targets extendable
Like matchers, targets should use a module-like register/lookup system. This
replaces the brittle switch statements we had before.

The only behavior change is supporing IPT_GET_REVISION_TARGET. This makes it
much easier to add IPv6 redirect in the next change.

Updates #3549.

PiperOrigin-RevId: 334469418
2020-09-29 15:02:25 -07:00